I'm trying to automate the deployment of sensu checks to each role that a host plays.
I currently have a structure like
group_vars/
nginx
all
In each group_vars file, I have defined the following:
sensu_checks:
- check_name
- check_other_name
So for example, in group_vars/all I'd have:
sensu_checks:
- check_raid
- check_load
- check_disk
In group_vars/nginx I'd have:
sensu_checks:
- check_pid
- check_http
What I would like to know if it's possible would be to get all the checks that a specific host should install, for example with:
- name: Print host sensu checks
command: echo {{item}}
with_flattened:
- {{ sensu_checks }}
This doesn't work though, as it only gives me the group_vars of the last group the host name is defined in. Is there a way to get a flattened list the checks of all the groups the host is attached to?
In the previous example, I'd expect
[ check_load, check_disk, check_raid, check_http, check_pid ]
but instead I'm getting
[ check_http, check_pid ]
for an nginx host (which is part of both the 'all' and and 'nginx' groups)