Indrouction to Ansible
Ansible is a free, open-source software which is used to automate and configure several tasks in servers (and even your own host). Ansible can handle simple tasks ranging from configuration management, installation and updates, bootstraping machine to complex tasks like network automation, CI/CD and even cloud provisioning and management.
Ansible Architecture
A very simplified version of Ansible at high level can be:
flowchart LR
subgraph MN["Managed Nodes"]
direction LR
N1["Node1"]
N2["Node2"]
NN["NodeN"]
end
subgraph CN["Control Node"]
direction TD
Ansible["Ansible Software"]
Inventory@{ shape: doc, label: "Inventory File"}
Playbooks@{ shape: docs, label: "Playbook Files"}
Ansible -. lookup .-> Inventory
Ansible -. reads .-> Playbooks
end
CN -- automates --> MN
Control Node
Control node is where you install Ansible software and perform remote server management or automates tasks from. Ansible reads the playbook files you have written (in YAML) and performs intended actions in the servers listed in inventory file.
Inventory
This is just a file which lists hosts to manage. The file format can be INI or YAML. Ansible knows “which nodes” to perform actions against looking up this file.
Playbooks
Playbooks are files where you write “what action to perform” against which managed node. Ansible reads this file to perform intended tasks.
Managed Node
Any host which Ansible manages and listed in inventory file.
Features of Ansible
Ansible is designed around the following principles:
- Agent-less: No agent software need to be installed in managed nodes — can connect directly by SSH.
- Simplicity: You write instructions in declarative language like
YAML, Ansible does the heavy lifting. - Scalability and Flexibility: Introduce new OS tomorrow and it’s very likely Ansible supports that. It can quickly scale the systems you automate ranging from OS, network devices to cloud.
- Indempotency: When the system is already in the state your playbook describes, Ansible doesn’t try to change it even if you run multiple times. For example, if you instruct to “update nginx” and nginx is already up to date then there is no need to perfrom that action again.
How Ansible Automates Remote Systems?
Ansible automates remote systems by connecting to them over SSH (or other supported protocols) and executing predefined tasks from playbooks. It uses simple, agentless configuration files written in YAML to install software, manage files, configure services, and perform system updates across multiple machines consistently and efficiently.
Ansible General Workflow
Conceptually, these are the task you perform to automate servers:
flowchart TD
A[Configure Inventory] --> B[Configure SSH Access]
B --> C[Write Ansible Playbook]
C --> D[Run Ansible Playbook]
D --> E[Ansible Connects to Remote Hosts]
E --> F[Execute Tasks]
F --> G[Check Results]
G --> H[Fix / Update Playbook]
H --> D