What is Ansible?
· Category: DevOps & CI/CD
Short answer
Ansible is an open-source automation tool for configuration management, application deployment, and orchestration. It uses SSH and does not require agents on target machines.
How it works
Ansible connects to nodes via SSH and executes modules written in Python. Playbooks define the desired state in YAML. The inventory file lists the target hosts.
Example
---
- name: Install nginx
hosts: webservers
become: yes
tasks:
- name: Ensure nginx is installed
apt:
name: nginx
state: present
Why it matters
Ansible is simple to learn and agentless, making it easy to adopt. It is ideal for configuration drift correction, patch management, and repeatable deployments.
Tips
- Use roles to organize playbooks.
- Use Ansible Vault for secrets.
- Test playbooks with Molecule.
Common issues
- SSH connectivity must be configured.
- Idempotency is not guaranteed for all modules.
- Large inventories slow down execution.