Our integration gateways are eleven Linux servers holding the client certificates our carriers issue us. A role called partner_certs puts them in place, and its tasks are tagged certs, so when a carrier sends a renewal we can push just that with ansible-playbook site.yml --tags certs. That takes two minutes. The whole playbook takes forty.
In August we changed site.yml to load roles with include_role instead of the roles list, so each gateway could pick its roles from inventory in a loop. A full run behaved exactly as before, which is how we tested it.
In October a carrier certificate was due to expire at midnight. The new one arrived at four in the afternoon. An engineer ran the playbook with --tags certs and it finished green in under a minute: fact gathering ok, nothing changed, nothing failed. He assumed an earlier run had already put the files in place. At midnight every label request to that carrier started failing its TLS handshake.
Tags work differently for imports and includes. import_role is static: Ansible reads the role's tasks while it parses the playbook, so tags on those tasks are visible to --tags. include_role is dynamic: the role is loaded only when the include task itself runs, and under a tag filter that include is just another task that has to match. Ours had no tags. Ansible skipped it, never opened the role, and never saw a single task tagged certs. Tasks skipped by a tag filter are not even listed in the output, so the run looked like one with nothing to do.
We copied the certificate by hand at twenty past twelve. Each include task now carries its role's tags and passes them inward with apply, so the tasks inside inherit them. The wrapper we use for tagged runs counts the tasks that actually executed and fails if a tag selected none, because a targeted run that touched nothing is never what anybody meant.
A tag filter only looks at the tasks it can see. After the change, it could no longer see inside our roles.
– Sergey Shinder
Top comments (0)