Hey People,
Having some trouble using YAML dictionaries.
I'm refactoring my variable structure in a role a wrote a while ago.
The variables used to all look like: sensu_api_host, but I wanted to move to using dictionaries, so when referencing them it wouldn't be:
{{ sensu_api_host }}
it'd be:
{{ sensu['api']['host'] }}
In doing so, I've restructured my roles' defaults/main.yml like so:
sensu:
api:
host: "{{ groups['sensu_masters'][0] }}"
port: 4567
ssl: "false"
user_name: admin
password: secret
uchiwa_path: ''
timeout: 5000
client_config: client.json.j2
config_path: /opt/local/etc/sensu
gem_state: present
plugin_gem_state: present
user_name: sensu
group_name: sensu
include_plugins: true
include_dashboard: false
master: false
Though, I have a problem. Lookups for the above variables work fine... until I try to assign them values elsewhere, where it should take precedence.
Some of the key values above are clobbered when they are defined elsewhere, such as host_vars/hostname.yml or group_vars/groupname.yml.
It seems that if I want to define one of the nested keys' value elsewhere, it ruins the dictionary lookup for all other child keys who share that parent.
For example, above you can see that sensu['include_dashboard'] is set to false.
If I want to set this to `true` for a particular host, in host_vars/hostname.yml like so: