Ansible is not in the default RHEL 7 repositories, but in this recipe, I will show you how to install it in several ways.
Ansible needs the following packages installed:
python-httplib2
python-jinja2
python-paramiko
python-setuptools
PyYAML
So, in order to achieve this, execute the following command:
~]# yum install -y python-httplib2 python-jinja2 python-keyczar python-paramiko python-setuptools PyYAML
As RHEL 7 and some other major distributions come preinstalled with Python (yum requires it, as do most of the Red Hat tools), we don't have to include it in the preceding command.
In this recipe, I will cover the three most used methods of installing Ansible.
This method is quite simple as you just download the tarball and extract it in a location of your choosing. Perform the following steps:
~]$ curl -o /tmp/ansible-latest.tar.gz http://releases.ansible.com/ansible/ansible-latest.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 905k 100 905k 0 0 870k 0 0:00:01 0:00:01 --:--:-- 870k ~]$
/opt
, as follows:~]# tar zxf /tmp/ansible-latest.tar.gz -C /opt/
~]# ln -s /opt/ansible-1.9.2 /opt/ansible
~]# cat << EOF > /etc/profile.d/ansible.sh # Ansible-related stuff export ANSIBLE_HOME=/opt/ansible export PATH=${PATH-""}:${ANSIBLE_HOME}/bin export MANPATH=${MANPATH-""}:${ANSIBLE_HOME}/docs/man export PYTHONPATH=${PYTHONPATH-""}:${ ANSIBLE_HOME}/lib EOF ~]#
~]# . /etc/profile.d/ansible.sh
~]# /etc/cron.daily/man-db.cron
Git makes keeping your local copy of Ansible up to date quite simple.
It automatically updates/removes files where needed. Perform the following steps:
git
is installed using this command:~]# yum install -y git
git
repository to /opt
, as follows:~]# cd /opt ~]# git clone git://github.com/ansible/ansible.git --recursive
~]# cat << EOF > /etc/profile.d/ansible.sh # Ansible-related stuff export ANSIBLE_HOME=/opt/ansible export PATH=${PATH-""}:${ANSIBLE_HOME}/bin export MANPATH=${MANPATH-""}:${ANSIBLE_HOME}/docs/man export PYTHONPATH=${PYTHONPATH-""}:${ ANSIBLE_HOME}/lib EOF ~]#
~]# . /etc/profile.d/ansible.sh
~]# /etc/cron.daily/man-db.cron
Installing from a repository has the advantage that you can keep your version of Ansible up to date along with your system. Here are the steps you need to perform:
~]# yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
~]# yum install -y ansible