On 22.04.16 16:42 Pogan wrote:
> I forgot to mention that idea is to do this through host variable file, and
> not through playbook itself.
>
Set a variable called bar for this host foo in the host_vars/foo file
and only execute the task, when this variable is not set:
- hosts: mailservers
tasks:
- name: Check amavis service, and start if needed.
service: name=amavis state=started
when: hostvars[foo]['bar']|default('') is undefined
I'm not sure what exactly has to be inside the default, but using
default avoids errors when the variable bar is undefined...
Johannes