Task Group

30 views
Skip to first unread message

Hilco Wijbenga

unread,
Sep 17, 2014, 11:40:56 AM9/17/14
to Ansible Project
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

James Cammarata

unread,
Sep 17, 2014, 1:23:57 PM9/17/14
to ansible...@googlegroups.com
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.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAE1pOi2gA-_%2B1zNwtVL%2BE5usKHLqE1_Q2VvQsF_Rc10y17gCfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Hilco Wijbenga

unread,
Sep 17, 2014, 1:30:16 PM9/17/14
to Ansible Project
On 17 September 2014 10:23, James Cammarata <jcamm...@ansible.com> wrote:
> 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?

James Cammarata

unread,
Sep 17, 2014, 1:39:09 PM9/17/14
to ansible...@googlegroups.com
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.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages