What is infrastructure automation?
Without automation, a DevOps engineer manually creates servers, installs software, configures firewalls, and deploys apps — repeating the same work for every host.
With automation, you write the process once and the tool applies it consistently across many servers.
Infrastructure automation = managing servers and cloud resources
automatically with scripts and DevOps tools.
Shell vs Python vs Ansible
| Approach | Example | Pain |
|---|---|---|
| Shell | apt install openjdk-17-jdk -y | Login to every server; hard at scale |
| Python | os.system("apt install ...") | Extra scripting; not infra-focused |
| Ansible | ansible-playbook java.yml | Built for fleets; idempotent |
If Java is already installed, Ansible skips safely. A naive shell script may run the install again every time.
What is Ansible?
Ansible is an open-source automation tool used for:
- Configuration management — packages, services, files, users
- Provisioning — cloud resources (also possible; Terraform often preferred)
- Deployment — ship apps as part of CI/CD
- Network automation — routers, switches, firewalls
Ansible vs Terraform
| Ansible | Terraform |
|---|---|
| Configuration management | Infrastructure provisioning |
| Configures existing servers | Creates infrastructure |
| YAML | HCL |
| Agentless (SSH) | Cloud APIs |
| Install software & deploy apps | Create EC2, VPC, LB, etc. |
| Procedural / task-oriented | Declarative desired state |
One line: Terraform creates infrastructure; Ansible configures and manages it.
Real-world flow
- Terraform — EC2, network, security groups
- Ansible — Docker, Nginx, Node.js, app deploy
Why companies use Ansible
- Agentless — no agent on targets; SSH is enough
- SSH + Python — secure, widely available
- Simple YAML — readable playbooks
- Idempotent modules — safe to rerun
- Huge module ecosystem
- name: Install Nginx
apt:
name: nginx
state: presentHow Ansible works
| Piece | Role |
|---|---|
| Control node | Where Ansible is installed; sends tasks |
| Managed nodes | Target servers |
| Inventory | Hosts and groups |
| Playbook | YAML automation tasks |
| SSH | Connection — no agent required |
Control Node
↓
Inventory
↓
SSH
↓
Managed Nodes
↓
Execute tasks / playbooks
Ansible works by connecting from a control node to managed servers over SSH and executing automation tasks.
Push vs pull
| Push (Ansible) | Pull (e.g. some CM agents) |
|---|---|
| Control node pushes config | Hosts pull config on a schedule |
| Fast and simple | Needs an agent / pull client |
| No agent on targets | Agent must be installed |
Ansible uses a push model from the control node.