Ansible include_vars: Including dictionary variables from a file
"Doesn't work" is a very vague description of your problem, but this is not a valid task definition:
- name: Dict test
include_vars: test1.yml
debug:
msg: "User {{ item.key }} is {{ item.value.name }} ({{ item.value.telephone }})"
loop: "{{ lookup('dict', users) }}"
include_vars
and debug
are individual actions so they need to be separate tasks; as you have it this should give you the helpful error ERROR! conflicting action statements: include_vars, debug
- include_vars: test1.yml
- name: Dict test
debug:
msg: "User {{ item.key }} is {{ item.value.name }} ({{ item.value.telephone }})"
loop: "{{ users | dict2items }}"