Immediately restart the nrpe service after a configuration change.

This commit is contained in:
Andrea Dell'Amico 2019-06-27 18:36:36 +02:00
parent 63d95a54b3
commit 4ee9627f56
1 changed files with 9 additions and 0 deletions

View File

@ -33,19 +33,28 @@
- name: Install the global nrpe commands file
template: src=common-nrpe.cfg.j2 dest=/etc/nagios/nrpe.d/common.cfg owner=root group=root mode=444
notify: Restart NRPE server
register: nrpe_restart
tags: [ 'nagios', 'nrpe', 'nrpe_cfg' ]
- name: set the NRPE ACL
action: |
lineinfile name=/etc/nagios/nrpe.cfg regexp="allowed_hosts=" line="allowed_hosts=127.0.0.1,{% for ip in nagios_monitoring_server_ip %}{{ ip }}{%if not loop.last %},{% endif %}{% endfor %}"
notify: Reload NRPE server
register: nrpe_restart
tags: [ 'nagios', 'nrpe', 'nrpe_cfg' ]
- name: set the NRPE default timeout
lineinfile: name=/etc/nagios/nrpe.cfg regexp="command_timeout=" line="command_timeout={{ nrpe_command_timeout }}"
notify: Reload NRPE server
register: nrpe_restart
tags: [ 'nagios', 'nrpe', 'nrpe_cfg' ]
- name: Restart NRPE server
service: name=nagios-nrpe-server state=restarted
when:
- nrpe_restart is defined
- nrpe_restart is changed
- name: nagios needs root to execute some commands. We do it via sudo
template: src=nagios.sudoers.j2 dest=/etc/sudoers.d/nagios owner=root group=root mode=0440
tags: [ 'nagios', 'nrpe', 'sudo' ]