Ansible and Target Servers

Michael Mensah
3 min readMay 1


Ansible and Target Servers

What is Ansible — an open-source automation tool used for configuration management, application deployment, and task automation. The ansible control engine, which operates separately, relies on three components to facilitate the process. In addition, Ansible has the capability to authenticate login on target servers using the existing SSH protocol. The three components are as follows:

  1. Control Engine — This is the Ansible software that possesses intelligence on how to configure software packages across multiple servers.
  2. Inventory File — This file contains the IP addresses of the target servers and specifies where configuration needs to occur.
  3. Modules — These modules assist Ansible in performing the configuration across the target servers.

Let see how to implement an Ansible on 3 target servers.

First — Launch your instances

Second — Login to the Ansible control engine and Install Ansible.

Amazon Linux 2 AMI
Install Ansible using command -
Amazon-linux-extras install ansible2 -y
#Check the version of Ansible with the command - 
ansible --version

Second — Configure the Inventory file by going to the ansible location where the file are located.

cd /etc/ansible/
ls -l
vi hosts (Copy and paste all your targer server IP address in the host file)
Shift + : on your keyboard - wq to save your entry in the vim editor

Three —

1. Configure SSH passwordless authentication on the Ansible control engine.

2. Copy the public key to the “.ssh” directory on the target servers.

3. Create a file named “authorized_keys” and copy the public key into it.

#Create a key
ssh-keygen -t rsa (This generates both the priviate and public keys)

Four — Copy public key from Ansible control engine to the authorize keys in the target servers.

#Copy public to the authorize_keys in the target servers
cat ~/.ssh/
#login to one of the targer server
cd /root
ls -la
cd .ssh
#created a file called authorized_keys and copy and pay the publics from
Ansible control engine.
vi authorized_keys

Fifth — Test login to all 3 target servers from your Ansible control engine.

From the screenshot I am able to authenticate to all 3 servers from my ansible control engine.

Note — After project kindly terminate all servers to avoid any chargers.

In conclusion, this is how to set up Ansible to manage configuration across three or more targets servers.

Thank you all for stopping by to read my Mini project with MensahCloud.



Michael Mensah

Cloud Systems Engineer | DevOps Engineer