Ansible is a popular open-source automation platform that is used for managing and configuring remote systems. In this article, we will look at how to install Ansible on Rocky Linux 8.
The first step in installing Ansible is to add the Ansible repository to your system. This can be done by running the following commands in the terminal:
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo <https://download.ansible.com/ansible/rpm/stable/x86_64_linux>
Next, update your system’s package list by running the following command:
sudo dnf update
Now you are ready to install Ansible. This can be done by running the following command:
sudo dnf install -y ansible
Once the installation is complete, you can verify that Ansible is working correctly by running the ansible --version
command, which should print the version number of Ansible that is installed on your system.
To use Ansible, you will need to create an inventory file that specifies the systems that Ansible will manage. This file is typically called /etc/ansible/hosts
and has a simple format that lists the hostnames or IP addresses of the systems that Ansible will manage. For example, a simple inventory file might look like this:
[webservers]
192.168.1.10
192.168.1.11
192.168.1.12
[dbservers]
192.168.1.20 192.168.1.21
In this example, the webservers
and dbservers
groups are defined, and each group contains a list of hostnames or IP addresses. You can add as many groups and systems as you need to your inventory file, and you can use these groups to target specific systems when running Ansible commands.
Once you have created your inventory file, you can test that Ansible is able to connect to the systems that are listed in it by running the following command:
ansible all -m ping
This command will run the ping
module on all of the systems in the inventory file, and it should print a message indicating whether the ping was successful or not for each system.
In conclusion, installing Ansible on Rocky Linux 8 is a simple process that involves adding the Ansible repository, updating the package list, and installing the Ansible package. Once installed, you can create an inventory file to specify the systems that Ansible will manage, and you can use the ansible
command to run Ansible modules and perform other tasks.