I'm getting the following error:
ERROR: failed to combine variables, expected dicts but got a 'dict' and a
'str'
with the following setup:
# ./site.yaml
---
- hosts: all
connection: local
gather_facts: no
vars:
xxx:
aaa: 1
roles:
- role1
# ./roles/role1/vars/main.yaml
---
xxx: "{{ my_xxx }}"
# ./roles/role1/defaults/main.yaml
---
my_xxx:
bbb: 2
# ./roles/role1/tasks/main.yaml
---
- debug:
msg: xxx={{ xxx }}
# ./hosts
localhost
There is no error if there is no vars definition in the site.yaml (no
hashes to be 'combined'). The problem is that the value of xxx coming from
the role is still Jinja2 template string ("{{ my_xxx }}" - which is in fact
a string, not a hash) when the merge happens. Interesting is that if I turn
the hash ("bbb: 2", "aaa: 1") to a list ("- bbb: 2", "- aaa: 1") all works
as expected.
The question is why it's even trying to merge the two variables? I would
expect the variable to be replaced and not merged as per default setting
hash_behaviour=replace in ansible.cfg.
Any comments which will help me to understand this behavior are more than
appreciated.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/e6a4300e-bc0b-42f6-9860-415442066f49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.