---
- name: Setup various nrpe checks
  hosts: all

  tasks:

  - name: Update nrpe checks configuration to Redhat-like hosts.
    include_tasks: monitoring_setup_nrpe_checks.yaml
    loop:
    - {plugin_path: "/usr/lib64/nagios/plugins"}
    when: ansible_os_family == 'RedHat'
  
  - name: Update nrpe checks configuration to Debian-like and Suse hosts.
    include_tasks: monitoring_setup_nrpe_checks.yaml
    loop:
    - {plugin_path: "/usr/lib/nagios/plugins"}
    when: ansible_os_family == 'Debian' or ansible_os_family == 'Suse'


  handlers:

  - name: restart nrpe RS
    systemd:
      name: nrpe
      state: restarted

  - name: restart nrpe D
    systemd:
      name: nagios-nrpe-server
      state: restarted