Change variable in Ansible template based on group with kids?

I found Change variable in Ansible template based on group . However, how to extend the response in groups with children?

If I extend the group vars file from the link above to

[host0] host0.my-network.com [host1] host1.my-network.com [es-masters:children] host0 host1 

How can I extend the above answer (see below) so that it works with the vars group file above? Simple FQDN replenishment in jinja2 instruction does not work.

 {% if ansible_fqdn in groups['es-masters'] %} node_master=true {% else %} node_master=false {% endif %} 
0
jinja2 ansible
source share
1 answer

What you need to do:
Provide default value in template

 # role_name/templates/template.j2 node_master={{ role_name_node_master | default(true) }} 

How to override in group_vars

 # group_vars/es-masters.yml role_name_node_master: false 
0
source share

All Articles