Compare commits
1 commit
master
...
nrpe-allow
Author | SHA1 | Date | |
---|---|---|---|
Sven Velt | 3a00a96c23 |
59
README.md
59
README.md
|
@ -1,59 +0,0 @@
|
||||||
monitored
|
|
||||||
=========
|
|
||||||
|
|
||||||
Prepare remote machine for monitoring with Naemon/Nagios/Icinga via NRPE and/or SSH
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
|
|
||||||
- Role "epel" for RedHat-like systems
|
|
||||||
|
|
||||||
Role Variables
|
|
||||||
--------------
|
|
||||||
|
|
||||||
Defaults (config/overwrite required):
|
|
||||||
- `monitored_by_nrpe` (defaults: `false`): install/configure NRPE
|
|
||||||
- `monitored_by_ssh` (defaults: `false`): install/configure SSH incl. wrapper
|
|
||||||
script
|
|
||||||
- `monitored_server_ips` (defaults: `[127.0.0.1,]`: list(!) of monitoring server
|
|
||||||
ips
|
|
||||||
|
|
||||||
Required for SSH:
|
|
||||||
- `monitored_ssh_key_files` (defaults: `[]`): list(!) of SSH key strings(!)
|
|
||||||
|
|
||||||
Common variables:
|
|
||||||
- `monitored_packages_install` (defaults: `true`): install plugings
|
|
||||||
- `monitored_sudo_file` (defaults: `/etc/sudoers.d/monitored`): sudoers file
|
|
||||||
- `monitored_sudo_commands`: list of `sudoers` config lines
|
|
||||||
- `monitored_packages_additional(_nrpe|_ssh)`: additional packages to install
|
|
||||||
- `monitored_plugins_custom`: additional plugin scripts to copy
|
|
||||||
- `monitored_plugins_custom_path` (defaults: `/usr/local/plugins/`): path for
|
|
||||||
additional plugins
|
|
||||||
|
|
||||||
NRPE:
|
|
||||||
- `monitored_nrpe_*`: NRPE config variables
|
|
||||||
|
|
||||||
SSH:
|
|
||||||
- `monitored_ssh_key_wrapper`: local path/filename of wrapper
|
|
||||||
- `monitored_ssh_key_wrapper_src`: remote path and filename of wrapper
|
|
||||||
- `monitored_ssh_key_wrapper_*`: file attributes of wrapper
|
|
||||||
|
|
||||||
Example Playbook
|
|
||||||
----------------
|
|
||||||
|
|
||||||
- hosts: all
|
|
||||||
roles:
|
|
||||||
- role: monitored
|
|
||||||
when: monitored_dont|default(false) != true
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
|
|
||||||
GPL-2.0-or-later
|
|
||||||
|
|
||||||
Author Information
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Sven Velt - <sven-ansiblerole@velt.biz>
|
|
||||||
https://git.velt.biz/velt.biz/
|
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
---
|
---
|
||||||
monitored_by_nrpe: false
|
monitored_by_nrpe: False
|
||||||
monitored_by_ssh: false
|
monitored_by_ssh: False
|
||||||
|
|
||||||
monitored_user: nagios
|
monitored_user: nagios
|
||||||
monitored_group: nagios
|
monitored_group: nagios
|
||||||
monitored_homedir: /var/lib/nagios
|
monitored_homedir: /var/lib/nagios
|
||||||
monitored_shell: /bin/bash
|
monitored_shell: /bin/bash
|
||||||
monitored_password: null
|
|
||||||
|
|
||||||
monitored_sudo_file: /etc/sudoers.d/monitored
|
monitored_sudo_file: /etc/sudoers.d/monitored
|
||||||
monitored_sudo_commands: []
|
monitored_sudo_commands: []
|
||||||
|
|
||||||
monitored_packages_install: true
|
monitored_packages_install: True
|
||||||
monitored_packages_predepends: []
|
monitored_packages_predepends: []
|
||||||
monitored_packages_additional: []
|
monitored_packages_additional: []
|
||||||
monitored_packages_additional_nrpe: []
|
monitored_packages_additional_nrpe: []
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
dependencies:
|
|
||||||
- role: epel
|
|
||||||
when: ansible_os_family == "RedHat" and ansible_distribution != "Fedora"
|
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
- hosts: all
|
- hosts: all
|
||||||
roles:
|
roles:
|
||||||
|
|
||||||
# "epel" is already a dependency (meta/main.yml)
|
- role: epel
|
||||||
# - role: epel
|
when: ansible_os_family == "RedHat" and ansible_distribution != "Fedora"
|
||||||
# when: ansible_os_family == "RedHat" and ansible_distribution != "Fedora"
|
|
||||||
|
|
||||||
- role: monitored
|
- role: monitored
|
||||||
when: monitored_dont|default(false) != true
|
when: monitored_dont|default(False) != True
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
---
|
---
|
||||||
- debug:
|
|
||||||
msg:
|
|
||||||
- "SSH: {{ monitored_by_ssh }}"
|
|
||||||
- "NRPE: {{ monitored_by_nrpe }}"
|
|
||||||
|
|
||||||
- name: Sanity checks
|
- name: Sanity checks
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- monitored_dont|default(false) != true
|
- monitored_dont|default(False) != True
|
||||||
- monitored_by_nrpe == true or monitored_by_ssh == true
|
- monitored_by_nrpe == True or monitored_by_ssh == True
|
||||||
fail_msg: "Neither monitored_by_nrpe nor monitored_by_ssh set to True"
|
|
||||||
|
|
||||||
- name: Gather OS Specific Variables
|
- name: Gather OS Specific Variables
|
||||||
include_vars: "{{ item }}"
|
include_vars: "{{ item }}"
|
||||||
|
@ -23,14 +17,14 @@
|
||||||
package:
|
package:
|
||||||
name: "{{ monitored_packages_predepends }}"
|
name: "{{ monitored_packages_predepends }}"
|
||||||
state: latest
|
state: latest
|
||||||
when: monitored_packages_predepends|default(false)
|
when: monitored_packages_predepends|default(False)
|
||||||
|
|
||||||
- name: "INCLUDE: Create monitoring user"
|
- name: "INCLUDE: Create monitoring user"
|
||||||
import_tasks: user.yml
|
import_tasks: user.yml
|
||||||
|
|
||||||
- name: "INCLUDE: Install always necessary packages"
|
- name: "INCLUDE: Install always necessary packages"
|
||||||
include_tasks: packages.yml
|
include_tasks: packages.yml
|
||||||
when: monitored_packages_install != false
|
when: monitored_packages_install != False
|
||||||
|
|
||||||
- name: "INCLUDE: Copy custom plugins"
|
- name: "INCLUDE: Copy custom plugins"
|
||||||
include_tasks: plugins_custom.yml
|
include_tasks: plugins_custom.yml
|
||||||
|
@ -38,9 +32,9 @@
|
||||||
|
|
||||||
- name: "INCLUDE: Monitoring by NRPE"
|
- name: "INCLUDE: Monitoring by NRPE"
|
||||||
include_tasks: nrpe.yml
|
include_tasks: nrpe.yml
|
||||||
when: monitored_by_nrpe == true
|
when: monitored_by_nrpe == True
|
||||||
|
|
||||||
- name: "INCLUDE: Monitoring by SSH"
|
- name: "INCLUDE: Monitoring by SSH"
|
||||||
include_tasks: ssh.yml
|
include_tasks: ssh.yml
|
||||||
when: monitored_by_ssh == true
|
when: monitored_by_ssh == True
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
loop: "{{ monitored_nrpe_include_dirs }}"
|
loop: "{{ monitored_nrpe_include_dirs }}"
|
||||||
|
|
||||||
- name: "INCLUDE: Migrate custom NRPE files"
|
- name: "INCLUDE: Migrate custom NRPE files"
|
||||||
import_tasks: nrpe_migrate.yml
|
include: nrpe_migrate.yml
|
||||||
|
|
||||||
- name: Enable NRPE
|
- name: Enable NRPE
|
||||||
service:
|
service:
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
name: "{{ monitored_nrpe_servicename }}"
|
name: "{{ monitored_nrpe_servicename }}"
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
- name: Install additional packages for NRPE monitoring
|
- name: Instal additional packages for NRPE monitoring
|
||||||
package:
|
package:
|
||||||
name: "{{ monitored_packages_additional_nrpe }}"
|
name: "{{ monitored_packages_additional_nrpe }}"
|
||||||
state: latest
|
state: latest
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
name: "{{ monitored_packages_mp }}"
|
name: "{{ monitored_packages_mp }}"
|
||||||
state: latest
|
state: latest
|
||||||
register: monitoringplugins
|
register: monitoringplugins
|
||||||
ignore_errors: true
|
ignore_errors: True
|
||||||
|
|
||||||
- name: Install Nagios-Plugins
|
- name: Install Nagios-Plugins
|
||||||
package:
|
package:
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
---
|
---
|
||||||
- name: Sanity check
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- monitored_ssh_key_files|length > 0
|
|
||||||
fail_msg: "List of SSH keys ('monitored_ssh_key_files') is empty!"
|
|
||||||
|
|
||||||
- name: Copy SSH authorized_keys for monitoring user
|
- name: Copy SSH authorized_keys for monitoring user
|
||||||
authorized_key:
|
authorized_key:
|
||||||
user: "{{ monitored_user }}"
|
user: "{{ monitored_user }}"
|
||||||
|
@ -21,9 +15,9 @@
|
||||||
group: "{{ monitored_group }}"
|
group: "{{ monitored_group }}"
|
||||||
mode: "{{ monitored_ssh_key_wrapper_mode }}"
|
mode: "{{ monitored_ssh_key_wrapper_mode }}"
|
||||||
backup: yes
|
backup: yes
|
||||||
when: monitored_ssh_key_wrapper_src|default(false) and monitored_ssh_key_wrapper|default(false)
|
when: monitored_ssh_key_wrapper_src|default(False) and monitored_ssh_key_wrapper|default(False)
|
||||||
|
|
||||||
- name: Install additional packages for SSH monitoring
|
- name: Instal additional packages for SSH monitoring
|
||||||
package:
|
package:
|
||||||
name: "{{ monitored_packages_additional_ssh }}"
|
name: "{{ monitored_packages_additional_ssh }}"
|
||||||
state: latest
|
state: latest
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
home: "{{ monitored_homedir }}"
|
home: "{{ monitored_homedir }}"
|
||||||
move_home: yes
|
move_home: yes
|
||||||
shell: "{{ monitored_shell }}"
|
shell: "{{ monitored_shell }}"
|
||||||
password: "{{ monitored_password }}"
|
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: "Install sudo (if required)"
|
- name: "Install sudo (if required)"
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
### {{ ansible_managed }}
|
### {{ ansible_managed }}
|
||||||
|
|
||||||
log_facility=daemon
|
log_facility=daemon
|
||||||
{% if monitored_nrpe_pidfile %}pid_file={{ monitored_nrpe_pidfile }}
|
pid_file={{ monitored_nrpe_pidfile }}
|
||||||
{% else %}# pid_file=
|
|
||||||
{% endif %}
|
|
||||||
debug=0
|
debug=0
|
||||||
|
|
||||||
{% if monitored_nrpe_server_address %}server_address={{ monitored_nrpe_server_address }}
|
{% if monitored_nrpe_server_address %}server_address={{ monitored_nrpe_server_address }}
|
||||||
|
@ -14,7 +12,7 @@ server_port={{ monitored_nrpe_port }}
|
||||||
nrpe_user={{ monitored_user }}
|
nrpe_user={{ monitored_user }}
|
||||||
nrpe_group={{ monitored_group }}
|
nrpe_group={{ monitored_group }}
|
||||||
|
|
||||||
allowed_hosts=127.0.0.1,{{ monitored_server_ips|join(',') }}
|
allowed_hosts=127.0.0.1,::1,{{ monitored_server_ips|join(',') }}
|
||||||
|
|
||||||
dont_blame_nrpe={% if monitored_nrpe_dont_blame == "1" %}1
|
dont_blame_nrpe={% if monitored_nrpe_dont_blame == "1" %}1
|
||||||
{% else %}0
|
{% else %}0
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-pty,from="{{ monitored_server_ips|join(",") }}"{% if monitored_ssh_key_wrapper %},command="{{ monitored_ssh_key_wrapper }}"{% endif %}
|
no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-pty{% if monitored_ssh_key_wrapper %},command="{{ monitored_ssh_key_wrapper }}"{% endif %}
|
|
@ -1,7 +1,4 @@
|
||||||
---
|
---
|
||||||
monitored_shell: /bin/ash
|
|
||||||
monitored_password: '*'
|
|
||||||
|
|
||||||
monitored_packages_mp:
|
monitored_packages_mp:
|
||||||
- monitoring-plugins
|
- monitoring-plugins
|
||||||
monitored_packages_np:
|
monitored_packages_np:
|
||||||
|
@ -22,5 +19,5 @@ monitored_packages_nrpe:
|
||||||
- nrpe
|
- nrpe
|
||||||
|
|
||||||
monitored_nrpe_basedir: /etc
|
monitored_nrpe_basedir: /etc
|
||||||
monitored_nrpe_pidfile: false
|
monitored_nrpe_pidfile: /var/run/nrpe.pid
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
---
|
---
|
||||||
monitored_user: _nagios
|
monitored_by_nrpe: False
|
||||||
monitored_group: _nagios
|
|
||||||
|
monitored_packages_nrpe: null
|
||||||
|
|
||||||
monitored_packages_mp:
|
monitored_packages_mp:
|
||||||
- monitoring-plugins
|
- monitoring-plugins
|
||||||
monitored_packages_np:
|
monitored_packages_np:
|
||||||
- nagios-plugins
|
- nagios-plugins
|
||||||
|
|
||||||
monitored_packages_nrpe:
|
|
||||||
- nrpe
|
|
||||||
|
|
||||||
monitored_nrpe_basedir: /etc/nagios
|
|
||||||
monitored_nrpe_pidfile: /run/nrpe/nrpe.pid
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue