Ansible automates repetitive server tasks using simple YAML playbooks without agents on remote servers.
Install and Configure Inventory
sudo apt install ansible -y
sudo nano /etc/ansible/hosts
[webservers]
web1.yourdomain.com
web2.yourdomain.com
[all:vars]
ansible_user=ubuntu
Test Connection
ansible all -m ping
ansible webservers -m command -a "uptime"
Write a Playbook
---
- name: Configure Web Servers
hosts: webservers
become: yes
tasks:
- name: Install Nginx
apt: name=nginx state=present
- name: Start Nginx
systemd: name=nginx enabled=yes state=started
Run
ansible-playbook setup-webserver.yml --check # dry run
ansible-playbook setup-webserver.yml
Conclusion
Ansible eliminates manual server configuration drift. Our team uses Ansible for consistent server deployments.
Comments