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 }}
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.