Thanks a lot, Michael! I haven't thought of "when" at all. I'll use this.
On Tuesday, March 18, 2014 5:45:20 PM UTC+1, Michael DeHaan wrote: > > We generally dislike to see logic coded in Jinja2, but that will indeed > function. > > I'd be tempted to do this, personally, to remove the Jinja2 logic: > > - set_fact: jboss_host_type=slave > > - set_fact: jboss_host_type=master > when: jboss_master_host == inventory_hostname > > > On Tue, Mar 18, 2014 at 12:32 PM, Jakub Holy <[email protected]<javascript:> > > wrote: > >> Hello! >> >> I have the following group var in group_vars/staging: >> >> jboss_master_host: barad-dur.example.com >> >> And I need to set, for each host in a play, its jboss_host_type = master >> | slave based on that variable - the jboss_host_type is used in multiple >> places in templates. >> >> I have found the following solution, adding this to my tasks: >> >> - name: Set jboss_host_type var >> set_fact: jboss_host_type={{ 'master' if jboss_master_host == >> inventory_hostname else 'slave' }} >> >> The question is, is this the right way to do it? Is there a better way? >> >> Thank you! >> >> PS: Ansible 1.5.3 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected]<javascript:> >> . >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/19f18258-213d-4117-a886-7096714d2ea3%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/19f18258-213d-4117-a886-7096714d2ea3%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a74f0db9-b164-4e03-b5b8-f83a74d538e3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
