Installing Ansible on RHEL/CentOS 7

Using Vagrant, pip or a Docker containers, Ansible can be installed in different ways on all major Linux distributions.

The server where Ansible engine is installed is called the controller. The servers which Ansible will manage are called managed hosts. Installing Ansible on Windows machine to use as a controller is not supported. However, Windows machines can be managed by Ansible.

In this post we will explore how to install Ansible on a RHEL/CentOS 7.5 box using the yum native package manager. We will also review the commons best practice to follow after the installation to make the Ansible administration as smooth as possible.

The environment used will be one controller (server1) and two managed nodes (server1 and server2) as shown below. Server1 will play the of a controller and a managed hosts at the same time.

Before going ahead with the installation, let’s update the the system on all hosts.

 

  • Checking the Prerequisites


  • On the controller node

On RHEL, the Ansible Engine repository needs to be initially added

 

On CentOS, first ensure that the CentOS 7 EPEL repository is installed

 

  • On the managed nodes

To be able to use all available types of Ansible modules, Python needs to be installed on both the controller and any managed nodes

 

  • Installing Ansible


Once the prerequisites are installed, we can go ahead with the Ansible installation

 

  • Checking Ansible Successful Installation


To check if Ansible has been installed successfully, you can run the ansible command

 

Let’s check the Ansible version installed

 

We may also run a single ad-hoc command against the Ansible controller by pinging the localhost

 

If you encounter any issue ansible running this command, add the -vvvv flag to see more details:

 

That’s it for this post. In the next one, we will prepare the remote hosts to make them manageable from the controller host.

Find this post interesting. Share it!

3 Comments

  1. Pingback: Ansible for the Impatient Beginners – vAdmin-Land

  2. Samirlag

    Good documentation steps for beginners

    Reply
    1. Mourad NAKIB (Post author)

      Thanks Samir. I’m happy it helped.

      Reply

Leave a Comment

Your email address will not be published. Required fields are marked *