In this tutorial, we will show you how to install Ansible on Linux Mint 20. For those of you who didn’t know, Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It can be used both with Linux-based systems and Windows-based systems. Nowadays Ansible is also used to manage EC2 instances in AWS, Virtual machines, and Containers, etc. It does not require any agent on managed hosts, but it only requires ssh connection.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of an Ansible simple IT automation system on a Linux Mint 20 (Ulyana).
Install Ansible on Linux Mint 20 Ulyana
Step 1. Before running the tutorial below, it’s important to make sure your system is up to date by running the following
apt commands in the terminal:
sudo apt update sudo apt install openssh-server sudo apt install software-properties-common
Step 2. Installing Ansible on Linux Mint 20.
By default, Ansible is available on the Linux Mint base repository. Now we will install Ansible on Linux Mint 20 by executing the command below:
sudo apt install ansible
You can verify Ansible installation by checking the installed version:
Step 3. Setup SSH keys.
Ansible controller node uses ssh keys to access the host nodes, now we generate ssh key and copy the public key to the hosts’ authorized keys file:
Step 4. Configure Host Nodes for Ansible.
To share the ssh keys between control to managed hosts, run the
ssh-copy-id command example is shown below:
ssh-copy-id [email protected] ssh-copy-id [email protected]
Next, test if you can access the host nodes from the controller:
ssh [email protected] ssh [email protected]
Step 5. Create Ansible Inventory File.
Ansible inventory is a file that lists or defines the hosts to be managed via Ansible.
/etc/ansible/hosts is the default Ansible inventory file, To configure the inventory file you can open
/etc/ansible/hosts the file and adjust the configurations:
sudo nano /etc/ansible/hosts
Added the below lines:
node 1 ansible_host=192.168.77.20 node 2 ansible_host=192.168.77.21
Save and close a file, then confirm the servers, list the content of the inventory file with the command as shown below:
Step 6. Test Connection Ansible.
Once successfully configured both Ansible controller node and host nodes. Now Ansible should be able to connect to the servers listed in the inventory file using SSH:
ansible all -m ping -u meilana ansible node1 -m ping -u meilana
Check available space on Node1:
ansible node1 -a "df -h" -u meilana
To update all the nodes, run:
ansible all -m apt -a "upgrade=yes update_cache=yes" --become -K
Congratulations! You have successfully installed Ansible. Thanks for using this tutorial for installing the latest version of Ansible simple IT automation on the Linux Mint system. For additional help or useful information, we recommend you check the official Ansible website.