- name: Gather installed package facts package_facts: manager: auto # nagios-plugins-nrpe.x86_64 , nrpe, nagios-nrpe-plugin - name: Check OS debug: msg: "{{ ansible_fact['os_family'] }} is the OS" - name: Check if nagios NRPE is installed debug: msg: "NRPE is installed." when: "'nrpe' in ansible_facts.packages" - name: Ensure NRPE is installed (Debian/Ubuntu) apt: name: nrpe state: present become: yes register: nrpe_install_result when: "'nrpe' not in ansible_facts.packages" - name: Deploy custom Nagios/NRPE script ansible.builtin.copy: src: memory_usage_check.py dest: /usr/local/nagios/libexec/my_custom_check.py mode: '0755' when: nrpe_install_result is defined and nrpe_install_result.changed