Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows. It includes its own declarative language to describe system configuration. Ansible was written by Michael DeHaan and acquired by Red Hat in 2015. Ansible is agentless, temporarily connecting remotely via SSH or Windows Remote Management (allowing remote PowerShell execution) to do its tasks.
1 Install ansible
Ansible is available in the EPEL repository of CentOS 8. So, you can easily install Ansible on CentOS 8. To enable EPEL repository, install the epel-release package with the following command:
sudo dnf install epel-release
Now install Ansibel by running the following command:
sudo dnf install ansible
Check that Ansible is successfully installed by using this command:
ansible --version
ansible 2.9.21
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
2 Configuration
In this section we are going to configure the Ansible.
First we are going to create a user ansible that will contain all the Playbooks and the configuration of the ansible in the home directory.
adduser ansible
Set a strong password for the new user:
passwd ansible
Changing password for user ansible.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Now, create an Ansible inventory file as follows:
touch /home/ansible/hosts