Commit fd72c7d8 authored by Assaf Flatto's avatar Assaf Flatto

Fix nrpe configuration - allowed hosts IP detection

parent f9d8d51e
--- ---
# defaults file for icinga2-ansible-add-hosts # defaults file for icinga2-ansible-add-hosts
icinga2_hosts_dir: "/etc/icinga2/conf.d/" icinga2_hosts_dir: "/etc/icinga2/conf.d/hosts"
host_address: "{{ hostvars[item]['ansible_default_ipv4']['address'] }}" host_address: "{{ hostvars[item]['ansible_default_ipv4']['address'] }}"
host_attributes: "none" host_attributes: "none"
host_checks: "none" host_checks: "none"
--- ---
# tasks file for icinga2-ansible-add-hosts # tasks file for icinga2-ansible-add-hosts
- name: create Autogenerated host directory
file:
path: "{{ icinga2_hosts_dir }}"
owner: icinga
group: icinga
mode: 0755
state: directory
recurse: yes
- import_tasks: icinga2_add_hosts.yml - import_tasks: icinga2_add_hosts.yml
...@@ -24,6 +24,8 @@ nrpe_agent_plugins_x86_64: "/usr/lib64/nagios/plugins" ...@@ -24,6 +24,8 @@ nrpe_agent_plugins_x86_64: "/usr/lib64/nagios/plugins"
nrpe_agent_check_mem: "https://raw.githubusercontent.com/zwindler/check_mem_ng/master/check_mem_ng.sh" nrpe_agent_check_mem: "https://raw.githubusercontent.com/zwindler/check_mem_ng/master/check_mem_ng.sh"
ssh_port: 22
# Sample NRPE check commands # Sample NRPE check commands
nrpe_check_commands: nrpe_check_commands:
check_load: check_load:
......
--- ---
- name: Install Nrpe and Plugins - name: Install Nrpe and Plugins
apt: pkg={{ item }} package:
state=latest name: "{{ item }}"
update_cache=yes state: latest
install_recommends=no update_cache: yes
install_recommends: no
with_items: "{{ nrpe_agent_Debian }}" with_items: "{{ nrpe_agent_Debian }}"
tags: tags:
- nrpe_agent_install - nrpe_agent_install
- name: Copy Nrpe Configuration - name: Copy Nrpe Configuration
template: src=nrpe.cfg.j2 template:
dest={{ nrpe_agent_config }} src: nrpe.cfg.j2
owner=root dest: "{{ nrpe_agent_config }}"
group=root owner: root
mode=0644 group: root
backup=yes mode: 0644
backup: yes
notify: notify:
- restart nagios-nrpe-server - restart nagios-nrpe-server
tags: tags:
......
--- ---
# tasks file for icinga2-nrpe-agent # tasks file for icinga2-nrpe-agent
- set_fact:
allowed_hosts: "{{ hostvars[item]['ansible_default_ipv4']['address'] }}"
with_inventory_hostnames: monitoring_servers
- include_tasks: icinga2_nrpe_agent_RedHat.yml - include_tasks: icinga2_nrpe_agent_RedHat.yml
when: ansible_os_family == 'RedHat' and 'monitoring_servers' not in group_names when: ansible_os_family == 'RedHat' and 'monitoring_servers' not in group_names
# NRPE Agent will be installed on clients only # NRPE Agent will be installed on clients only
......
# {{ ansible_managed }} # {{ ansible_managed }}
allowed_hosts={{ nrpe_allowed_hosts }} allowed_hosts={{ allowed_hosts | default('nrpe_allowed_hosts') }}
{{ nrpe_configuration }} {{ nrpe_configuration }}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment