Given this playbook and inventory:
+$ cat hostvars.yml
---
- hosts: all
tasks: [ ]
- hosts: localhost
user: ansible
sudo: true
tasks:
- debug: msg={{ item.key }}
with_dict: hostvars
+$ cat hosts.ini
[tests]
673086-ialutil1
703165-ialprdproxy1
Ansible 1.7.2 gives this result:
+$ ap -t hostvars.yml -i ~/ansible/hosts.ini | grep msg
TASK: [debug msg={{ item.key }}]
**********************************************
"msg": "703165-ialprdproxy1"
"msg": "localhost"
"msg": "673086-ialutil1"
That is, the items in the dict are all hosts.
Ansible 1.9.3-1 gives this result:
+$ ap -t hostvars.yml -i ~/ansible/hosts.ini | grep msg
TASK: [debug msg={{ item.key }}]
**********************************************
"msg": "703165-ialprdproxy1"
"msg": "inventory_hostname"
"msg": "ansible_connection"
"msg": "groups"
"msg": "inventory_hostname_short"
"msg": "group_names"
"msg": "ansible_python_interpreter"
"msg": "localhost"
"msg": "673086-ialutil1"
Now there are a bunch of items in the dict that aren't hosts.
Is that expected? It bit us because we have a task that uses
'with_dict: hostvars' to do stuff with a couple of hostvars values for
each host, and that breaks if there are things in hostvars that aren't
hosts (e.g. there is no item.value.ansible_default_ipv4.address).
-Josh (
j...@care.com)
This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.