Configuration Management is a crucial stage in DevOps lifecycle. It helps in the automation and orchestration of the IT infrastructure. There are several tools for configuration management, for example, Puppet, Ansible, Chef, and SaltStack. And, of course, Ansible is one of the most popular tools in DevOps. It can manage thousands of servers and your complete IT infrastructure with ease. We will cover the following in this article.

Ansible installationSSH key exchangeAnsible client setupAnsible testing

Ansible Installation

To keep it simple, let’s try using Ansible on two servers. One will be ansible-server and another one ansible-client with the following IP.

ansible-server – 10.0.0.1ansible-client – 10.0.0.25

Installation is straightforward…the following needs to be done on all the servers where you want to use Ansible. In this case, on above both servers.

Run the below command to install the necessary software required for installing ansible.

Install the repository with ansible package.

Update the advanced packaging tool (apt)

And, finally – run the command below to install

It will take few seconds to install the necessary package. How do you ensure its installed and its version? Well, it is easy. You can use –version syntax with ansible to find out like below. As you can see, Ansible 2.8.1 is installed and it provides the necessary information such as configuration file location, python module. Next, we need to do SSH key exchange so serve and a client can talk to each other.

SSH Key Exchange

Ansible connects to its client through SSH (Secure shell). We will first generate a public key on the ansible-server, which needs to be copied to the ansible-client. Ensure you are logged in as a root user.

Generate the key using ssh-keygen command as shown below

As you would have noticed, it has generated a public key in the .ssh folder. The complete path is /root/.ssh/id_rsa.pub Note: ensure the private and public key files are not world readable. You can list the files to verify them.

Go to the .ssh folder

List the files

If you notice permission is wrong, then you may change it by using chmod command Ex: Let’s copy the public key to Ansible host which IP address is 192.168.56.101 You can see in the output above, 1 key has been added successfully. This indicates that the SSH key is exchanged. Next, we will setup an Ansible client.

Ansible Client Setup

I assume you have already followed the Ansible installation steps on the client server as explained in previous steps. Client or Host setup is nothing but making the Ansible server aware of the clients. And, to do so:

Login to Ansible serverGo to /etc/ansibleAdd the following in hosts file by using your favorite editor

Save the hosts file

Ansible Test

If you have followed all the steps correctly, you will get a SUCCESS message when you run the below command on the ansible-server. Thea above pings to the client to test the connectivity and confirm if good or not. Conclusion I hope this gives you an idea to get it started with installation and playing around. Stay tuned for more Ansible tutorials or also check out this Udemy Mastering Ansible course.

How to Install and Configure Ansible on Ubuntu  - 72How to Install and Configure Ansible on Ubuntu  - 23How to Install and Configure Ansible on Ubuntu  - 10How to Install and Configure Ansible on Ubuntu  - 57How to Install and Configure Ansible on Ubuntu  - 83How to Install and Configure Ansible on Ubuntu  - 1How to Install and Configure Ansible on Ubuntu  - 41How to Install and Configure Ansible on Ubuntu  - 8How to Install and Configure Ansible on Ubuntu  - 41How to Install and Configure Ansible on Ubuntu  - 67How to Install and Configure Ansible on Ubuntu  - 15How to Install and Configure Ansible on Ubuntu  - 86How to Install and Configure Ansible on Ubuntu  - 8How to Install and Configure Ansible on Ubuntu  - 92How to Install and Configure Ansible on Ubuntu  - 69How to Install and Configure Ansible on Ubuntu  - 50How to Install and Configure Ansible on Ubuntu  - 49How to Install and Configure Ansible on Ubuntu  - 9How to Install and Configure Ansible on Ubuntu  - 41How to Install and Configure Ansible on Ubuntu  - 93How to Install and Configure Ansible on Ubuntu  - 97How to Install and Configure Ansible on Ubuntu  - 68How to Install and Configure Ansible on Ubuntu  - 67How to Install and Configure Ansible on Ubuntu  - 66