ansible-roles/nagios-nrpe/tasks/main.yml

97 lines
2.4 KiB
YAML

---
- name:
ansible.builtin.set_fact:
nagios_nrpe_processes: "{{ ansible_distribution_major_version is version('12', '<') | ternary(nagios_nrpe_processes_default_before_debian_12, nagios_nrpe_processes_default) }}"
when: nagios_nrpe_processes == None or nagios_nrpe_processes | length <= 0
- name: base nrpe & plugins packages are installed
ansible.builtin.apt:
name:
- nagios-nrpe-server
- monitoring-plugins
- monitoring-plugins-basic
- monitoring-plugins-common
- monitoring-plugins-standard
- nagios-plugins-contrib
state: present
tags:
- nagios-nrpe
- name: custom plugin dependencies packages are installed
ansible.builtin.apt:
name:
- libfcgi-client-perl
- ruby-crack
state: present
when:
- ansible_distribution == "Debian"
- ansible_distribution_major_version is version('10', '>=')
tags:
- nagios-plugins
- name: custom configuration is present
ansible.builtin.template:
src: evolix.cfg.j2
dest: /etc/nagios/nrpe.d/evolix.cfg
group: nagios
mode: "0640"
force: false
notify: restart nagios-nrpe-server
tags:
- nagios-nrpe
- name: update allowed_hosts lists
ansible.builtin.lineinfile:
dest: /etc/nagios/nrpe.d/evolix.cfg
line: "allowed_hosts={{ nagios_nrpe_allowed_hosts | join(',') }}"
regexp: '^allowed_hosts='
insertafter: '# Allowed IPs'
notify: restart nagios-nrpe-server
when: nagios_nrpe_force_update_allowed_hosts | bool
tags:
- nagios-nrpe
- name: Nagios config is secured
ansible.builtin.file:
dest: /etc/nagios/
mode: "0750"
group: nagios
state: directory
notify: restart nagios-nrpe-server
tags:
- nagios-nrpe
- ansible.builtin.include_role:
name: evolix/remount-usr
when: nagios_plugins_directory is search("/usr")
tags:
- nagios-nrpe
- nagios-plugins
- name: Nagios plugins are installed
ansible.builtin.copy:
src: plugins/
dest: "{{ nagios_plugins_directory }}/"
mode: "0755"
notify: restart nagios-nrpe-server
tags:
- nagios-nrpe
- nagios-plugins
- name: Nagios lib is secured
ansible.builtin.file:
dest: /usr/local/lib/nagios/
mode: "0755"
group: nagios
recurse: yes
state: directory
notify: restart nagios-nrpe-server
tags:
- nagios-nrpe
- ansible.builtin.include_tasks: wrapper.yml
- ansible.builtin.include_tasks: check-local.yml