Prevent playbook execution without tags
If you have a playbook or a role with extensive tags usage (e.g. install
/update
/uninstall
) and want to prevent its execution without tags (in which case every task will be executed), you can add untagged task as the first one in your plays like follows:
- name: Prevent run without tags
fail: msg="You must run this playbook with tags!"
It will fire if no tag is specified during execution, but will be skipped if any tag is given (because this task is not tagged at all).