40 lines
1.1 KiB
YAML
40 lines
1.1 KiB
YAML
- name: Gather installed package facts
|
|
package_facts:
|
|
manager: auto
|
|
|
|
# , nrpe, nagios-nrpe-plugin
|
|
- name: Check OS
|
|
debug:
|
|
msg: "{{ ansible_facts['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: nagios-nrpe-plugin
|
|
state: present
|
|
become: yes
|
|
register: nrpe_install_result
|
|
when: "{{ ansible_facts['os_family'] == 'Debian' }} and ('nagios-nrpe-plugin' not in ansible_facts.packages) "
|
|
|
|
- name: Ensure NRPE is installed (RedHat/CentOS)
|
|
yum:
|
|
name: nagios-plugins-nrpe.x86_64
|
|
state: present
|
|
become: yes
|
|
register: nrpe_install_result
|
|
when: "{{ ansible_facts['os_family'] == 'RedHat' }} and ('nagios-plugins-nrpe.x86_64 ' 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 |