What is Ansible and what problems does it solve?
Learn what Ansible is, how its agentless YAML automation works, and the real problems it solves like configuration drift and manual server setup.
Expected Interview Answer
Ansible is an open-source automation tool that configures servers, deploys applications, and orchestrates IT tasks using simple, human-readable YAML files, without requiring any agent software on the managed machines.
It connects to remote hosts over SSH (or WinRM for Windows) and executes idempotent tasks defined in playbooks, so running the same playbook repeatedly produces the same end state. Ansible solves the problems of manual, error-prone server setup, configuration drift across fleets, and undocumented 'works on my machine' processes by turning infrastructure changes into version-controlled, repeatable code.
- Agentless — only needs SSH and Python on targets
- Idempotent tasks avoid duplicate or partial changes
- Human-readable YAML lowers the learning curve
- Eliminates configuration drift across many servers
- Infrastructure changes become version-controlled code
- Scales the same playbook from one host to thousands
AI Mentor Explanation
Ansible is like a captain who hands every fielder a written, identical instruction card before each over instead of shouting positions ball by ball. The card describes the desired final field placement, so no matter how many players or how often it is read, everyone ends up exactly where the plan says. Manual configuration is the chaotic shouting; Ansible is the calm, repeatable instruction card that guarantees the same fielding setup every single time.
Step-by-Step Explanation
Step 1
Define an inventory
List the managed hosts (by IP or hostname), optionally grouped, in an INI or YAML inventory file.
Step 2
Write a playbook
Describe the desired state as ordered tasks in YAML, each calling a module like apt, copy, or service.
Step 3
Connect agentlessly
Ansible SSHes into each host and pushes small Python modules to run the tasks, then removes them.
Step 4
Apply idempotently
Each task checks current state first and only changes what differs, so reruns are safe.
Step 5
Report results
Ansible summarizes ok, changed, and failed counts per host so you can verify the outcome.
What Interviewer Expects
- A clear definition of Ansible as agentless automation
- Understanding of idempotency and desired state
- Awareness that it uses SSH/WinRM and YAML
- The real problems it solves: drift, manual setup, repeatability
- Basic vocabulary: inventory, playbook, module, task
Common Mistakes
- Claiming Ansible requires an agent on every node
- Confusing Ansible with a programming language rather than declarative YAML
- Not mentioning idempotency when describing reruns
- Saying it only works for configuration and cannot deploy apps or orchestrate
Best Answer (HR Friendly)
“Ansible is a tool that automates setting up and managing servers using simple, readable files instead of manual commands. It solves the problem of teams configuring machines by hand, which is slow and inconsistent, by making every server match one repeatable, documented standard.”
Code Example
---
- name: Ensure web server is installed and running
hosts: webservers
become: true
tasks:
- name: Install nginx
ansible.builtin.apt:
name: nginx
state: present
update_cache: true
- name: Ensure nginx is started and enabled
ansible.builtin.service:
name: nginx
state: started
enabled: trueFollow-up Questions
- What does it mean for an Ansible task to be idempotent?
- How does an agentless architecture differ from Puppet or Chef?
- What is an inventory and how do you group hosts?
- How does Ansible connect to Windows hosts?
- What language are Ansible playbooks written in and why?
MCQ Practice
1. Which statement best describes Ansible's architecture?
Ansible is agentless; the control node connects to targets over SSH (or WinRM for Windows) and needs no permanent agent installed.
2. What format are Ansible playbooks written in?
Playbooks are written in YAML, chosen for its human-readable, declarative style.
3. Why does idempotency matter in Ansible?
Idempotent tasks only change what differs from the desired state, so repeated runs are safe and predictable.
Flash Cards
What is Ansible? — An agentless, open-source automation tool that configures servers and deploys apps using declarative YAML playbooks over SSH.
How does Ansible reach managed hosts? — Over SSH for Linux/Unix and WinRM for Windows — no permanent agent required, only Python on the target.
What problem does Ansible solve? — Manual, inconsistent server setup and configuration drift, by turning changes into repeatable, version-controlled code.
What is idempotency in Ansible? — A task only changes what differs from desired state, so running a playbook many times yields the same result.