Hi all,
The ansible docs, here, claim that you can assign a variable to a host inline in a playbook. Then, here, it says you can use “when” paired with a variable to run certain roles on certain hosts. Why then, does this not work?
`
Hi all,
The ansible docs, here, claim that you can assign a variable to a host inline in a playbook. Then, here, it says you can use “when” paired with a variable to run certain roles on certain hosts. Why then, does this not work?
`
you are missing a colon:
- { role: syslog-client, when: type == "syslog" }
fyi, setting the var that way sets it always for all hosts, so that
when statement is always true.
Hey Brian, thanks for the prompt reply.
Ok, so the colon got that running. So, what I actually mean to do with this playbook is the opposite, run the second play on all servers EXCEPT the one from the first play. What is the ansible equivalent of the boolean “not”? I’ve tried both when: type =! “syslog” and when: type not “syslog” and neither works. How would I implement this?
Thanks again!
!= , also note that 'type' will NOT be visible in the 2nd play as you
defined it as a play level variable, you want to use set_fact in this
case.
Of course its !=. My brain is not working today. I need a vacation…
Thanks for the tip on set_fact, I’ll look into it a bit more.
Thanks again for all the help!