For those of you who are working with #Ansible… Ansible 2.5 is out, and has an unusual documentation change around a key Ansible concept – `with_` loops Where you previously had:
with_dict: "{{ your_fact }}"
or
with_subelements:
- "{{ your_fact }}"
- some_subkey
This now should be written like this:
loop: "{{ lookup('dict', your_fact) }}"
and
loop: "{{ lookup('subelements', your_fact, 'some_subkey') }}"
Fear not, I hear you say, It’s fine, of course the documentation suggests that this is “how it’s always been”…… HA HA HA Nope. This behaviour is new as of 2.5, and needs ansible to be updated to the latest version. As far as I can tell, there’s no way to indicate to Ansible “Oh, BTW, this needs to be running on 2.5 or later”… so I wrote a role that does that for you.
ansible-galaxy install JonTheNiceGuy.version-check
You’re welcome :)
More useful URLs:
- “Complex Loops” – 2.5’s way of saying “We didn’t like the old way that wasn’t just with_items”. (http://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#complex-loops)
- “Lookup Plugins” – what used to be two or three items is now a fleet! (http://docs.ansible.com/ansible/latest/plugins/lookup.html)
- “Loops” – what this page looked like in 2.4! (http://docs.ansible.com/ansible/2.4/playbooks_loops.html)