title: Change variable in Ansible template based on group
body: <p>I've got an Ansible inventory file a bit like this:</p>
  
  <pre><code>[es-masters]
  host1.my-network.com
  
  [es-slaves]
  host2.my-network.com
  host3.my-network.com
  
  [es:children]
  es-masters
  es-slaves
  </code></pre>
  
  <p>I also have a Jinja2 template file that needs a certain value set to "true" if a host belongs to the "es-masters" group.</p>
  
  <p>I'm sure that there's a simple way of doing it but after some Googling and reading the documentation, I've drawn a blank.</p>
  
  <p>I'm looking for something simple and programmatic like this to go in the Jinja2 template:</p>
  
  <pre><code>{% if hostvars[host][group] == "es-masters" %}
  node_master=true
  {% else %}
  node_master=false
  {% endif %}
  </code></pre>
  
  <p>Any ideas?</p>