Finally fixed, vars_files and with_items now 100% compatible

Devel branch update.

I've finally fixed with_items (better) such that there should be no
more confusion about not being able to use vars_files to conditionally
load host specific files, and use those later in with_items.

Essentially before with_items was a macro that created tasks. Now
it's not a macro anymore, what it does is just loop over many things
from inside the core "Runner" code, and then returns as if there was
only one module call.

The code needs cleanup from me yet, but it's pushed, and you should be
able to test away.

Easiest thing to do is, assuming a file
packages_by_hostname/$hostname.yml containing:

Someday I will get tired of whining for a page in the Ansible docs that focuses on all the ins and outs of variables, with examples, and will just create such a page. It will be lame, because my understanding of the subject is incomplete, but then someone who knows better will fix it up, and then (frabjous day) I will have what I want. Except by then I’ll have been forced to learn the answers already, so I will no longer need it. Sigh.

Seriously, though: I will make a point of carving out some time to do more than whining about this, and actually put together at least an outline I can post for feedback. In the meantime, though, I’d suggest that the pestering you’ve endured about variables is not just telling you that the functionality could be improved (though it’s awesome that you’ve done that) but also that there’s an opportunity for improved docs in that area.

Seriously, though: I will make a point of carving out some time to do more than whining about this, and actually put together at least an outline I can post for feedback. In the meantime, though, I'd suggest that the pestering you've endured about variables is not just telling you that the functionality could be improved (though it's awesome that you've done that) but also that there's an opportunity for improved docs in that area.

Don't think it's needed anymore, by making all the things people try more or less possible -- which I've done this weekend -- there is no need to document what may not be clear.

People skim docs, they don't read them totally. The goal here is to prevent the question from even being asked.

In this case, my question to you is, what still don't you think you know?

looks like this has broken the fetch code

seems to be passing in “$item” rather then the file name as src

eg

TASK: [fetch src=$item dest=/data/transit/configs] *********************
ok: [jabber.starground.co.uk] => {“changed”: false, “msg”: “missing remote file”}
ok: [zabbix.starground.co.uk] => {“changed”: false, “msg”: “missing remote file”}
ok: [office.starground.co.uk] => {“changed”: false, “msg”: “missing remote file”}

I'm assuming you mean fetch using with_items. Very likely as I don't think there's an example of that in examples/, nor a unit test.

Will take a look shortly, shouldn't be difficult.

Fixed pushed, had the multiball code one level too low in the stack, and also tweaked the unilateral phase detractors to improve the magneto reluctance.

Thanks, I’ll take a look in the morning. Very late here.

Also noticed “ssh.” is missing from ./lib/ansible/runner/connection/init.py

conn = ssh.SSHConnection(self.runner, host, port)

Also fixed, thanks

I tested this change and it seems to have broken something. Test playbook action:

  • name: Installing required package $item for the controller stack
    action: apt pkg=$item state=installed
    with_items:
  • nginx
  • php5-fpm
  • unzip
  • python-mysqldb

Previously this would show:

TASK: [Installing required package nginx for the controller stack] *********************
ok: [127.0.0.1]

TASK: [Installing required package php5-fpm for the controller stack] *********************
ok: [127.0.0.1]

TASK: [Installing required package unzip for the controller stack] *********************
ok: [127.0.0.1]

TASK: [Installing required package python-mysqldb for the controller stack] *********************
ok: [127.0.0.1]

Now the output is different and $item is not being substituted properly:

TASK: [Installing required package $item for the controller stack] *********************
ok: [127.0.0.1]
ok: [127.0.0.1]
ok: [127.0.0.1]
ok: [127.0.0.1]

Thanks

  • Mark

This part is actually 100% fine -- which is irrelevant to the parts I'm actually fixing ATM (mostly about inventory variables not getting passed down, about done)

Notice the 5 oks? The name of the task is not going to be substituted anymore, and it runs 5 commands, but only
makes 1 task. You didn't get any failures, so that's a good thing.

I noticed that happening, too (the with_items producing just a list of oks, rather than full output for the task iteration with $item replaced with the list item). I wasn’t sure if it was intentional or not, but it sounds from this comment like it was.

Maybe it’s just because I got used to the old behavior, but I felt like this output is a little less clear about what is actually going on. If there are benefits to the new behavior I’m sure I can get used to this style of output as well, but at least at the moment it feels like a small step backward to lose visibility into each individual item being explicitly iterated over.

I'm not against output upgrades, I'm just saying it's not at all busted. If you run with --verbose you can pretty easily tell what is going on.

patches would be considered.