Ansible group_vars -
i'm trying automate deployment of sensu checks each role host plays.
i have structure
group_vars/ nginx
in each group_vars file, have defined following:
sensu_checks: - check_name - check_other_name
so 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 know if it's possible checks specific host should install, example with:
- name: print host sensu checks command: echo {{item}} with_flattened: - {{ sensu_checks }}
this doesn't work though, gives me group_vars of last group host name defined in. there way flattened list checks of groups host attached to?
in 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 nginx host (which part of both 'all' , and 'nginx' groups)
with_flattened
doesn't expect in case - you're victim of variable scoping.
the nginx
group specific, ansible using variable definition - explains why you're getting sensu_check
defined in nginx
.
you rename var in 1 of 2 places (i recommend nginx var, since that's specific one), , use with_flattened
combine 2 lists:
with_flattened: - {{ sensu_checks }} - {{ sensu_nginx_checks }}
Comments
Post a Comment