Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions icinga2-nrpe-agent/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nrpe_agent_Debian:
- { package: "nagios-nrpe-plugin" }
- { package: "nagios-plugins" }

nrpe_agent_Gentoo:
- { package: "nrpe" }
- { package: "nagios-plugins" }

nrpe_configuration:
- { directive: "log_facility=daemon" }
- { directive: "server_port=5666" }
Expand All @@ -27,6 +31,10 @@ nrpe_users_Debian:
- { user: "nrpe_user=nagios" }
- { user: "nrpe_group=nagios" }

nrpe_users_Gentoo:
- { user: "nrpe_user=nagios" }
- { user: "nrpe_group=nagios" }

nrpe_agent_config: "/etc/nagios/nrpe.cfg"

# Plugins path for Debian x86_64 and other i386
Expand Down
20 changes: 20 additions & 0 deletions icinga2-nrpe-agent/tasks/icinga2_nrpe_agent_Gentoo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: Install Nrpe and Plugins
portage: package={{ item.package }}
state=present
update=yes
with_items: nrpe_agent_{{ ansible_os_family }}
tags:
- nrpe_agent_install

- name: Copy Nrpe Configuration
template: src=nrpe.cfg.j2
dest={{ nrpe_agent_config }}
owner=root
group=root
mode=0644
backup=yes
notify:
- restart nrpe
tags:
- nrpe_agent_config
3 changes: 3 additions & 0 deletions icinga2-nrpe-agent/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
- include: icinga2_nrpe_agent_Debian.yml
when: ansible_os_family == 'Debian' and 'monitoring_servers' not in group_names
# NRPE Agent will be installed on clients only

- include: icinga2_nrpe_agent_Gentoo.yml
when: ansible_os_family == 'Gentoo' and 'monitoring_servers' not in group_names
5 changes: 4 additions & 1 deletion icinga2-nrpe-agent/templates/nrpe.cfg.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# {{ ansible_managed }}

allowed_hosts={% for host in groups['monitoring_servers'] %}{{ hostvars[host]['ansible_eth0']['ipv4']['address'] }}{% if not loop.last %},{% endif %}{% endfor %}
allowed_hosts={% for host in nrpe_allowed_hosts %}{{ host }}{% if not loop.last %},{% endif %}{% endfor %}

{% for element in nrpe_configuration %}
{{ element.directive }}
Expand All @@ -12,3 +12,6 @@ allowed_hosts={% for host in groups['monitoring_servers'] %}{{ hostvars[host]['a
{% if ansible_os_family == 'Debian' %}
{% include "nrpe_Debian.cfg.j2" %}
{% endif %}
{% if ansible_os_family == 'Gentoo' %}
{% include "nrpe_Gentoo.cfg.j2" %}
{% endif %}
11 changes: 11 additions & 0 deletions icinga2-nrpe-agent/templates/nrpe_Gentoo.cfg.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# {{ ansible_managed }}
{% for element in nrpe_users_Gentoo %}
{{ element.user }}
{% endfor %}

# Here goes NRPE check commands
{% for key,value in nrpe_check_commands.iteritems() %}
{% for key,value in value.items() %}
command[{{ key }}]={{ nrpe_agent_plugins }}/{{ key }} {{ value }}
{% endfor %}
{% endfor %}