Does anyone know why handlers get executed on ALL members of a group when only one member met the conditional??? See below...
When I execute our top level playbook site.yml on a group that contains multiple hosts...even though only one host results in a "changed" status for the task...the handlers get executed on ALL members of the group
members of our_group:
top level playbook site.yml:
---
- name: PLAY 1 - Apply common roles to Inventory Group
hosts: our_hosts
serial: 10
roles:
- { role: dnsclient }
- { role: autofs }
- { role: local_users }
- { role: nis_client } << --- This is the role in which the handler is called
nis_client role task with handler:
- name: Create /etc/yp.conf from template and Restart ypbind
template: src=yp.conf.j2 dest=/etc/yp.conf owner=root group=root mode=0644
notify:
- stop ypbind
- start ypbind
- restart autofs
tags:
- provision
- config
- nis_client
nis_client role handlers main.yml:
---
- name: stop ypbind
command: service ypbind stop
- name: start ypbind
command: service ypbind start
- name: restart autofs
service: name=autofs state=restarted
result of run:
TASK: [nis_client | Create /etc/nsswitch.conf from template] ******************
TASK: [nis_client | Create /etc/sysconfig/ypbind from template] ***************
TASK: [nis_client | Ensure that rpcbind is started] ***************************
TASK: [nis_client | Create /etc/yp.conf from template and Restart ypbind] *****
NOTIFIED: [nis_client | stop ypbind] ******************************************
NOTIFIED: [nis_client | start ypbind] *****************************************
NOTIFIED: [nis_client | restart autofs] ***************************************
PLAY RECAP ********************************************************************
Finished: SUCCESS