Welcome to Ansible: what you will learn and the big picture
What you will learn in this module. This is your first step into network automation with Ansible, and you do not need any earlier experience. By the end you will have built a working control node, described three real devices in an inventory, talked to them with ad-hoc commands, written a playbook, dry-run it, applied it, and proved that running it again changes nothing. You will also learn the short list of errors every beginner meets and how to read them.
- What Ansible is, what "agentless" means, and why network engineers use it.
- The control node,
ansible-core, collections and fully qualified module names. - An inventory with groups and the variables that tell Ansible how to log in.
ansible.cfgand the SSH host key question.- Ad-hoc commands:
ping,ios_command,ios_facts,ios_config. - YAML and your first playbook, line by line, with
--check,--diffand idempotency.
Prerequisites. You should be able to type basic Linux commands (cd, ls, cat) and know what an SSH login and an ntp server line on a router are. You do not need Python, YAML or any Ansible knowledge. Everything is explained from zero.
Analogy: a tireless assistant with a checklist
Imagine you must add the same NTP server to fifty routers tonight. By hand you would open fifty SSH sessions, type the same line fifty times and hope you never mistype. Now imagine a tireless assistant who reads your checklist, logs in to each router exactly as you would, types the commands, and reports "done" or "already there" for every device. That assistant is Ansible. You write the checklist (a playbook) and the list of devices (an inventory); Ansible does the typing.
Ansible runs on one Linux box and logs in to every device over SSH, the same way you do.
The words you will meet
- Control node
- The Linux machine where Ansible is installed and where you run commands. In our lab it is AUTO01.
- Managed node
- Any device Ansible manages: here two routers and a switch.
- Agentless
- Nothing is installed on the managed node. Ansible only needs the SSH login that you already use.
- Inventory
- A file that lists the devices and how to reach them.
- Module
- A ready-made worker for one job, for example
cisco.ios.ios_configsends configuration lines. - Task, play, playbook
- A task calls one module. A play says which hosts run a list of tasks. A playbook is a file holding one or more plays.
- Idempotent
- Running the same playbook twice gives the same end state, and the second run changes nothing.
Worked example. The Network Kings lab has R1 in Pune (10.99.0.1), R2 in Bengaluru (10.99.0.2) and the access switch SW1 (10.99.0.10). Adding ntp server 10.99.0.60 by hand means three logins. With Ansible it is one command: ansible-playbook ntp.yml. With three devices the saving is small; with three hundred it is the difference between a night and a minute.
Why network engineers like Ansible
- No agent, no daemon: routers and switches cannot run agents anyway. Ansible uses SSH and the normal CLI.
- Readable: a playbook is plain YAML text that a colleague can review like a change ticket.
- Safe by design: you can dry-run, you can limit a run to one device, and good modules only send what is missing.
- One tool, many vendors: the same ideas work for Cisco IOS, Junos, NX-OS and Linux servers.
Common beginner mistake. Thinking Ansible must be installed on the routers, or that it "pushes a program" to them. It does not. If you can SSH to a device from the control node, Ansible can manage it. Another trap: running a playbook against all devices on day one. You will learn to limit and dry-run first.
Exam trap. Interviewers ask "is Ansible agent-based?" The answer is no: it is agentless and push-based over SSH (or an API). The control node must be Linux or macOS; Windows is not supported as a control node.
The 2 AM NTP change
A bank branch network of forty routers had a retired NTP server. The engineer on call logged in to each router by hand. By router 28 he mistyped an IP address, and logs on that router were stamped with the wrong time for a week. The team later wrote a playbook with one NTP variable. The next time the server changed, one edit and one run updated all forty devices and the recap showed which ones were already correct.
Lesson: automation is not about speed alone; it removes typing mistakes and gives you a record of what changed.
"What is Ansible and why is it agentless?"
Ansible is an open-source automation tool. You describe the desired state in YAML playbooks and an inventory; the control node connects over SSH (or an API), runs modules, and reports ok, changed or failed per device. It is agentless because network devices cannot host an agent, so it reuses the management access you already have. Mention idempotency and the inventory/playbook split to show you understand the model.
Key takeaways
- Ansible runs on a Linux control node and manages devices over SSH with nothing installed on them.
- The inventory says which devices; the playbook says what to do.
- A module does one job; a task calls a module; a play targets hosts; a playbook holds plays.
- Idempotent means a second run changes nothing.
- Our lab: AUTO01 manages R1, R2 and SW1 on 10.99.0.0/24.