Day 17: Ansible - Installation and configuration
1 min read
The Ansible control node runs on Linux (or macOS/WSL). Managed Windows hosts are supported — they just go in the inventory; only the controller needs a Unix-like system.
Update the system
Debian-based (Ubuntu, Debian):
sudo apt-get update
sudo apt-get upgrade
RHEL-based (CentOS, RHEL, Fedora):
sudo dnf update
(yum still works as a compatibility symlink on older releases.)
Install Python
Debian-based:
sudo apt-get install -y python3
RHEL-based:
sudo dnf install -y python3
Install Ansible
Debian-based:
sudo apt-get install -y ansible
RHEL-based (requires EPEL on RHEL/CentOS):
sudo dnf install -y epel-release
sudo dnf install -y ansible
Verify the install
ansible --version
Configure Ansible
Ansible reads /etc/ansible/ansible.cfg for defaults. Create an inventory file at /etc/ansible/hosts, for example:
[webservers]
192.168.1.10
192.168.1.11
Then point Ansible at it in /etc/ansible/ansible.cfg:
[defaults]
inventory = /etc/ansible/hosts
Ansible is now installed and ready to use.