block statements?

50 views
Skip to first unread message

Ian Denhardt

unread,
Oct 24, 2014, 6:16:23 PM10/24/14
to ansible...@googlegroups.com
Hey

Does ansible have a way of grouping multiple tasks into one (akin to a
block statement in many programming languages)? I've several tasks that
I want to (a) apply some common options to, such as sudo: yes, and (b)
do in a loop (with_items). I could put these in a separate role, but
that seems very heavyweight, and in my case I'm already inside of a role
that I'd like to be self-contained. I haven't been able to find anything
that lets me do this -- I tried hacking around it by putting an include
statement as the task, but got an error saying that using that with
with_items had been removed after being deprecated. That's more than
reasonable -- it's pretty ugly -- but I can't find a better way to do
this.

Thoughts?

-Ian

signature.asc

Brian Coca

unread,
Oct 24, 2014, 6:54:30 PM10/24/14
to ansible...@googlegroups.com
you can already do some of this, with variables and tags, with include
and role directives. But currently there is only one true block of
tasks and that is a play.

there is some work in ansible to create the block concept/object for
tasks but it is in early stages.
--
Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

James Cammarata

unread,
Oct 25, 2014, 7:51:42 AM10/25/14
to ansible...@googlegroups.com
Hi Ian,

This is actually a feature we are currently working on, specifically as part of our "v2" refactoring Michael mentioned in another thread on this group. This will most likely be available in version 1.9 in the future, but for now using roles and include statements with tags is the best way to group related tasks.

Thanks!

--
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/CADn%2BHsy6WQv8ix0rBMPrOxWm5hx%3D%3DuYovrdtFGsn-_haUCH0ig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages