Include + with_items AGAIN.

46 views
Skip to first unread message

Akos Vandra

unread,
Nov 4, 2014, 9:14:45 AM11/4/14
to ansible-project
Hello,

I know, I know... It's getting boring, but... I keep bumping into this a LOT.

I would like to bring back include + with_items again.

Consider having:

- one nginx role
- a few other roles, let's say it's a wordpress role for now.

I'd like the nginx role to create a few sites that are given to it with its parameters by default, but I would like the wordpress role to be able to create other nginx sites for its own use.

What I am doing right now is that I have a tasks file in the nginx role that will take in a template parameter and a site name, and it will create that site, and enable it by symlinking into sites-enabled.

BUT!
In the nginx role I cannot use this tasks file, since I would have to do an include + with_items, so I had to duplicate that functionality, and assign with_items to each and every one of the tasks described within.

What I would like to do is:

having a var like
  sites:
    - name: site1
      someparameter: 42
    - name: site2
      someparameter: 4242

To be able to call 
 - include: create_site
   with_items: sites

That would be the same as
 
- include: create_site name=site1 someparameter=42
- include: create_site name=site2 someparameter=4242

I know there are some problems with this, and it was deprecated due to confusion about how it worked.
Maybe it should be brought back under another name? Maybe there is another solution for problems like this? 

What is the ansible way of doing things such as this one?

Thanks,
  Akos

Michael DeHaan

unread,
Nov 4, 2014, 9:36:04 AM11/4/14
to ansible...@googlegroups.com
The 'v2/' tree refactoring may possibly allow this.

Please be patient.


--
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/CAHHcNodu6EEdkn-MZ1yM892Tax9XtJL9W2xQH%2Bi-QJ7obkiywQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages