EvoBSD/roles/nagios-nrpe/tasks/main.yml
Jérémy Dubois 99ff7284a3 base, collectd, etc-git, logsentry, nagios-nrpe: install packages manually
Because openbsd_pkg module is broken since OpenBSD 7.4 with the version of Ansible we currently use
2024-03-13 15:17:20 +01:00

128 lines
3.2 KiB
YAML

# yamllint disable rule:line-length
---
# openbsd_pkg is broken since OpenBSD 7.4 with the version of Ansible we currently use
#- name: "Install nrpe"
# community.general.openbsd_pkg:
# name:
# - nrpe--
# state: present
# tags:
# - nagios-nrpe
#
#- name: "Install monitoring packages"
# community.general.openbsd_pkg:
# name:
# - monitoring-plugins
# - check_bioctl
# state: present
# tags:
# - nagios-nrpe
- name: "Install nrpe and monitoring packages"
include: openbsd_pkg_custom.yml
vars:
package: "{{ item }}"
loop:
- nrpe--
- monitoring-plugins
- check_bioctl
tags:
- nagios-nrpe
- name: "Create nrpe.d dir"
ansible.builtin.file:
path: /etc/nrpe.d
state: directory
owner: root
group: wheel
mode: "0755"
tags:
- nagios-nrpe
- name: "Include nrpe.d dir in nrpe.cfg"
ansible.builtin.lineinfile:
dest: /etc/nrpe.cfg
line: 'include_dir=/etc/nrpe.d'
create: true
tags:
- nagios-nrpe
- name: "Check if nrpe service exists, for usage in check_mode"
stat:
path: /etc/rc.d/nrpe
register: nrpe_exists
- name: "Custom configuration is present"
ansible.builtin.blockinfile:
block: "{{ lookup('template', 'evolix_bsd.cfg.j2') }}"
path: /etc/nrpe.d/evolix.cfg
marker: "## {mark} ANSIBLE MANAGED BLOCK : Custom NRPE configuration file from EvoBSD"
create: true
mode: "0644"
insertbefore: BOF
notify: restart nrpe
tags:
- nagios-nrpe
- name: "Create nrpe plugins dir"
ansible.builtin.file:
path: /usr/local/libexec/nagios/plugins/
state: directory
owner: root
group: wheel
mode: "0755"
tags:
- nagios-nrpe
- name: "Nagios plugins are installed"
ansible.builtin.copy:
src: plugins_bsd/{{ item.name }}
dest: /usr/local/libexec/nagios/plugins/{{ item.name }}
owner: root
group: wheel
mode: "0755"
force: "{{ item.force }}"
with_items:
- {name: 'check_carp_if', force: true}
- {name: 'check_connections_state.sh', force: false}
- {name: 'check_ipsecctl.sh', force: false}
- {name: 'check_ipsecctl_critiques.sh', force: false}
- {name: 'check_openbgpd', force: true}
- {name: 'check_openvpn', force: false}
- {name: 'check_openvpn.pl', force: true}
- {name: 'check_ospfd_simple', force: true}
- {name: 'check_packetfilter.sh', force: true}
- {name: 'check_pf_states', force: false}
- {name: 'check_mailq.pl', force: true}
- {name: 'check_dhcp_pool', force: false}
- {name: 'check_dhcpd.sh', force: false}
- {name: 'check_ipmi_sensor', force: true}
notify: restart nrpe
tags:
- nagios-nrpe
- nagios-nrpe-utils
- name: "Nagios plugins are installed - template"
ansible.builtin.template:
src: plugins_bsd/{{ item.name }}.j2
dest: /usr/local/libexec/nagios/plugins/{{ item.name }}
owner: root
group: wheel
mode: "0755"
force: "{{ item.force }}"
with_items:
- {name: 'check_free_mem.sh', force: true}
notify: restart nrpe
tags:
- nagios-nrpe
- nagios-nrpe-utils
- name: "Starting and enabling nrpe"
ansible.builtin.service:
name: nrpe
enabled: true
state: started
when: nrpe_exists.stat.exists
tags:
- nagios-nrpe