Task Group

Hi all,

Is there a way to group tasks (below the level of a role)? Perhaps
with something with tags?

I would like to conditionally run or not run a group of tasks. That
would avoid the need to add a "when:" clause for each individual task.

Cheers,
Hilco

You can definitely group tasks within roles using any tags you want, and you can tag the roles themselves. The tags applied to the role will also apply to all tasks/handlers within that role as well.

How would that work then? I know how to limit a run to just a tag
(--tags "tag-1") on the command line but how would that work in a
playbook or a role? How do you "enable" a tag based on the results of
a previous task?

Lets say for example, you have a role which is tagged with “foo”, and some individual tasks within that role are tagged with “bar”.

If you run Ansible with --tags=foo, all tasks within that role would be executed. If you used --tags=bar instead, only those tasks within that role tagged as such would be run.

Regarding your second question, in combination to my response on your other post you can combine --tags with the --limit @retry.file, --step or --start-at-task options to further limit your executions.