Red Hat, CentOS, and Fedora package installation
If you are using Yellowdog Updater, Modified (Yum), you will have an extra step, since Ansible is not located in the default RHEL repositories. As you may have experienced when installing tools in the past, the Extra Package for Enterprise Linux (EPEL) is often required to be installed before you can use the package manager to install the tools. This is a very straightforward step. We first need to download the epel-release rpm file from the Fedora Project website: http://fedoraproject.org/wiki/EPEL. We then need to install it using rpm as follows:
sudo rpm -i epel-release-latest-7.noarch.rpm
The Ansible engine repository (available at https://access.redhat.com/articles/3174981) is another valid repository to download the latest releases from Ansible. To access its packages using Red Hat Linux only, we first need to enable it as follows:
sudo subsription-manager repos --enable rhel-7-server-ansible-2.5-rpms
After that, the package manager will need to update its cache, the package list. We use Yum to do so, as follows:
sudo yum update
Just like installing any other package using Yum, we need to specify ansible as the input for the install option:
sudo yum install ansible
Most of the Red Hat family operating systems should accept those commands to set up Ansible. Fedora 18 and later versions have a next-generation package manager, Dandified Yum (DNF). This is currently the default package manager from Fedora 22 and onwards. After installing the EPEL package using RPM, we need to run the following command to update the DNF package list:
sudo dnf -y update
We then install Ansible using the following command:
sudo dnf -y install ansible
Using the Red Hat family of operating systems, Ansible installation can be done by getting the appropriate RPM file and installing it using RPM. First, we need to download the appropriate RPM file from the Ansible releases link: https://releases.ansible.com/ansible/rpm/. Download the RPM file with the desired Ansible version and install it as follows:
sudo rpm -Uvh ansible-2.5.5-1.el7.ans.noarch.rpm
If needed, RPM files can also be built and installed from a source easily. We recommend using the official GitHub Ansible repository. Firstly, we need to get the project folder using Git. We may need to have Git installed already to be able to download it easily:
git clone https://github.com/ansible/ansible.git
cd ansible
Then, we need to build the Ansible rpm file and install it using the same command:
make rpm
sudo rpm -Uvh rpm-build/ansible-*.noarch.rpm