[PYTHON] I wanted to use the find module of Ansible2, but it took some time, so make a note

I wanted to use the find module of Ansible2, but it took some time, so make a note

environment

Apparently you need to get the source from GitHub and compile it instead of yum.

procedure

Follow the official procedure below to carry out the work. http://docs.ansible.com/ansible/intro_installation.html#running-from-source

An error occurred with the following command. .. ..

$ sudo pip install paramiko PyYAML Jinja2 httplib2 six

    gcc -pthread -fno-strict-aliasing -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=          ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -pipe -Wall -Wp,-D_FORTIFY_SOURC          E=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOU          RCE -fPIC -fwrapv -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/MD2.c -o build/temp.lin          ux-x86_64-2.7/src/MD2.o
    src/MD2.c:31:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-DJuN7X/pycrypto/setup.py';exec(compile          (getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-c          G6Sjn-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-buil          d-DJuN7X/pycrypto

When I looked it up, it seems that the cause is that there is no python develop tool. So

$ sudo yum install python-devel

When I executed the same command after installing the above package, it ended normally. Subsequent work could be carried out as it was without any errors.

Successful installation

Check the version and there seems to be no problem

$ ansible --version
ansible 2.0.0
  config file =
  configured module search path = Default w/o overrides

It's time to test!

$ echo "127.0.0.1" > ~/ansible_hosts
$ ansible all -m ping --ask-pass
SSH password:
127.0.0.1 | FAILED! => {
    "failed": true,
    "msg": "ERROR! to use the 'ssh' connection type with passwords, you must ins                                              tall the sshpass program"
}

That is an error. He asked me to put in an ssh pass. Then let's do exactly that.

$ sudo rpm -ivh http://ftp.iij.ad.jp/pub/linux/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
$ sudo yum install sshpass

It's time to test! (Part 2)

$ ansible all -m ping --ask-pass
SSH password:
127.0.0.1 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

Oh, I was able to communicate. Then, execute the find command that you wanted to use last.

$ ansible all -m find -a "paths=." --ask-pass
SSH password:
127.0.0.1 | SUCCESS => {
    "changed": false,
    "examined": 10,
    "files": [
        {
            "atime": 1448404038.6609726,
            "ctime": 1448403725.0179846,
            "dev": 64769,
            "gid": 1000,
            "inode": 611328,
            "isblk": false,
            "ischr": false,
            "isdir": false,
            "isfifo": false,
            "isgid": false,
            "islnk": false,
            "isreg": true,
            "issock": false,
            "isuid": false,
            "mode": "0664",
            "mtime": 1448403725.0179846,
            "nlink": 1,
            "path": "ansible_hosts",
            "rgrp": true,
            "roth": true,
            "rusr": true,
            "size": 10,
            "uid": 1000,
            "wgrp": true,
            "woth": false,
            "wusr": true,
            "xgrp": false,
            "xoth": false,
            "xusr": false
        }
    ],
    "matched": 1,
    "msg": ""
}

The file information was successfully acquired.

Finally

After all, considering the dependency, it is easy to put it in yum. However, there is no choice but to do this kind of work temporarily because the latest functions are not provided.

Recommended Posts

I wanted to use the find module of Ansible2, but it took some time, so make a note
I made a function to crop the image of python openCV, so please use it.
I tried to find out the difference between A + = B and A = A + B in Python, so make a note
[Fabric] I was addicted to using boolean as an argument, so make a note of the countermeasures.
A record of the time it took to deploy mysql on Cloud9 + Rails
I set up TensowFlow and was addicted to it, so make a note
Work memorandum (pymongo) Part 3. I don't want to look it up again, so make a note of it (aggregate)
I wanted to know the number of lines in multiple files, so I tried to get it with a command
I tried to scrape YouTube, but I can use the API, so don't do it.
[Python] I tried to implement stable sorting, so make a note
I tried to make a regular expression of "time" using Python
I tried to make a site that makes it easy to see the update information of Azure
I tried to make a calculator with Tkinter so I will write it
[Hi Py (Part 1)] I want to make something for the time being, so first set a goal.
Python: I want to measure the processing time of a function neatly
I was addicted to trying Cython with PyCharm, so make a note
The tree.plot_tree of scikit-learn was very easy and convenient, so I tried to summarize how to use it easily.
I thought I could make a nice gitignore editor, so I tried to make something like MVP for the time being
I thought it would be slow to use a for statement in NumPy, but that wasn't the case.
I made a tool to estimate the execution time of cron (+ PyPI debut)
A programming beginner tried to find out the execution time of sorting etc.
When I tried to make a VPC with AWS CDK but couldn't make it
I want to make a music player and file music at the same time
Use Pillow to make the image transparent and overlay only part of it
I failed to install django with pip, so a reminder of the solution
I want to see a list of WebDAV files in the Requests module
I didn't understand the Resize of TensorFlow so I tried to summarize it visually.
Make it easy to specify the time of AWS CloudWatch Events with CDK.
I wanted to create a dll to use a function written in C from Python with ctypes, but I had a hard time
The math of some entrance exam question is awkward to think about, so I left it to python after all
I use python but I don't know the class well, so I will do a tutorial
Tips for Python beginners to use the Scikit-image example for themselves 7 How to make a module
I tried to make something like a chatbot with the Seq2Seq model of TensorFlow
I can't find the clocksource tsc! ?? The story of trying to write a kernel patch
I uploaded a module to pypl that deletes Japanese stop words, so share it
It was a life I wanted to OCR on AWS Lambda to locate the characters.
A Python beginner made a chat bot, so I tried to summarize how to make it.
I just wanted to extract the data of the desired date and time with Django
I realized that it is nonsense to use the module without thinking because it is convenient.
I tried to make it easy to change the setting of authenticated Proxy on Jupyter
Make a note of the list of basic Pandas usage
I wanted to use the Python library from MATLAB
I stumbled upon using MoviePy, so make a note
Python Note: The mystery of assigning a variable to a variable
I tried running the sample code of the Ansible module
I don't like to be frustrated with the release of Pokemon Go, so I made a script to detect the release and tweet it
It took me half a day to install Polyglot in the anaconda environment on my mac, so I'll leave a note
Make a note of what you want to do in the future with Raspberry Pi
[Python] I want to make a 3D scatter plot of the epicenter with Cartopy + Matplotlib!
[Git] I tried to make it easier to understand how to use git stash using a concrete example
I want to find the intersection of a Bezier curve and a straight line (Bezier Clipping method)
When I got a list of study sessions in Python, I found something I wanted to make
I tried to find the entropy of the image with python
I tried to find the average of the sequence with TensorFlow
Make the display of Python module exceptions easier to understand
I want to use only the normalization process of SudachiPy
I made a function to check the model of DCGAN
(Note) How to pass the path of your own module
How to find the scaling factor of a biorthogonal wavelet
I want to know the legend of the IT technology world
I want to create a Dockerfile for the time being.