Create exception for service on a host

Hi,

I guess this is fairly simple question, but I’m stuck with it…
I have a playbook that checks whether services are up on hosts and starts them if they are not in started state, for example:

  • hosts: mailservers

tasks:

  • name: Check amavis service, and start if needed.
    service: name=amavis state=started

What if i wanted to leave service in stopped state only on one of the hosts in “mailservers” group while performing this playbook? How can I achieve that?

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