Ansible: Installation and Host Configuration

Ansible Installation

Steps to install Ansible

  • For example, take three servers (1-Ansiblemaster, 2-Nodes)
  • Ansible as a means of managing our various servers, we need to install the Ansible software on at least one machine.


Ansible Installation on a CentOS/RedHat Server

Updating the machine.

#yum update

After updating the server with the above command, install the required packages

# rpm -Uvh

Installing Ansible on CentOS.

#yum install -y ansible

Verify Ansible Installation.

# ansible --version


Ansible Installation on Ubuntu Server

Update Server.

#apt update

After updating the server with the above command, install the required packages.

# apt install -y software-properties-common

Create a repository.

#sudo apt-add-repository ppa:ansible/ansible

Install Ansible on Ubuntu Server.

#apt install -y ansible

Verify Ansible installation.

# ansible --version

Ansible Configuration and Host Inventory

Configuration file default location:

#vi /etc/ansible/ansible.cfg

#cp /etc/ansible/ansible.cfg   ~/

#vi ansible.cfg

After this need to enable some configurations in “#vi ansible.cfg”.

   inventory =/root/hosts/

   library =/usr/share/my_modules/

   module_utils =/usr/share/my_module_utils/

   remote_tmp =~/.ansible/tmp

   local tmp = ~/.ansible/tmp

   plugin_filters_cfg =/etc/ansible/plugin_filters.yml

   forks =5

   poll_interval =15

   sudo_user =root

   transport =smart

   remote_port = 22

   module_lang =C




Host file default location:

#vi /etc/ansible/hosts

#cp /etc/ansible/hosts  ~/


After changing the path of the Host and ansible.cfg files, first add the remote server IPs in the host inventory file and save the file.

#vi hosts

To check the connection is held or not in master. We can check with this command.

#ansible all –list-hosts à to see all connected nodes lists

Get all node details.

#ansible all –m ping

#ansible all –m setup

See if the selected node is connected.

#ansible ubnt –m ping

Venkata Narayana Yarava

Venkata Narayana Yarava is an experienced Cloud DevOps Engineer with exposure to various technologies, he has a experience in DevOps Training and with different IT environments. He has a huge passion for automation technologies, specifically DevOps Tools, OpenStack, AWS, Linux, open source software. If you enjoy our articles please support us and make a small contribution: Buy Us A Coffee