/
main.yml
61 lines (51 loc) · 1.77 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
# Nagios NRPE Server role by Mooash
# Include variables at the start so they're in scope
- name: Include OS-Specific variables
include_vars: "{{ ansible_os_family }}.yml"
# Include RedHat specific variables due to x64/x86 differences
- name: Include RedHat x86 variables
include_vars: "{{ ansible_os_family }}-x86.yml"
when: "'{{ansible_os_family}}' == 'RedHat' and '{{ansible_architecture}}' == 'i386'"
- name: Include RedHat x64 variables
include_vars: "{{ ansible_os_family }}-x64.yml"
when: "'{{ansible_os_family}}' == 'RedHat' and '{{ansible_architecture}}' == 'x86_64'"
# Install our needed packages for each specific OS
# Debian packages
- include: packages-debian.yml
when: "ansible_os_family == 'Debian'"
# RedHat based packages
- include: packages-redhat.yml
when: "ansible_os_family == 'RedHat'"
# Arch Linux based packages
- include: packages-archlinux.yml
when: "ansible_os_family == 'Archlinux'"
# Create our config
- name: Create nrpe.cfg from template
sudo: true
template: >
src="nrpe.cfg.j2"
dest="{{ nagios_nrpe_server_dir }}/nrpe.cfg"
owner=root group=root mode=0644
notify: restart nagios-nrpe-server
# Create nrpe_ansible.cfg
- name: Create nrpe_ansible.cfg from template
sudo: true
template: >
src="nrpe_ansible.cfg.j2"
dest="{{ nagios_nrpe_server_dir }}/nrpe_ansible.cfg"
owner=root group=root mode=0644
notify: restart nagios-nrpe-server
# Sync our plugins
- name: Install plugins
sudo: true
copy: >
src="{{ item }}"
dest="{{ nagios_nrpe_server_plugins_dir }}/"
owner=root group=root mode=0755
with_fileglob:
- plugins/*
# Ensure NRPE server is running and will start at boot
- name: Ensure NRPE server is running
sudo: true
service: name="{{ nagios_nrpe_server_service }}" state=started enabled=yes