Goal: Install ansible on a RedHat Linux machine.
Little overview on how it all started: When my Linux machine was RedHat 5.9 (Tikanga), the default python installed version was 2.4. I tried my best, but couldn't get anything to work as Ansible requires python >= 2.6. I tried installing 2.7.9 on Linux 5.9 version but then things started to act up really fast.
I did try 2.7.9 python on Linux 5.9 as "make altinstall" instead of install but still there were lots of errors while running yum / etc system level commands.
Few errors which came there were (with or without running sudo):
# sudo pip install ansible
Traceback (most recent call last):
File "/usr/bin/pip", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 236, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2097, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1830, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.4/site-packages/pip-6.0.8-py2.4.egg/pip/__init__.py", line 211
except PipError as exc:
^
SyntaxError: invalid syntax
or
# sudo easy_install pip
Searching for pip
Best match: pip 6.0.8
Processing pip-6.0.8-py2.4.egg
pip 6.0.8 is already the active version in easy-install.pth
Installing pip script to /usr/bin
Installing pip2 script to /usr/bin
Installing pip2.4 script to /usr/bin
Using /usr/lib/python2.4/site-packages/pip-6.0.8-py2.4.egg
Processing dependencies for pip
or
# sudo pip install ansible
Traceback (most recent call last):
File "/usr/bin/pip", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 236, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2097, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1830, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.4/site-packages/pip-6.0.8-py2.4.egg/pip/__init__.py", line 211
except PipError as exc:
^
SyntaxError: invalid syntax
or
# sudo easy_install ansible
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in ?
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
etc....
Finally to my luck, I thought, let's try installing python again from scratch (so I ran yum erase python, !!! beware !!!!) and to my knowledge, it was the best command I ever ran in my experience with a little oversight. End result: I ended up creating a new product, here: http://www.keepcalmandcarryon.com/creator/?shortcode=qCsMlpyc
Anyways, ... Now, I got the server revived with a newer version of RedHat (version 6.6 Santiago) and this time default Python on it was: 2.6.6.
Current situation: THIS is what I'm facing now, on RH Linux 5.9 with Python 2.6.6 installed.
I'm running: sudo easy_install pip but I got an error:
sudo: easy_install: command not found
To resolve the above, I'm now running: sudo yum install python-setuptools
It found it... but showing me some an error.
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
http://74.125.194.100/yum/x86_64/6Server/%24YUM0/Server/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
http://74.125.194.100/yum/x86_64/supplemental/%24YUM0/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Resolving Dependencies
--> Running transaction check
---> Package python-setuptools.noarch 0:0.6.10-3.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================
Installing:
python-setuptools noarch 0.6.10-3.el6 release.update 336 k
Transaction Summary
==============================================================================================================================================================================================================================
Install 1 Package(s)
Total download size: 336 k
Installed size: 1.5 M
Is this ok [y/N]: y
Downloading Packages:
http://74.125.194.100/yum/x86_64/6Server/%24YUM0/Server/../Packages/python-setuptools-0.6.10-3.el6.noarch.rpm: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error Downloading Packages:
python-setuptools-0.6.10-3.el6.noarch: failure: ../Packages/python-setuptools-0.6.10-3.el6.noarch.rpm from release.update: [Errno 256] No more mirrors to try.
-bash-4.1$
Any idea, how can i get easy_install, pip or ansible on my Linux machine 6.6 (now).
Thanks.
Ran the following commands to fix everything and now ansible is finally installed:
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -ivh epel-release-6-8.noarch.rpm
But at this stage, I got an error for Jinja2 ... as below: ImportError: No module named setuptools
-bash-4.1$ sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 40, in <module>
from setuptools import setup, Extension, Feature
ImportError: No module named setuptools
-bash-4.1$
To fix the above and proceed, I ran the following commands to get python-setuptools (which installs easy_install)
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
Great, now I have easy_install installed on my machine.
-bash-4.1$ which easy_install
/usr/bin/easy_install
-bash-4.1$
At this point, I wanted to install ANSIBLE, so I ran the following:
sudo easy_install pip
sudo pip install ansible
The last line in the above ansible install command's output was:
Successfully installed ansible-1.9.0.1 jinja2-2.7.3 markupsafe-0.23 pycrypto-2.6.1
Now, I can see ansible on my machine.
-bash-4.1$ which ansible
/usr/bin/ansible
-bash-4.1$
Oh, oh... something is still not good:
-bash-4.1$ ansible --help
Traceback (most recent call last):
File "/usr/bin/ansible", line 36, in <module>
from ansible.runner import Runner
File "/usr/lib/python2.6/site-packages/ansible/runner/__init__.py", line 62, in <module>
from Crypto.Random import atfork
File "/usr/lib64/python2.6/site-packages/Crypto/Random/__init__.py", line 29, in <module>
from Crypto.Random import _UserFriendlyRNG
File "/usr/lib64/python2.6/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, in <module>
from Crypto.Random.Fortuna import FortunaAccumulator
File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, in <module>
import FortunaGenerator
File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 34, in <module>
from Crypto.Util.number import ceil_shift, exact_log2, exact_div
File "/usr/lib64/python2.6/site-packages/Crypto/Util/number.py", line 56, in <module>
if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
-bash-4.1$
I checked, my LD_LIBRARY_PATH variable was already set/exported as:
LD_LIBRARY_PATH=/usr/lib64/:/usr/local/lib64
Then what else... OK.
Ran the following steps/commands to resolve the above error and get ansible to actually WORK!!!. For prompts, I said Yes "y".
echo "y" | sudo pip uninstall pycrypto
echo "y" | sudo yum erase python-crypto
echo "y" | sudo pip uninstall ansible
sudo pip install ansible
## Time to get gmplib 6.0.0(a) etc
wget https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2
tar -xvjpf gmp-6.0.0a.tar.bz2
## Change to the above extracted folder and run some commands, seems like they'll run forever.
cd gmp-6.0.0
./configure
sudo make || echo "these few steps will take good amt of time to complete"
sudo make check || echo "hang on and see if all tests passes in the check process"
sudo make install || echo "final shenzi will be done shortly"
sudo make check || echo "really!!!! ????"
which ansible
ansible || ansible --help
!!! FINALLY !!! ----
-bash-4.1$ which ansible
/usr/bin/ansible
-bash-4.1$ ansible
Usage: ansible <host-pattern> [options]
Options:
-a MODULE_ARGS, --args=MODULE_ARGS
module arguments
--ask-become-pass ask for privilege escalation password
-k, --ask-pass ask for SSH password
--ask-su-pass ask for su password (deprecated, use become)
-K, --ask-sudo-pass ask for sudo password (deprecated, use become)
--ask-vault-pass ask for vault password
-B SECONDS, --background=SECONDS
run asynchronously, failing after X seconds
(default=N/A)
-b, --become run operations with become (nopasswd implied)
--become-method=BECOME_METHOD
privilege escalation method to use (default=sudo),
valid choices: [ sudo | su | pbrun | pfexec | runas ]
--become-user=BECOME_USER
run operations as this user (default=root)
-C, --check don't make any changes; instead, try to predict some
of the changes that may occur
-c CONNECTION, --connection=CONNECTION
connection type to use (default=smart)
-e EXTRA_VARS, --extra-vars=EXTRA_VARS
set additional variables as key=value or YAML/JSON
-f FORKS, --forks=FORKS
specify number of parallel processes to use
(default=5)
-h, --help show this help message and exit
-i INVENTORY, --inventory-file=INVENTORY
specify inventory host file
(default=/etc/ansible/hosts)
-l SUBSET, --limit=SUBSET
further limit selected hosts to an additional pattern
--list-hosts outputs a list of matching hosts; does not execute
anything else
-m MODULE_NAME, --module-name=MODULE_NAME
module name to execute (default=command)
-M MODULE_PATH, --module-path=MODULE_PATH
specify path(s) to module library (default=None)
-o, --one-line condense output
-P POLL_INTERVAL, --poll=POLL_INTERVAL
set the poll interval if using -B (default=15)
--private-key=PRIVATE_KEY_FILE
use this file to authenticate the connection
-S, --su run operations with su (deprecated, use become)
-R SU_USER, --su-user=SU_USER
run operations with su as this user (default=root)
(deprecated, use become)
-s, --sudo run operations with sudo (nopasswd) (deprecated, use
become)
-U SUDO_USER, --sudo-user=SUDO_USER
desired sudo user (default=root) (deprecated, use
become)
-T TIMEOUT, --timeout=TIMEOUT
override the SSH timeout in seconds (default=10)
-t TREE, --tree=TREE log output to this directory
-u REMOTE_USER, --user=REMOTE_USER
connect as this user (default=c400093)
--vault-password-file=VAULT_PASSWORD_FILE
vault password file
-v, --verbose verbose mode (-vvv for more, -vvvv to enable
connection debugging)
--version show program's version number and exit
-bash-4.1$
PS: Stay away if you can from "yum erase python" and entering "y" for it, good luck.