Include + with_items AGAIN.

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

The ‘v2/’ tree refactoring may possibly allow this.

Please be patient.