What is Ansible?
Ansible is an open-source IT automation tool developed by Red Hat that automates provisioning, configuration management, application deployment, and orchestration.
Key Characteristics
Agentless — no software installed on managed nodes; communicates over SSH (Linux) or WinRM (Windows).
Declarative & Procedural — you describe what you want (install nginx, ensure service is running) in YAML-based Playbooks.
Idempotent — running the same playbook multiple times produces the same result without unintended side effects.
Core Components
| Component | Description |
|---|---|
| Inventory | List of hosts/groups Ansible manages |
| Playbook | YAML file defining automation tasks |
| Task | A single unit of work (install package, copy file) |
| Module | Built-in function that does the actual work (yum, copy, service) |
| Role | Reusable, structured collection of tasks |
| Handler | Task triggered only when notified (e.g. restart nginx after config change) |
| Vault | Encrypts sensitive data (passwords, keys) |
| Control Node | Machine where Ansible runs |
| Managed Node | Target machine being automated |
Simple Playbook Example
- name: Install and start nginx hosts: webservers become: true # sudo tasks: - name: Install nginx ansible.builtin.yum: name: nginx state: present - name: Start and enable nginx ansible.builtin.service: name: nginx state: started enabled: true - name: Copy config file ansible.builtin.copy: src: nginx.conf dest: /etc/nginx/nginx.conf notify: Restart nginx # triggers handler only if file changed handlers: - name: Restart nginx ansible.builtin.service: name: nginx state: restarted
Common Use Cases
- Configuration management — enforce consistent state across 100s of servers
- Application deployment — deploy code, run migrations, restart services
- Provisioning — spin up cloud VMs, containers, network devices
- Orchestration — coordinate multi-tier deployments in order
- Patching — rolling OS updates across a fleet
- OpenShift/K8s automation — manage OCP clusters, operators, resources via
k8smodule
Ansible vs Other Tools
| Ansible | Puppet | Chef | Terraform | |
|---|---|---|---|---|
| Language | YAML | DSL | Ruby | HCL |
| Agent | Agentless | Agent | Agent | Agentless |
| Style | Procedural + Declarative | Declarative | Procedural | Declarative |
| Best for | Config mgmt + orchestration | Config mgmt | Config mgmt | Infrastructure provisioning |
In the OpenShift/Red Hat World
- Ansible Automation Platform (AAP) — enterprise version with UI, RBAC, scheduling
- ansible-playbook for OCP — automate cluster installs, day-2 ops, operator config
- OpenShift + Ansible — often used together; Ansible handles infra, OCP handles workloads
- Operator SDK — some operators are built using Ansible roles