In a playbook I would like to set a conditional variable for use in a template, e.g.
{% if is_master %}
…
{% endif %}
But if I follow the recipe at
http://ansible.cc/docs/playbooks2.html#conditional-execution
e.g.
vars:
is_master: “‘$ansible_hostname’ == ‘foo’”
Then I find that {{ is_master }} expands to the literal string ‘$ansible_hostname’ == ‘foo’
Can I get ansible to evaluate the condition before passing it to the template?
I’m using ansible 0.7.2 from the ubuntu 12.04 repos.
For now my workaround is to put the logic in the template:
{% if ansible_hostname == ‘foo’ %}
{% set is_master = true %}
{% endif %}
Thanks,
Brian.