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.
EXCEPT for the servers in the group “ntpservers”.
where can i find all these kind of parameters?
--
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 ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Michael,
I believe you are right it's much easier to start a new play and that was also the first solution i found. Because I’m just a newbie to ansible i tried to keep things consistent and place everything which is default on a server (host file, resolve.conf , ntp.conf etc) into a playbook "common" and the applications in their own playbook. Problem was that i wanted to run both a ntp server as a ntp client. Right now everything works perfectly but i will consider your approach when i go along and everything start to become too complicated.
By the way, till now i really like ansible.
Thanks,
Kind regards.