`play` module to group related tasks

42 views
Skip to first unread message

Grzegorz Nosek

unread,
Jan 27, 2015, 1:07:06 PM1/27/15
to ansible...@googlegroups.com
Hi,

I just wrote a module that allows for DRYer playbooks, without repeating sudo/when/with_items etc. over and over again in a play (or making lots of small included files).

It's on github: https://github.com/gnosek/ansible-play and comes with a couple examples, so I'll just mention it allows an include/with_items combination, runtime-evaluated includes and other funny things :)

Comments, patches, flames appreciated.

Also, I'd love to see some version of this upstream, even though it does work around the API in a rather crude way and would benefit greatly from some minor changes in Ansible core.

Best regards,
 Grzegorz Nosek

James Cammarata

unread,
Jan 27, 2015, 3:05:39 PM1/27/15
to ansible...@googlegroups.com
Hi Grzegorz, 

You might want to look at the v2 work going on, which will implement some of the features you've noted above (include + with_items and runtime evaluated includes, at least at the task level).

Also, another feature we're working on in v2 is the concept of "blocks", which will essentially allow better grouping (and error handling) for tasks. An example of a block is:

  begin:
    - name: task 1
      ...
    - name: task 2
      ...
  rescue:
    - name: rescue task 1 (runs when any task in the main block fails)
      ...
  end:
    - name: some cleanup task that is always run
      ...

Blocks already support tags/when statements, but do not currently support many of the other task-level options like sudo/sudo_user. If we want to, they could be extended to include those as well without too much effort I think, if that's something users are interested in. We're using the ruby-ish syntax here due to internal variable names, but we have talked about switching this back to the more pythonic try/except/finally syntax.

I plan on using my speaking slot for AnsibleFest London next week to run over the new features in V2, so stay tuned for a slide deck to see what else is going on in the new codebase (or even better, buy tickets!).

Sorry this degenerated into a "hey, look at v2!" response, but I really do think it does (or will) fit what you're trying to accomplish here, and we're getting very close to opening up contributions there as it's nearing critical mass on feature support.

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/d45e953a-58a6-4431-836b-5cdf58af5721%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Grzegorz Nosek

unread,
Jan 27, 2015, 4:34:04 PM1/27/15
to ansible...@googlegroups.com
Hi,

I'm happy v2 will include equivalent features in the core (please add sudo/sudo_user/remote_user while you're at it). I acknowledge this module is a hack and would be better handled internally, but it does allow for less repetition in playbooks and solves a pain point of mine.

Is v2 usable to any degree? Are the new features/changes documented somewhere? Unfortunately I won't attend AnsibleFest but I'm looking forward to your slides/video.

Thanks,
 Grzegorz Nosek

James Cammarata

unread,
Jan 27, 2015, 8:32:41 PM1/27/15
to ansible...@googlegroups.com
Yes V2 is usable to a degree - it's passing about 75% of the integration tests we have but it's definitely not finished. You can use it very simply by sourcing v2/hacking/env-setup, just as you would with a regular git checkout of the code.

If you try it out and hit a bug, let us know here on the mailing list first before opening a GitHub issue, as we're still tracking things internally and may know about it already.

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.
Reply all
Reply to author
Forward
0 new messages