How to install Ansible on Ubuntu 22.04
In this tutorial, we will guide you how you can install Ansible on Ubuntu 22.04 using the easiest method whose steps are given below and, in the end, we will also show you how you can configure Ansible to use it for automation.
Steps to install Ansible on Ubuntu 22.04
Step 1: First, install some useful required packages if not already installed for running Ansible on Ubuntu 22.04 using the following command:
Step 2: Now, add the Ansible repository in order to successfully install the latest Ansible version on Ubuntu 22.04:
Step 3: Once the repository is added, you can then execute the Ansible installation through the following command:
After completing the Ansible installation, use the following command to check its version:
Steps to Configure Ansible on Ubuntu 22.04
Now, the next task is to configure Ubuntu hosts for Ansible automation. You can automate Ansible using multiple hosts and setting up each host requires exactly the same step performed for the initial host.
To configure a host, you will need to perform the following steps.
Step 1: First, install OpenSSH via the following command:
You can also check the status of SSH using the following command:
Step 2: Next, configure firewall to allow the SSH access on Ubuntu 22.04 using the following command:
Step 3: Now, create an Ansible user through the below-given command. This step will require setting up a password of your own:
After updating the password, you will be required to provide your full name and other information:
Enter “Y” to complete the step.
This will add the Ansible user.
Step 4: Now, execute the below-given command to allow Ansible users to enable password-less sudo access:
Step 5: Next, Generate SSH keys using the below mentioned command:
Press Enter in all next options without typing anything to generate SSH keys:
Step 6: Next, copy the SSH public key to Ansible host using the following command.
Type “yes” in the next option:
Set password for first user.
This will add the first user as “ansible”. You can add more you want using the above steps.
Step 7: Once the hosts are created, you can then use the following command to add hosts:
In our case, we have only one host, you can add other hosts. Save the file after adding the hosts. Then use the following command to ping the hosts.
That’s it, the above command’s output ensures that you have perfectly set up Ansible on your Ubuntu.
Ansible is an excellent IoT automation tool that allows users the opportunity to implement different IoT tasks including software deployment, configuration management and more. The installation is pretty simple on Ubuntu while the main thing matters is how you configure Ansible. The above guidance will be helpful in installing and setting up Ansible on Ubuntu 22.04.