Level 3 · Extending Ansible¶
Level 3 goes beyond using Ansible to extending and operating it: writing modules and plugins, building inventories from live sources, handling the awkward corners of command and shell, running long tasks, measuring performance, orchestrating rolling updates safely, and reasoning about state, drift and convergence.
What was run, and what wasn't
ansible-core 2.21.5 on a Mac, local connections only. Measured here: two custom modules (25 tests), three filters, a lookup and two forms of dynamic inventory (23 tests), command/shell pitfalls, async behaviour and messages, forks and fact-gathering timings on 20 local hosts, a rolling update over eight simulated servers (11 tests), and orphan/conflict/drift experiments. Not run: SSH and real network latency, pipelining, Windows and network devices (their collections were installed only to read documentation), Molecule, real cloud inventories, and Ansible's own ansible-test.
Prerequisites: Levels 1 and 2.
Modules¶
- Writing a Custom Module: argument spec, check and diff modes, a pure core, 25 tests.
- Filter and Lookup Plugins: and the comma-join surprise of
lookup(). - Dynamic Inventory: a script and a plugin producing identical inventories.
- Command and Shell Without Breaking Idempotency: injection, pipefail,
argv,creates. - Async Tasks and Polling: and the confusing message when a job outlives
async. - Performance: forks from 50 s to 4.5 s, and what fact gathering costs.
- Rolling Updates and Failure Budgets: and an
always:section that defeatedmax_fail_percentage. - State, Drift and Convergence: orphans, flip-flopping tasks, purge patterns.
- Network and Windows Targets: connection types and collections, read offline.
- Project: A Tested Custom Module: the capstone for the level.
After Level 3¶
Level 4 is operations: controllers and execution environments, Ansible in CI/CD, secrets at scale, pull mode, Terraform together with Ansible, a drift auditor built on check mode, automation incidents, migrating scripts and anti-patterns, governance, and a capstone managing a simulated fleet.