Pcornel
Automation · Ansible

Tags

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

Back to the Topic

Answer

Ansible tags select subsets of tasks, roles or plays at invocation time, changing execution coverage without changing the underlying content file.

Remember

  • Playbook file unchanged ≠ execution path unchanged; tag selection can omit dependencies.
  • Tagged task selected ≠ prerequisites selected automatically in every design.
  • Skip-tag success ≠ safe partial run; omitted tasks may be required for consistency.
  • Task has tag ≠ task always runs with that tag due to includes/inheritance nuances.

First checks

  • ansible-playbook site.yml --list-tags — tags
  • ansible-playbook site.yml --tags config --check — run subset
  • never/always special tags — behaviour

Verify in this order

tags → selected tasks

Where it usually breaks

Tag filtering proves which content Ansible selected; it does not prove the resulting partial task graph is sufficient for a consistent target state.

Inventory/vars → play/task selection → connection/become → module request → module result → target object read-back → handler/service effective state → workload verification.

Tags 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=5410

Confirmation

Confirm action

Continue?