Install Ansible on Red Hat Enterprise Linux
As far as automated configuration management tools go, Ansible is “the new hotness” on the market. I admit, I am pretty new to Ansible. Until recently, the majority of my configuration management experience has been rooted solely in Puppet. Tack onto that my recent foray back into the world of Red Hat and I have a lot to learn, starting with getting Ansible installed and running on RHEL. There are two ways to install Ansible—via yum, or directly from source. Yum is obviously easier. However, in the event you are working in a closed system, compiling from source may be your only option. I’ll cover both in this article.
Ansible is not available in the default RHEL repositories, so we need to install Extra Packages for Enterprise Linux (EPEL) in order to install it via yum. To do so, head on over to http://fedoraproject.org/wiki/EPEL and download the newest version of epel-release for your version of RHEL. Once you’ve downloaded that file, navigate to the download location in a terminal and install the RPM using the following command:
sudo rpm -i epel-release-latest-7.noarch.rpm
After installing EPEL, you need to update your package list. This tells yum about all the new packages you can install.
sudo yum update
And that’s it! Well, not really. We still need to install Ansible, but we’re done with the setup portion. Installing Ansible via yum works much the same way as any other yum package. Simply pop open a terminal and run the following command:
sudo yum install ansible
Now, we are done. To test things out, simply ping your Ansible server on localhost. You should receive a “pong” in response.
ansible localhost -m ping
If using third-party package repositories is impractical or impossible, your next best option is compiling Ansible via source. While this seems like a much more involved process, it is just as straightforward as the yum install. To begin, let’s clone the GitHub repository:
git clone git://github.com/ansible/ansible.git --recursive cd ./ansible git submodule update --init --recursive
Once the Ansible repository is finished downloading, we need to install some dependencies. First, we need to install Python via yum:
sudo yum install python
Next, we need to install a few required Python modules:
sudo easy_install pip
And finally, we simply need to install Ansible to our system:
sudo make install
Now, like before, simply run the ping command to test our newly installed Ansible!
ansible localhost -m ping
And that’s it! Ansible is now ready to rock and roll on Red Hat Enterprise Linux! For more in-depth information about properly configuring and using Ansible, head on over to their website at https://www.ansible.com/.
Zachary Flower (@zachflower) is a freelance web developer, writer, and polymath. He has an eye for simplicity and usability, and strives to build products with both the end user and business goals in mind. From building projects for the NSA to creating features for companies like Name.com and Buffer, Zach has always taken a strong stand against needlessly reinventing the wheel, often advocating for the use of well established third-party and open source services and solutions to improve the efficiency and reliability of a development project.
Join the Red Hat Developer Program (it's free) and get access to related cheat sheets, books, and product downloads.