Skip to main content
What is Ansible? Ansible is an open-source automation tool for configuration management, application deployment, orchestration, and task automation. Instead of manually repeating the same steps across multiple servers, you declare the desired state (what the servers should look like) and let Ansible apply those instructions consistently and idempotently. Why do we need it? Imagine you run the same website on 20 servers. Each server must have Apache installed and the same configuration file. If you configure each machine by hand you duplicate effort and increase the risk of mistakes:
One missing or incorrect setting can lead to a single server serving a 404 page while the rest work correctly. To prevent manual drift and ensure consistency, we use configuration automation.
A diagram showing two versions of shop.example.com — a red 404 error page and a green-bordered working storefront — with arrows pointing to a grid of 20 server tiles, one tile marked as problematic. The caption asks how to apply the required setup across all 20 servers.
Define the desired state and apply it With Ansible you describe the required setup once and apply it to any number of hosts. For the website example you need:
  • Apache installed
  • The correct apache2.conf file in place
  • Apache running
Ansible takes these instructions and enforces them on the selected servers.
A dark-themed diagram titled "Configuration Management" showing a "Required Setup" panel (Apache installed, settings file) feeding into Ansible. Arrows from Ansible point to a dashed group of numbered server nodes (01–20), each with an Apache icon.
How Ansible knows which servers to manage Ansible needs two primary inputs:
  1. Inventory — a list (or dynamic source) of hosts to manage.
  2. Playbook — a YAML file that describes the tasks to achieve the desired state.
Example inventory (INI-style):
Example playbook (install Apache, copy config, ensure service is running):
Modules and tasks Each playbook task calls a module — a focused unit that performs a specific action (package installation, file copy, service management, user creation, cloud operations, etc.). Use the appropriate module and provide the required parameters (for example, the package name). Core Ansible components How Ansible executes tasks on managed servers Ansible runs on a control node and connects to managed hosts (typically over SSH). It pushes modules to the remote host and executes them there. Ansible is agentless — no persistent agent is required on the managed hosts. Most standard modules expect Python to be present on the target systems.
Ansible is agentless — ensure SSH access and that Python (usually Python 3) is installed on managed hosts. For systems without Python, connection plugins and raw modules can help, but most standard modules assume Python is available.
Idempotency Ansible is idempotent: running the same playbook repeatedly results in no unnecessary changes if the target already matches the desired state. For example, if Apache is already running on 19 hosts and stopped on one, re-running the playbook will only start Apache on the affected host and leave the others untouched. Updating configuration and handlers When you update a configuration file, Ansible copies the new file only where it differs. If Apache needs a reload to apply the new configuration, use a handler and notify it from the task that changes the file. Handlers only run when a notifying task reports a change. Example task with notification and handler:
Handlers only run when a task reports changed. If a copy results in no difference, the handler will not be executed. Test changes in a safe environment before applying to production.
Running playbooks Ansible does not continuously watch hosts by default. Apply (or re-apply) desired state by running playbooks manually, via cron, or from a CI/CD pipeline:
Adding or removing servers To add a host, include it in your inventory and re-run the playbook so the new server receives the same configuration:
For dynamic or cloud environments, use a dynamic inventory script or cloud inventory plugins to discover and manage hosts automatically. Links and references

Watch Video