Ansible is the most popular agentless automation tool for IT infrastructure. It works over SSH, requiring no software on target servers.
Installing Ansible
sudo apt update && sudo apt install -y ansible
sudo dnf install -y ansible-core
ansible --version
Inventory Setup
[webservers]
web1 ansible_host=192.168.1.10
web2 ansible_host=192.168.1.11
[all:vars]
ansible_user=deploy
Your First Playbook
---
- name: Configure web servers
hosts: webservers
become: yes
tasks:
- name: Install Nginx
apt:
name: nginx
state: present
- name: Start Nginx
systemd:
name: nginx
state: started
enabled: yes
Running Playbooks
ansible-playbook setup.yml --syntax-check
ansible-playbook setup.yml --check
ansible-playbook setup.yml
Using Roles
ansible-galaxy init roles/webserver
Master Ansible with our DevOps eBook collection.