Pcornel
Automation · Ansible

Tasks

Cheat sheet · https://pcornel.dk/topic.php?topic=5399

Back to the Topic

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

BoundaryHealthy evidenceSuspicious evidence
Inputs / selectionCorrect inventory, hosts, variables/facts and content are explicitWrong scope, stale facts, hidden precedence or content-version drift
ExecutionConnection, privilege, module/task context and ordering match intentUnreachable, wrong execution host, privilege/plugin failure or misleading skip/change state
Result semanticsPer-host/item results are preserved and interpreted correctlyAggregate recap hides partial/skipped/handled failures
Target proofResource/workload read-back and rerun confirm convergenceGreen 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

Confirmation

Confirm action

Continue?