Tasks
Cheat sheet · https://pcornel.dk/topic.php?topic=5399
Answer
Ansible tasks are ordered action declarations that invoke modules or action plugins with arguments and controls such as conditionals, loops, delegation, retries, tags and error rules.
Remember
- Task listed ≠ task executed; tags, when clauses and host failure state can skip it.
- ok/changed ≠ service acceptance; module result describes the task contract only.
- Task name ≠ action identity; inspect module/action and arguments.
- Task executed for inventory host ≠ executed on that host when delegation/local actions apply.
First checks
ansible-playbook site.yml --list-tasks— tasks- Task names descriptive — logs
- register + assert for checks — validation
Verify in this order
task → module → result
Where it usually breaks
A task result proves the invoked action reported a state for a specific host/item/context; it does not automatically prove end-to-end workload success.
Inventory/vars → play/task selection → connection/become → module request → module result → target object read-back → handler/service effective state → workload verification.
Tasks Ansible boundary map
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Inputs / selection | Correct inventory, hosts, variables/facts and content are explicit | Wrong scope, stale facts, hidden precedence or content-version drift |
| Execution | Connection, privilege, module/task context and ordering match intent | Unreachable, wrong execution host, privilege/plugin failure or misleading skip/change state |
| Result semantics | Per-host/item results are preserved and interpreted correctly | Aggregate recap hides partial/skipped/handled failures |
| Target proof | Resource/workload read-back and rerun confirm convergence | Green Ansible status treated as end-to-end acceptance |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5399