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

126 lines
3 KiB
YAML
Raw Normal View History

2022-10-19 18:23:54 +02:00
# yamllint disable rule:line-length
2018-12-28 11:23:49 +01:00
---
- name: "Install nrpe"
2018-12-28 11:23:49 +01:00
openbsd_pkg:
name:
- nrpe--
2018-12-28 11:23:49 +01:00
state: present
tags:
- nagios-nrpe
2018-12-28 11:23:49 +01:00
- name: "Install monitoring packages"
2018-12-28 11:23:49 +01:00
openbsd_pkg:
name:
- monitoring-plugins
- check_bioctl
2018-12-28 11:23:49 +01:00
state: present
tags:
- nagios-nrpe
2018-12-28 11:23:49 +01:00
- name: "Create nrpe.d dir"
2018-12-28 11:23:49 +01:00
file:
path: /etc/nrpe.d
state: directory
owner: root
group: wheel
mode: "0755"
tags:
- nagios-nrpe
2018-12-28 11:23:49 +01:00
- name: "Include nrpe.d dir in nrpe.cfg"
2018-12-28 11:23:49 +01:00
lineinfile:
dest: /etc/nrpe.cfg
line: 'include_dir=/etc/nrpe.d'
tags:
- nagios-nrpe
2018-12-28 11:23:49 +01:00
- name: "Custom configuration is present"
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"
2022-10-19 18:23:54 +02:00
create: true
mode: "0644"
insertbefore: BOF
2018-12-28 11:23:49 +01:00
notify: restart nrpe
tags:
- nagios-nrpe
2018-12-28 11:23:49 +01:00
- name: "Allow NRPE hosts"
lineinfile:
dest: /etc/nrpe.d/evolix.cfg
insertbefore: BOF
2022-10-19 18:23:54 +02:00
backrefs: true
regex: "allowed_hosts={{ nagios_nrpe_allowed_hosts | join(',') }}(.*)"
line: 'allowed_hosts={{ nagios_nrpe_allowed_hosts | join(",") }}\1'
tags:
- nagios-nrpe
- name: "Allow NRPE hosts - add comment"
lineinfile:
dest: /etc/nrpe.d/evolix.cfg
insertbefore: BOF
line: "# Allowed IPs"
tags:
- nagios-nrpe
- name: "Create nrpe plugins dir"
2020-10-14 16:35:17 +02:00
file:
path: /usr/local/libexec/nagios/plugins/
state: directory
owner: root
group: wheel
mode: "0755"
tags:
- nagios-nrpe
2020-10-14 16:35:17 +02:00
- name: "Nagios plugins are installed"
2018-12-28 11:23:49 +01:00
copy:
src: plugins_bsd/{{ item.name }}
dest: /usr/local/libexec/nagios/plugins/{{ item.name }}
2018-12-28 11:23:49 +01:00
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}
2020-10-13 12:02:48 +02:00
- {name: 'check_packetfilter.sh', force: true}
- {name: 'check_pf_states', force: false}
- {name: 'check_mailq.pl', force: true}
2022-03-31 11:57:45 +02:00
- {name: 'check_dhcp_pool', force: false}
- {name: 'check_dhcpd.sh', force: false}
2018-12-28 11:23:49 +01:00
notify: restart nrpe
tags:
- nagios-nrpe
- nagios-nrpe-utils
2018-12-28 11:23:49 +01:00
- name: "Nagios plugins are installed - template"
2018-12-28 11:23:49 +01:00
template:
src: plugins_bsd/{{ item.name }}.j2
dest: /usr/local/libexec/nagios/plugins/{{ item.name }}
2018-12-28 11:23:49 +01:00
owner: root
group: wheel
mode: "0755"
force: "{{ item.force }}"
2018-12-28 11:23:49 +01:00
with_items:
- {name: 'check_free_mem.sh', force: true}
2018-12-28 11:23:49 +01:00
notify: restart nrpe
tags:
- nagios-nrpe
- nagios-nrpe-utils
2018-12-28 11:23:49 +01:00
- name: "Starting and enabling nrpe"
2018-12-28 11:23:49 +01:00
service:
name: nrpe
enabled: true
2018-12-28 11:23:49 +01:00
state: started
tags:
- nagios-nrpe