Would you like to learn how to do an Ansible installation on Ubuntu Linux? In this tutorial, we are going to show you how to install Ansible on a computer running Ubuntu Linux.
• Ubuntu 18.04
• Ubuntu 19.04
• Ansible 2.8.6
Hardware List:
The following section presents the list of equipment used to create this Ansible tutorial.
Every piece of hardware listed above can be found at Amazon website.
Ansible Related Tutorial:
On this page, we offer quick access to a list of tutorials related to Ansible.
Tutorial – Ansible Installation on Ubuntu Linux
Install the list of required packages.
Add the official Ansible repository to your APT database
Install Ansible.
Verify the Ansible version installed.
As an example, here is our output.
In our example, we installed Ansible on a computer using the IP address: 192.168.15.13
Create a local user account named ansible.
Use the SU comand to become the Ansible user.
Generate a SSH key to the Ansible user account.
Exit the local Ansible user account.
Edit the Ansible hosts file and add the list of desired Ansible nodes.
Edit the Ansible hosts file and add the list of desired Ansible nodes.
In our example, we add only 1 Ansible node using the IP address 192.168.15.12.
We created a group of Ansigle hosts named test.
On the command-lise of your Ansible node, create a user account named Ansible.
Don’t forget to set a password for the Ansible user account.
On the Ansible node, edit the SUDOERS configuration file
Add the following line at the end of the SUDOERS file.
Go back to the Ansible server command-line.
Use the ssh-copy-id command to copy the Ansible user account SSH key from the server to the node.
In our example, 192.168.15.12 is the IP address of the Ansible node.
Now, from the Ansible server, try to login on the Ansible node.
You will need to enter the SSH key password.
Logoff from the Ansile node and go back to the Ansible server.
On the Ansible server console, test the communication with the Ansible nodes.
Here is the command output:
On the Ansible server console, use the following command to get the Uptime of all Ansible nodes.
Here is the command output:
Congratulations! You have finished the Ansible installation on Ubuntu Linux.
Tutorial – Ansible Playbook Example
On the Ansible server, become the Ansible user.
Create an Ansible playbook.
Here is the content of the Ansible playbook named: playbook-test.yaml
In our example, the Ansible server will install the NTPDATE package using APT-GET on all hosts.
Use the following command to run your playbook.
Here is the playbook output.
Congratulations! You created an Ansible playbook successfully.