How to install Ansible on Ubuntu 18.04 step by step
This tutorial explains, install ansible on ubuntu 18.04
Ansible is an automation tool, that is used to manage remote machines. Ansible doesn’t require the installation of any agent on any remote Machine to manage them. It manages remote machines over the SSH protocol.
Ansible is installed on a Centralized Server and from there all other remote Machines are managed. Centralized Server where Ansible is installed is known as Control node and remote Machines are known as a Managed node.
Also Read: How to Install Jenkins on Ubuntu
& AWS EBS Volume snapshot backup and restore
Install Ansible on Ubuntu 18.04
Step 1– Update your Ubuntu Box
$ sudo apt update -y
Step 2– Install software-properties-common. It manages your distribution and independent software vendor software sources.
$ sudo apt install software-properties-common -y
Step 3- Add the following ppa(Personal Package Archives) to your System.
PPA is nothing but a unique software repository for nonstandard software/updates.
$ sudo apt-add-repository – -yes – -update ppa:ansible/ansible
Step 4– Use the apt command to install ansible.
$ sudo apt install ansible -y
Step 5– Check Ansible Version
$ ansible – -version
Basic Configuration of Ansible
Add remote Server’s IP that you want to manage, in the Ansible Inventory file. Ansible Inventory is managed by the file – /etc/ansible/hosts.
Put the IP addresses in the Inventory(hosts) file in the following way.
$sudo nano /etc/ansible/hosts
After adding, check your Inventory list by using the following command.
$ ansible-inventory -list -y
Create an ssh Connection
i)Generate a private key and public key in Control node(Ansible Server) using the following command.
$ ssh-keygen -t rsa
ii) The above command will create two files id_rsa and id_rsa.pub inside the .ssh folder. Copy the content of public-key (id_rsa.pub).
Note: Make sure the permission of id_rsa should be 400.
iii) Create a folder .ssh on the home directory of any user such as ec2-user on Managed node(Remote Servers). Create a file name authorized_keys inside .ssh folder
$ mkdir /home/ec2-user/.ssh
$ touch /home/ec2-user/.ssh/authorized_keys
iv) Copy the content of id_rsa.pub from the step ii) inside the file authorized_keys
Check connectivity to all hosts using the following command.
$ansible all -m ping -u ec2-user
Where ec2-user is the username that is able to ssh remote machines without a password.
Check connectivity to a host group using the following command.
$ ansible WebServer -m ping -u ec2-user
I hope you enjoyed this tutorial to install ansible on ubuntu 18.04. If you think this is really helpful, please do share this with others as well. Please also share your valuable feedback, comment or any query in the comment box. I will really happy to resolve your all queries.
If you think we helped you or just want to support us, please consider these:-
Connect to us: Facebook | Twitter