Notify is used in Ansible to have some conditionals in the playbooks (in the end to restart services)

Here is an example

---

- hosts: web
  tasks:
  - name: install the epel repo
    yum: name=http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm state=installed
  - name: install the latest version of nrpe
    yum: name=nagios-nrpe state=latest
  - name: install the latest version of nagios-common
    yum: name=nagios-common state=latest
  - name: install the latest version of nagios-plugins
    yum: name=nagios-plugins state=latest
  - name: install the latest version of nagios-plugins-all
    yum: name=nagios-plugins-all state=latest
  - name: config nrpe
    lineinfile: dest=/etc/nagios/nrpe.cfg regexp=^allowed_hosts=.*$ line=allowed_hosts=xx.xx.xx.xx
    notify:
      -  restart nrpe

  handlers:
  - name: restart nrpe
    service: name=nrpe state=restarted
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s