Dear all,

I’m trying probably something very simple but can’t get it to work. I’m 
trying to exclude a group from a task. I have a playbook for all hosts 
(hosts: all) but in one particular task I want to exclude a group, how do I 
do that? 

I know I can do something like:

hosts: all:!ntpservers

but that also excludes the ntpserver from all the other tasks.

This is what I’m trying to do: 

I’m installing an ntp daemon on all systems but want to install the 
configuration ntpd.conf on all systems EXCEPT for the servers in the group 
“ntpservers”. I want to install a different configuration file on those 
servers because these will become the real ntp servers, the others will 
become clients.

I have this so far:

  #-------------------------------------------------------------------#

  #               
               NTP                                             #

  #-------------------------------------------------------------------#

  - name: Role:common - ensure ntpd is installed on all nodes

    yum: pkg=ntp state=installed

    tags: ntp

 

  - name: Role:common - be sure ntp is configured

    template: src=ntp.conf.j2 dest=/etc/ntp.conf

    notify:

      - Handlers:common - restart ntpd

    tags: ntp

 

  - name: Role:common - be sure ntpd is running and enabled

    service: name=ntpd state=running enabled=yes

    tags: ntp 


And I believe in the template part I have to exclude the group “ntpservers” 
so I can install a different configuration file via a separate playbook 
especially for the ntpservers (via roles).

Hope someone can help me out. 

Kind regards,

Oliver.

 

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to