Eager to install ansible on Ubuntu? Here’s how we do it.
Here at Bobcares, we have seen several such Ubuntu related installations as part of our Server Management Services for web hosts and online service providers.
Today we’ll see how to install Ansible on Ubuntu.
Know more about Ansible
Ansible is a simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs.
Moreover, it provides a simple architecture that doesn’t require special software to be installed on nodes, using SSH to execute the automation tasks and YAML files to define provisioning details.
In order to install it on ubuntu, you just need One Ansible Control Node and One or more Ansible Hosts.
How to install ansible on ubuntu
Now let’s take a look at how our Support Engineers install Ansible.
1. Install Ansible
First, you need to install ansible software on the machine that will serve as the Ansible control node. For that, run the below command.
$ sudo apt-add-repository ppa:ansible/ansible
Press ENTER when you are prompted to accept the PPA addition.
After that, refresh the system packages so that it will be aware of the newly included PPA.
$ sudo apt update
Then install the Ansible software with,
$ sudo apt install ansible
Now, the Ansible control node has all of the software required to administer the hosts.
2. Setting Up the Inventory File
The host information is present in the inventory file. In order to edit the contents of your default Ansible inventory, open the /etc/ansible/hosts file using your text editor, on your Ansible Control Node.
$ sudo nano /etc/ansible/hosts
Here is an example that defines a group named [servers] with three different servers in it, each identified by a custom alias: server1, server2, and server3.
[servers]
server1 ansible_host=203.0.xxx.xxx
server2 ansible_host=203.0.xxx.xxx
server3 ansible_host=203.0.xxx.xxx
[all:vars]
ansible_python_interpreter=/usr/bin/python3
Here, the all:vars
subgroup sets the ansible_python_interpreter host parameter that will be valid for all hosts included in this inventory.
Once done, save and close the file by pressing CTRL+X then Y and ENTER to confirm your changes.
Run the below command to check the inventory.
$ ansible-inventory --list -y
3. Testing Connection
After setting the inventory file, check if Ansible is able to connect to these servers and run commands via SSH.
Run the below command from the local machine or Ansible control node.
$ ansible all -m ping -u root
This command will use Ansible’s built-in ping module to run a connectivity test on all nodes from your default inventory, connecting as root.
[Need any further assistance with Ubuntu queries? – We are here to help you.]
Conclusion
In today’s writeup, we saw how our Support Engineers install Ansible on Ubuntu.
0 Comments