Ansible: Installation and Initial Setup
What is Ansible?
Let's cut the chase. Ansible is tool for system and network admins to automate repetitive tasks for example installing and configuring multiple servers, and configuring routers, switches, firewalls, and WAPs at once. Ansible can talk to any device that talks the SSH language. Visit Ansible Documentation page to learn more.
This is not going to be step by step tutorial on how to using Ansible nor an in depth overview of Ansible. A lot of important basic topics will be missing from this post but they might appear in future posts. So if something is missing here, you can always look at the other posts in the same category. If something in my sayings does not feel right, you can reach out to me with questions or suggestions via LinkedIn or Email.
How to Install Ansible on Linux
Ansible is agent less. That means that you do not need to install Ansible on the managed nodes to have Ansible push some tasks into them. So only the control node needs to have Ansible installed on it. But you will need python and SSH installed and configured on the managed nodes.
You have multiple ways to install Ansible on your Linux workstation but I will be using the method via the Linux package manager.
How to locate python?
which python3
# /usr/bin/python3
How to locate SSH?
sudo systemctl status sshd
The ssh daemon must enabled, active, and running.
Update your system:
sudo dnf update -y
Install Ansible using the package manager
sudo dnf install ansible -y
Ansible keeps its main configuration files in /etc/ansible. There you should find the files ansible.cfg and hosts.
Run ansible --version to get details about your Ansible installation. The command will also tell you the location of your Ansible default configuration file.
If you install Ansible using the Linux package manager, you should have the config file generated and set in Ansible. In case you are missing the ansible.cfg file in your installation, you can create it the file /etc/ansible/ansible.cfg. There are many ways to set Ansible configuration file but I am going stick with the one generated by default during the installation.
Ansible Inventory
Ansible inventory contains the list of hosts you want to manage. By default the hosts file contains the list of nodes but you can customize the hosts file inside ansible.cfg. In the hosts file, you can put the nodes into groups like:
[web]
172.16.10.10
172.16.10.12
[db]
172.16.20.22
If you're able to run ansible --version without issue and locate ansible installation folder (/etc/ansible), you are good to do awesome things with ansible. In the next posts, we are going to deaper in the basics of ansible.
So, stay tuned.