├── .circleci └── config.yml ├── .editorconfig ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── VERSION ├── defaults └── main.yml ├── files └── plugins │ ├── README.md │ └── global │ └── README.md ├── handlers └── main.yml ├── meta ├── main.yml └── tests │ ├── inventory │ └── local_host.yml ├── tasks ├── main.yml ├── packages-Archlinux.yml ├── packages-Debian.yml ├── packages-RedHat.yml ├── packages-Solaris.yml └── variables.yml ├── templates ├── nrpe.cfg.j2 └── nrpe_ansible.cfg.j2 └── vars ├── Archlinux.yml ├── Debian.yml ├── RedHat-aarch64.yml ├── RedHat-i386.yml ├── RedHat-x86_64.yml ├── RedHat.yml └── Solaris.yml /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | 4 | jobs: 5 | build: 6 | docker: 7 | - image: circleci/python:3 8 | environment: 9 | SITE: local_host.yml 10 | steps: 11 | - checkout 12 | - run: sudo pip install ansible 13 | - run: "{ echo '[defaults]'; echo 'roles_path = ../../'; } >> ansible.cfg" 14 | - run: 15 | name: Ansible Version 16 | command: ansible --version 17 | - run: 18 | name: Create role symlink 19 | command: ln -s ../../../ nagios-nrpe-server 20 | working_directory: meta/tests/roles 21 | - run: ansible-playbook -i meta/tests/inventory meta/tests/$SITE --syntax-check 22 | - run: ansible-playbook -i meta/tests/inventory meta/tests/$SITE --connection=local --sudo 23 | 24 | lint: 25 | docker: 26 | - image: circleci/python:3 27 | steps: 28 | - checkout 29 | - run: sudo pip install ansible-lint 30 | - run: "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg" 31 | - run: ansible-lint --exclude=meta/tests/ . 32 | 33 | workflows: 34 | version: 2 35 | build_and_test: 36 | jobs: 37 | - build 38 | - lint 39 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [v3.1.0](https://github.com/jloh/nagios-nrpe-server/tree/v3.1.0) (2019-04-08) 4 | [Full Changelog](https://github.com/jloh/nagios-nrpe-server/compare/v3.0.1...v3.1.0) 5 | 6 | **Implemented enhancements:** 7 | 8 | - Add aarch64 config for ARM based RedHat/Amazon Linux installs [\#25](https://github.com/jloh/nagios-nrpe-server/pull/25) ([thowat](https://github.com/thowat)) 9 | - Allow variable override to work with OS defaults [\#24](https://github.com/jloh/nagios-nrpe-server/pull/24) ([benagricola](https://github.com/benagricola)) 10 | - enable server\_address and disable example commands in nrpe.cfg template [\#22](https://github.com/jloh/nagios-nrpe-server/pull/22) ([MrTango](https://github.com/MrTango)) 11 | 12 | **Fixed bugs:** 13 | 14 | - nagios-plugins aren't installed on debain based OS' [\#23](https://github.com/jloh/nagios-nrpe-server/issues/23) 15 | - Custom variables overwritten [\#18](https://github.com/jloh/nagios-nrpe-server/issues/18) 16 | - enable server\\_address and disable example commands in nrpe.cfg template [\#22](https://github.com/jloh/nagios-nrpe-server/pull/22) ([MrTango](https://github.com/MrTango)) 17 | 18 | **Closed issues:** 19 | 20 | - Ansible 2.X mega issue [\#16](https://github.com/jloh/nagios-nrpe-server/issues/16) 21 | 22 | **Merged pull requests:** 23 | 24 | - Fix lint errors [\#28](https://github.com/jloh/nagios-nrpe-server/pull/28) ([jloh](https://github.com/jloh)) 25 | - Setup CircleCI for tests [\#27](https://github.com/jloh/nagios-nrpe-server/pull/27) ([jloh](https://github.com/jloh)) 26 | - Fix var usage for aarch64 after \#24 [\#26](https://github.com/jloh/nagios-nrpe-server/pull/26) ([jloh](https://github.com/jloh)) 27 | 28 | ## [v3.0.1](https://github.com/jloh/nagios-nrpe-server/tree/v3.0.1) (2017-03-25) 29 | [Full Changelog](https://github.com/jloh/nagios-nrpe-server/compare/v3.0.0...v3.0.1) 30 | 31 | **Implemented enhancements:** 32 | 33 | - Nrpe command template [\#19](https://github.com/jloh/nagios-nrpe-server/pull/19) ([bashrc666](https://github.com/bashrc666)) 34 | 35 | **Fixed bugs:** 36 | 37 | - nagios\_nrpe\_command is undefined [\#20](https://github.com/jloh/nagios-nrpe-server/issues/20) 38 | 39 | ## [v3.0.0](https://github.com/jloh/nagios-nrpe-server/tree/v3.0.0) (2016-02-27) 40 | [Full Changelog](https://github.com/jloh/nagios-nrpe-server/compare/v2.3.0...v3.0.0) 41 | 42 | **Implemented enhancements:** 43 | 44 | - Allow comma separated server names in "nagios\_nrpe\_server\_allowed\_hosts" [\#13](https://github.com/jloh/nagios-nrpe-server/issues/13) 45 | - Remove dependency on EPEL repo [\#9](https://github.com/jloh/nagios-nrpe-server/issues/9) 46 | 47 | **Merged pull requests:** 48 | 49 | - Move several tasks into single ones [\#17](https://github.com/jloh/nagios-nrpe-server/pull/17) ([jloh](https://github.com/jloh)) 50 | 51 | ## [v2.3.0](https://github.com/jloh/nagios-nrpe-server/tree/v2.3.0) (2015-09-04) 52 | [Full Changelog](https://github.com/jloh/nagios-nrpe-server/compare/v2.2.0...v2.3.0) 53 | 54 | **Implemented enhancements:** 55 | 56 | - Solaris 11.1 -- OpenCSW [\#12](https://github.com/jloh/nagios-nrpe-server/pull/12) ([jaymell](https://github.com/jaymell)) 57 | 58 | **Closed issues:** 59 | 60 | - hardcoded sudo [\#11](https://github.com/jloh/nagios-nrpe-server/issues/11) 61 | 62 | **Merged pull requests:** 63 | 64 | - Add a Gitter chat badge to README.md [\#10](https://github.com/jloh/nagios-nrpe-server/pull/10) ([gitter-badger](https://github.com/gitter-badger)) 65 | 66 | ## [v2.2.0](https://github.com/jloh/nagios-nrpe-server/tree/v2.2.0) (2015-04-15) 67 | [Full Changelog](https://github.com/jloh/nagios-nrpe-server/compare/v2.1.1...v2.2.0) 68 | 69 | **Implemented enhancements:** 70 | 71 | - Ability to deploy per-server plugins [\#4](https://github.com/jloh/nagios-nrpe-server/issues/4) 72 | - Closes \#4 - Adding the ability to deploy per-server plugins [\#8](https://github.com/jloh/nagios-nrpe-server/pull/8) ([jloh](https://github.com/jloh)) 73 | - CI test [\#7](https://github.com/jloh/nagios-nrpe-server/pull/7) ([jloh](https://github.com/jloh)) 74 | - Add Arch Linux support [\#5](https://github.com/jloh/nagios-nrpe-server/pull/5) ([k0ste](https://github.com/k0ste)) 75 | 76 | **Merged pull requests:** 77 | 78 | - Further code cleanup [\#6](https://github.com/jloh/nagios-nrpe-server/pull/6) ([jloh](https://github.com/jloh)) 79 | 80 | ## [v2.1.1](https://github.com/jloh/nagios-nrpe-server/tree/v2.1.1) (2015-01-04) 81 | [Full Changelog](https://github.com/jloh/nagios-nrpe-server/compare/v2.1.0...v2.1.1) 82 | 83 | ## [v2.1.0](https://github.com/jloh/nagios-nrpe-server/tree/v2.1.0) (2015-01-04) 84 | [Full Changelog](https://github.com/jloh/nagios-nrpe-server/compare/v2.0.2...v2.1.0) 85 | 86 | **Implemented enhancements:** 87 | 88 | - Adding task to copy plugins to hosts [\#3](https://github.com/jloh/nagios-nrpe-server/pull/3) ([jloh](https://github.com/jloh)) 89 | 90 | ## [v2.0.2](https://github.com/jloh/nagios-nrpe-server/tree/v2.0.2) (2015-01-04) 91 | [Full Changelog](https://github.com/jloh/nagios-nrpe-server/compare/v2.0.1...v2.0.2) 92 | 93 | **Fixed bugs:** 94 | 95 | - Fixing file names to match ansible vars - thanks romanlv! [\#2](https://github.com/jloh/nagios-nrpe-server/pull/2) ([jloh](https://github.com/jloh)) 96 | 97 | ## [v2.0.1](https://github.com/jloh/nagios-nrpe-server/tree/v2.0.1) (2014-10-26) 98 | [Full Changelog](https://github.com/jloh/nagios-nrpe-server/compare/v2.0.0...v2.0.1) 99 | 100 | ## [v2.0.0](https://github.com/jloh/nagios-nrpe-server/tree/v2.0.0) (2014-09-21) 101 | [Full Changelog](https://github.com/jloh/nagios-nrpe-server/compare/v1.0.0...v2.0.0) 102 | 103 | ## [v1.0.0](https://github.com/jloh/nagios-nrpe-server/tree/v1.0.0) (2014-08-31) 104 | 105 | 106 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### General 2 | 3 | I've set some general contribution outlines [here](https://blog.jloh.co/github-contributing-guidelines/#pk_campaign=GitHub-Project&pk_kwd=nagios-nrpe-server). Please read them before opening a pull request. 4 | 5 | ### Project Specific 6 | 7 | #### Ansible formatting 8 | 9 | I try and follow Ansible's [playbook best practices](https://docs.ansible.com/playbooks_best_practices.html) to the best of my ability. That said, these rules always apply: 10 | 11 | * [Always Mention The State](https://docs.ansible.com/playbooks_best_practices.html#always-mention-the-state) 12 | * Move big plays to multiple lines. Plays like template look ugly on single lines. 13 | Not OK: 14 | 15 | ```yaml 16 | # Create nrpe_ansible.cfg 17 | - name: Create nrpe_ansible.cfg from template 18 | sudo: true 19 | template: src="nrpe_ansible.cfg.j2" dest="{{ nagios_nrpe_server_dir }}/nrpe_ansible.cfg" owner=root group=root mode=0644 20 | notify: restart nagios-nrpe-server 21 | ``` 22 | 23 | OK: 24 | 25 | ```yaml 26 | # Create nrpe_ansible.cfg 27 | - name: Create nrpe_ansible.cfg from template 28 | sudo: true 29 | template: > 30 | src="nrpe_ansible.cfg.j2" 31 | dest="{{ nagios_nrpe_server_dir }}/nrpe_ansible.cfg" 32 | owner=root group=root mode=0644 33 | notify: restart nagios-nrpe-server 34 | ``` 35 | * If a play is OS specific, state it in the play name. 36 | eg: `- name: Installing packages [Debian]` or `- name: Installing packages [RedHat]` 37 | 38 | ### Questions? 39 | 40 | If you're confused on any of the above, just contact me so I can clear up my documentation. 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 James Loh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Nagios NRPE Server Config 2 | ========= 3 | 4 | [![GitHub version](https://badge.fury.io/gh/jloh%2Fnagios-nrpe-server.svg)](http://badge.fury.io/gh/jloh%2Fnagios-nrpe-server) [![CircleCI](https://circleci.com/gh/jloh/nagios-nrpe-server.svg?style=svg)](https://circleci.com/gh/jloh/nagios-nrpe-server) 5 | 6 | An Ansible role to handle the installation and rollout of the Nagios NRPE Daemon. 7 | 8 | I've only selected certain platforms that I know this 100% works on, but it should work on any platform that NRPE can be installed on. 9 | 10 | Currently supports: 11 | 12 | * Debian 13 | - Squeeze 14 | - Wheezy 15 | * Ubuntu 16 | - Raring 17 | - Saucy 18 | - Trusty 19 | * RedHat 20 | - At least 6 onwards 21 | * Arch Linux 22 | - All 23 | * Solaris 24 | - At least 11.1 25 | 26 | Requirements 27 | ------------ 28 | 29 | RedHat based OS's must have the EPEL repo. 30 | 31 | Role Information 32 | -------------- 33 | 34 | This role gives you the ability to deploy plugins on a global and per-server basis. This can be done by putting plugins into [`files/plugins/global`](files/plugins/global) or by creating a folder in `files/plugins/` that is the servers [FQDN](http://en.wikipedia.org/wiki/Fully_qualified_domain_name). 35 | 36 | You can find out your servers FQDN by running the [Ansible Setup](http://docs.ansible.com/setup_module.html) module. 37 | 38 | Role Variables 39 | -------------- 40 | 41 | * *nagios_nrpe_server_bind_address*: 127.0.0.1 42 | * *nagios_nrpe_server_port*: 5666 43 | * *nagios_nrpe_server_allowed_hosts*: 127.0.0.1 44 | * *nagios_nrpe_command*: see example playbook section 45 | 46 | These are OS specific and likely wont want to be changed 47 | 48 | Debian: 49 | 50 | * *nagios_nrpe_server_pid*: /var/run/nagios/nrpe.pid 51 | * *nagios_nrpe_server_user*: nagios 52 | * *nagios_nrpe_server_group*: nagios 53 | * *nagios_nrpe_server_service*: nagios-nrpe-server 54 | * *nagios_nrpe_server_plugins_dir*: /usr/lib/nagios/plugins 55 | * *nagios_nrpe_server_dir*: /etc/nagios 56 | 57 | RedHat: 58 | 59 | * *nagios_nrpe_server_pid*: /var/run/nrpe/nrpe.pid 60 | * *nagios_nrpe_server_user*: nrpe 61 | * *nagios_nrpe_server_group*: nrpe 62 | * *nagios_nrpe_server_repo_redhat*: epel 63 | * *nagios_nrpe_server_service*: nrpe 64 | * *nagios_nrpe_server_dir*: /etc/nagios 65 | 66 | Arhc Linux: 67 | * *nagios_nrpe_server_pid*: /var/run/nrpe/nrpe.pid 68 | * *nagios_nrpe_server_user*: 31 69 | * *nagios_nrpe_server_group*: 31 70 | * *nagios_nrpe_server_service*: nrpe 71 | * *nagios_nrpe_server_plugins_dir*: /usr/lib/monitoring-plugins 72 | * *nagios_nrpe_server_dir*: /etc/nrpe 73 | 74 | Solaris: 75 | * *nagios_nrpe_server_dir*: /etc/opt/csw 76 | * *nagios_nrpe_server_group*: nagios 77 | * *nagios_nrpe_server_pid*: /var/run/nrpe.pid 78 | * *nagios_nrpe_server_plugins_dir*: /opt/csw/libexec/nagios-plugins 79 | * *nagios_nrpe_server_service*: svc:/network/cswnrpe:default 80 | * *nagios_nrpe_server_user*: nagios 81 | 82 | Dependencies 83 | ------------ 84 | 85 | N/A 86 | 87 | Example Playbook 88 | ---------------- 89 | 90 | ```yaml 91 | - hosts: servers 92 | roles: 93 | - jloh.nagios_nrpe_server 94 | vars: 95 | nagios_nrpe_server_allowed_hosts: 96 | - 192.168.0.1 97 | - 127.0.0.1 98 | nagios_nrpe_command: 99 | oracle_tnsping: 100 | script: check_oracle_health 101 | option: --mode tnsping 102 | oracle_connection-time: 103 | script: check_oracle_health 104 | option: --mode connection-time 105 | ``` 106 | 107 | License 108 | ------- 109 | 110 | MIT 111 | 112 | Author Information 113 | ------------------ 114 | 115 | Checkout my blog [here](http://blog.jloh.co). 116 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | v3.0.1 2 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | nagios_nrpe_server_bind_address: 127.0.0.1 3 | nagios_nrpe_server_port: 5666 4 | nagios_nrpe_server_allowed_hosts: 127.0.0.1 5 | nagios_nrpe_server_dont_blame_nrpe: 0 6 | nagios_nrpe_server_plugins_src_dir: plugins -------------------------------------------------------------------------------- /files/plugins/README.md: -------------------------------------------------------------------------------- 1 | Place plugin files here so that they're deployed by Ansible. 2 | 3 | Files in the `files/plugins/global/` folder will be deployed to all systems, files in `files/plugins/{{ ansible_fqdn }}/` will only be deployed to the server that has that FQDN. 4 | -------------------------------------------------------------------------------- /files/plugins/global/README.md: -------------------------------------------------------------------------------- 1 | This is just a placeholder so that git doesn't ignore this folder 2 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Restart the Nagios NRPE Server 3 | # Since RedHat based OS's and Debian based ones call the service 4 | # different names, we use a variable set in vars/{{ ansible_os_family }}.yml 5 | 6 | - name: restart nagios-nrpe-server 7 | service: 8 | name: "{{ nagios_nrpe_server_service }}" 9 | state: restarted 10 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: James Loh 4 | description: Nagios NRPE Server configuration Ansible Role 5 | license: license (MIT) 6 | min_ansible_version: 1.2 7 | platforms: 8 | - name: EL 9 | versions: 10 | - 5 11 | - 6 12 | - 7 13 | - name: Ubuntu 14 | versions: 15 | - raring 16 | - saucy 17 | - trusty 18 | - name: Debian 19 | versions: 20 | - squeeze 21 | - wheezy 22 | - name: ArchLinux 23 | versions: 24 | - all 25 | - name: Solaris 26 | galaxy_tags: 27 | - monitoring 28 | - system 29 | - nagios 30 | - nrpe 31 | dependencies: [] 32 | -------------------------------------------------------------------------------- /meta/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | -------------------------------------------------------------------------------- /meta/tests/local_host.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - nagios-nrpe-server 6 | vars: 7 | nagios_nrpe_command: 8 | oracle_tnsping: 9 | script: check_oracle_health 10 | option: --mode tnsping 11 | oracle_connection-time: 12 | script: check_oracle_health 13 | option: --mode connection-time -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Nagios NRPE Server role by James Loh 3 | 4 | # Include variables at the start so they're in scope 5 | - name: Include OS-Specific variables 6 | include_tasks: "variables.yml" 7 | 8 | # Install our needed packages for each specific OS 9 | - include: "packages-{{ ansible_os_family }}.yml" 10 | 11 | # Create our config 12 | - name: Create nrpe.cfg from template 13 | template: 14 | src: "nrpe.cfg.j2" 15 | dest: "{{ nagios_nrpe_server_dir }}/nrpe.cfg" 16 | owner: root 17 | group: root 18 | mode: 0644 19 | notify: restart nagios-nrpe-server 20 | 21 | # Create nrpe_ansible.cfg 22 | - name: Create nrpe_ansible.cfg from template 23 | template: 24 | src: "nrpe_ansible.cfg.j2" 25 | dest: "{{ nagios_nrpe_server_dir }}/nrpe_ansible.cfg" 26 | owner: root 27 | group: root 28 | mode: 0644 29 | notify: restart nagios-nrpe-server 30 | 31 | # Sync our plugins 32 | - name: Install global plugins 33 | copy: 34 | src: "{{ nagios_nrpe_server_plugins_src_dir }}/global/" 35 | dest: "{{ nagios_nrpe_server_plugins_dir }}" 36 | owner: root 37 | group: root 38 | mode: 0755 39 | failed_when: false 40 | 41 | # Install per-server plugins 42 | - name: Install per-server plugins 43 | copy: 44 | src: "{{ nagios_nrpe_server_plugins_src_dir }}/{{ inventory_hostname }}/" 45 | dest: "{{ nagios_nrpe_server_plugins_dir }}" 46 | owner: root 47 | group: root 48 | mode: 0755 49 | failed_when: false 50 | 51 | # Ensure NRPE server is running and will start at boot 52 | - name: Ensure NRPE server is running 53 | service: 54 | name: "{{ nagios_nrpe_server_service }}" 55 | state: started 56 | enabled: yes 57 | -------------------------------------------------------------------------------- /tasks/packages-Archlinux.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Update pacman cache for Arch Linux based OS's 3 | - name: Update pacman cache [Arch Linux] 4 | pacman: 5 | update_cache: yes 6 | 7 | # Nagios NRPE Server for Arch Linux based OS's 8 | - name: Install Nagios NRPE Server [Arch Linux] 9 | pacman: 10 | name: nrpe 11 | state: present 12 | -------------------------------------------------------------------------------- /tasks/packages-Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Update apt-cache for Debian based OS's 3 | - name: Update apt cache [Debian] 4 | apt: 5 | update_cache: yes 6 | 7 | # Nagios NRPE Server for Debian based OS's 8 | - name: Install Nagios NRPE Server [Debian] 9 | apt: 10 | name: nagios-nrpe-server 11 | state: present 12 | 13 | - name: Install nagios-plugins [Debian] 14 | apt: 15 | name: nagios-plugins 16 | state: present 17 | -------------------------------------------------------------------------------- /tasks/packages-RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Nagios NRPE Server for RedHat based OS's 3 | # The EPEL repo is required for this package 4 | - name: Install Nagios NRPE Server [RedHat] 5 | yum: 6 | name: nrpe 7 | state: present 8 | 9 | # Nagios Plugins since they aren't installed as part of the package above 10 | - name: Install Nagios NRPE Plugins [RedHat] 11 | yum: 12 | name: nagios-plugins-all 13 | state: present 14 | notify: restart nagios-nrpe-server 15 | -------------------------------------------------------------------------------- /tasks/packages-Solaris.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure CSWpkgutil is installed 3 | svr4pkg: 4 | src: http://get.opencsw.org/now 5 | name: CSWpkgutil 6 | state: present 7 | 8 | # pkgutil module does not actually provide full path to pkgutil -- 9 | # until that changes, it's necessary to make sure that /opt/csw/bin 10 | # is included in path: 11 | # Nagios NRPE Server for Solaris 12 | - name: Install Nagios NRPE Server [Solaris] 13 | pkgutil: 14 | name: CSWnrpe 15 | state: present 16 | environment: 17 | PATH: "{{ ansible_env.PATH }}:/opt/csw/bin" 18 | 19 | # Nagios Plugins 20 | - name: Install Nagios NRPE Plugins [Solaris] 21 | pkgutil: 22 | name: "CSWnrpe-plugin" 23 | state: present 24 | environment: 25 | PATH: "{{ ansible_env.PATH }}:/opt/csw/bin" 26 | notify: restart nagios-nrpe-server 27 | -------------------------------------------------------------------------------- /tasks/variables.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Variable configuration. 3 | - name: Include OS-specific variables. 4 | include_vars: "{{ ansible_os_family }}.yml" 5 | 6 | - name: Include OS-specific variables (RedHat). 7 | include_vars: "{{ ansible_os_family }}-{{ ansible_architecture }}.yml" 8 | when: ansible_os_family == 'RedHat' 9 | 10 | - name: Set defaults for OS-specific variables 11 | set_fact: 12 | nagios_nrpe_server_pid: "{{ nagios_nrpe_server_pid | default(__nagios_nrpe_server_pid) }}" 13 | nagios_nrpe_server_user: "{{ nagios_nrpe_server_user | default(__nagios_nrpe_server_user) }}" 14 | nagios_nrpe_server_group: "{{ nagios_nrpe_server_group | default(__nagios_nrpe_server_group) }}" 15 | nagios_nrpe_server_service: "{{ nagios_nrpe_server_service | default(__nagios_nrpe_server_service) }}" 16 | nagios_nrpe_server_plugins_dir: "{{ nagios_nrpe_server_plugins_dir | default(__nagios_nrpe_server_plugins_dir) }}" 17 | nagios_nrpe_server_dir: "{{ nagios_nrpe_server_dir | default(__nagios_nrpe_server_dir) }}" 18 | -------------------------------------------------------------------------------- /templates/nrpe.cfg.j2: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # Sample NRPE Config File 3 | # Written by: Ethan Galstad (nagios@nagios.org) 4 | # 5 | # Last Modified: 11-23-2007 6 | # 7 | # NOTES: 8 | # This is a sample configuration file for the NRPE daemon. It needs to be 9 | # located on the remote host that is running the NRPE daemon, not the host 10 | # from which the check_nrpe client is being executed. 11 | ############################################################################# 12 | 13 | # LOG FACILITY 14 | # The syslog facility that should be used for logging purposes. 15 | 16 | log_facility=daemon 17 | 18 | # PID FILE 19 | # The name of the file in which the NRPE daemon should write it's process ID 20 | # number. The file is only written if the NRPE daemon is started by the root 21 | # user and is running in standalone mode. 22 | 23 | pid_file={{ nagios_nrpe_server_pid }} 24 | 25 | # PORT NUMBER 26 | # Port number we should wait for connections on. 27 | # NOTE: This must be a non-priviledged port (i.e. > 1024). 28 | # NOTE: This option is ignored if NRPE is running under either inetd or xinetd 29 | 30 | server_port={{ nagios_nrpe_server_port }} 31 | 32 | # SERVER ADDRESS 33 | # Address that nrpe should bind to in case there are more than one interface 34 | # and you do not want nrpe to bind on all interfaces. 35 | # NOTE: This option is ignored if NRPE is running under either inetd or xinetd 36 | 37 | server_address={{ nagios_nrpe_server_bind_address }} 38 | 39 | # NRPE USER 40 | # This determines the effective user that the NRPE daemon should run as. 41 | # You can either supply a username or a UID. 42 | # 43 | # NOTE: This option is ignored if NRPE is running under either inetd or xinetd 44 | 45 | nrpe_user={{ nagios_nrpe_server_user }} 46 | 47 | # NRPE GROUP 48 | # This determines the effective group that the NRPE daemon should run as. 49 | # You can either supply a group name or a GID. 50 | # 51 | # NOTE: This option is ignored if NRPE is running under either inetd or xinetd 52 | 53 | nrpe_group={{ nagios_nrpe_server_group }} 54 | 55 | # ALLOWED HOST ADDRESSES 56 | # This is an optional comma-delimited list of IP address or hostnames 57 | # that are allowed to talk to the NRPE daemon. Network addresses with a bit mask 58 | # (i.e. 192.168.1.0/24) are also supported. Hostname wildcards are not currently 59 | # supported. 60 | # 61 | # Note: The daemon only does rudimentary checking of the client's IP 62 | # address. I would highly recommend adding entries in your /etc/hosts.allow 63 | # file to allow only the specified host to connect to the port 64 | # you are running this daemon on. 65 | # 66 | # NOTE: This option is ignored if NRPE is running under either inetd or xinetd 67 | 68 | allowed_hosts={{ nagios_nrpe_server_allowed_hosts|join(',') }} 69 | 70 | # COMMAND ARGUMENT PROCESSING 71 | # This option determines whether or not the NRPE daemon will allow clients 72 | # to specify arguments to commands that are executed. This option only works 73 | # if the daemon was configured with the --enable-command-args configure script 74 | # option. 75 | # 76 | # *** ENABLING THIS OPTION IS A SECURITY RISK! *** 77 | # Read the SECURITY file for information on some of the security implications 78 | # of enabling this variable. 79 | # 80 | # Values: 0=do not allow arguments, 1=allow command arguments 81 | 82 | dont_blame_nrpe={{ nagios_nrpe_server_dont_blame_nrpe }} 83 | 84 | # BASH COMMAND SUBTITUTION 85 | # This option determines whether or not the NRPE daemon will allow clients 86 | # to specify arguments that contain bash command substitutions of the form 87 | # $(...). This option only works if the daemon was configured with both 88 | # the --enable-command-args and --enable-bash-command-substitution configure 89 | # script options. 90 | # 91 | # *** ENABLING THIS OPTION IS A HIGH SECURITY RISK! *** 92 | # Read the SECURITY file for information on some of the security implications 93 | # of enabling this variable. 94 | # 95 | # Values: 0=do not allow bash command substitutions, 96 | # 1=allow bash command substitutions 97 | 98 | allow_bash_command_substitution=0 99 | 100 | # COMMAND PREFIX 101 | # This option allows you to prefix all commands with a user-defined string. 102 | # A space is automatically added between the specified prefix string and the 103 | # command line from the command definition. 104 | # 105 | # *** THIS EXAMPLE MAY POSE A POTENTIAL SECURITY RISK, SO USE WITH CAUTION! *** 106 | # Usage scenario: 107 | # Execute restricted commmands using sudo. For this to work, you need to add 108 | # the nagios user to your /etc/sudoers. An example entry for alllowing 109 | # execution of the plugins from might be: 110 | # 111 | # nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/ 112 | # 113 | # This lets the nagios user run all commands in that directory (and only them) 114 | # without asking for a password. If you do this, make sure you don't give 115 | # random users write access to that directory or its contents! 116 | 117 | # command_prefix=/usr/bin/sudo 118 | 119 | # DEBUGGING OPTION 120 | # This option determines whether or not debugging messages are logged to the 121 | # syslog facility. 122 | # Values: 0=debugging off, 1=debugging on 123 | 124 | debug=0 125 | 126 | # COMMAND TIMEOUT 127 | # This specifies the maximum number of seconds that the NRPE daemon will 128 | # allow plugins to finish executing before killing them off. 129 | 130 | command_timeout=60 131 | 132 | # CONNECTION TIMEOUT 133 | # This specifies the maximum number of seconds that the NRPE daemon will 134 | # wait for a connection to be established before exiting. This is sometimes 135 | # seen where a network problem stops the SSL being established even though 136 | # all network sessions are connected. This causes the nrpe daemons to 137 | # accumulate, eating system resources. Do not set this too low. 138 | 139 | connection_timeout=300 140 | 141 | # WEEK RANDOM SEED OPTION 142 | # This directive allows you to use SSL even if your system does not have 143 | # a /dev/random or /dev/urandom (on purpose or because the necessary patches 144 | # were not applied). The random number generator will be seeded from a file 145 | # which is either a file pointed to by the environment valiable $RANDFILE 146 | # or $HOME/.rnd. If neither exists, the pseudo random number generator will 147 | # be initialized and a warning will be issued. 148 | # Values: 0=only seed from /dev/[u]random, 1=also seed from weak randomness 149 | 150 | #allow_weak_random_seed=1 151 | 152 | # INCLUDE CONFIG FILE 153 | # This directive allows you to include definitions from an external config file. 154 | 155 | #include= 156 | 157 | # INCLUDE CONFIG DIRECTORY 158 | # This directive allows you to include definitions from config files (with a 159 | # .cfg extension) in one or more directories (with recursion). 160 | 161 | #include_dir= 162 | #include_dir= 163 | 164 | # COMMAND DEFINITIONS 165 | # Command definitions that this daemon will run. Definitions 166 | # are in the following format: 167 | # 168 | # command[]= 169 | # 170 | # When the daemon receives a request to return the results of 171 | # it will execute the command specified by the argument. 172 | # 173 | # Unlike Nagios, the command line cannot contain macros - it must be 174 | # typed exactly as it should be executed. 175 | # 176 | # Note: Any plugins that are used in the command lines must reside 177 | # on the machine that this daemon is running on! The examples below 178 | # assume that you have plugins installed in a /usr/local/nagios/libexec 179 | # directory. Also note that you will have to modify the definitions below 180 | # to match the argument format the plugins expect. Remember, these are 181 | # examples only! 182 | 183 | # The following examples use hardcoded command arguments... 184 | 185 | #command[check_users]={{ nagios_nrpe_server_plugins_dir }}/check_users -w 5 -c 10 186 | #command[check_load]={{ nagios_nrpe_server_plugins_dir }}/check_load -w 15,10,5 -c 30,25,20 187 | #command[check_hda1]={{ nagios_nrpe_server_plugins_dir }}/check_disk -w 20% -c 10% -p /dev/hda1 188 | #command[check_zombie_procs]={{ nagios_nrpe_server_plugins_dir }}/check_procs -w 5 -c 10 -s Z 189 | #command[check_total_procs]={{ nagios_nrpe_server_plugins_dir }}/check_procs -w 150 -c 200 190 | 191 | # The following examples allow user-supplied arguments and can 192 | # only be used if the NRPE daemon was compiled with support for 193 | # command arguments *AND* the dont_blame_nrpe directive in this 194 | # config file is set to '1'. This poses a potential security risk, so 195 | # make sure you read the SECURITY file before doing this. 196 | 197 | #command[check_users]={{ nagios_nrpe_server_plugins_dir }}/check_users -w $ARG1$ -c $ARG2$ 198 | #command[check_load]={{ nagios_nrpe_server_plugins_dir }}/check_load -w $ARG1$ -c $ARG2$ 199 | #command[check_disk]={{ nagios_nrpe_server_plugins_dir }}/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ 200 | #command[check_procs]={{ nagios_nrpe_server_plugins_dir }}/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$ 201 | 202 | {% if 'ansible_os_family' != 'Archlinux' %} 203 | # 204 | # local configuration: 205 | # if you'd prefer, you can instead place directives here 206 | include={{ nagios_nrpe_server_dir }}/nrpe_local.cfg 207 | {% endif %} 208 | include={{ nagios_nrpe_server_dir }}/nrpe_ansible.cfg 209 | 210 | {% if 'ansible_os_family' != 'Archlinux' %} 211 | # 212 | # you can place your config snipplets into nrpe.d/ 213 | # only snipplets ending in .cfg will get included 214 | include_dir={{ nagios_nrpe_server_dir }}/nrpe.d/ 215 | {% endif %} 216 | -------------------------------------------------------------------------------- /templates/nrpe_ansible.cfg.j2: -------------------------------------------------------------------------------- 1 | # {{ ansible_managed }} 2 | 3 | # Command NRPE 4 | {% if nagios_nrpe_command is defined %} 5 | {% for command in nagios_nrpe_command %} 6 | command[{{ command }}]={{ nagios_nrpe_server_plugins_dir }}/{{ nagios_nrpe_command[command]["script"] | default('check_' + command) }} {{ nagios_nrpe_command[command]["option"] | default() }} 7 | {% endfor %} 8 | {% endif %} 9 | -------------------------------------------------------------------------------- /vars/Archlinux.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Arhclinux based OS variables 3 | 4 | __nagios_nrpe_server_pid: /var/run/nrpe/nrpe.pid 5 | __nagios_nrpe_server_user: 31 6 | __nagios_nrpe_server_group: 31 7 | __nagios_nrpe_server_service: nrpe 8 | __nagios_nrpe_server_plugins_dir: /usr/lib/monitoring-plugins 9 | __nagios_nrpe_server_dir: /etc/nrpe 10 | -------------------------------------------------------------------------------- /vars/Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Debain based OS variables 3 | # We're required to do this as the user/group NRPE is run under 4 | # differes between RedHat/Debian OS's 5 | 6 | __nagios_nrpe_server_pid: /var/run/nagios/nrpe.pid 7 | __nagios_nrpe_server_user: nagios 8 | __nagios_nrpe_server_group: nagios 9 | __nagios_nrpe_server_service: nagios-nrpe-server 10 | __nagios_nrpe_server_plugins_dir: /usr/lib/nagios/plugins 11 | __nagios_nrpe_server_dir: /etc/nagios 12 | -------------------------------------------------------------------------------- /vars/RedHat-aarch64.yml: -------------------------------------------------------------------------------- 1 | __nagios_nrpe_server_plugins_dir: /usr/lib64/nagios/plugins 2 | -------------------------------------------------------------------------------- /vars/RedHat-i386.yml: -------------------------------------------------------------------------------- 1 | __nagios_nrpe_server_plugins_dir: /usr/lib/nagios/plugins 2 | -------------------------------------------------------------------------------- /vars/RedHat-x86_64.yml: -------------------------------------------------------------------------------- 1 | __nagios_nrpe_server_plugins_dir: /usr/lib64/nagios/plugins 2 | -------------------------------------------------------------------------------- /vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # RedHat based OS variables 3 | # We're required to do this as the user/group NRPE is run under 4 | # differes between RedHat/Debian OS's 5 | 6 | __nagios_nrpe_server_pid: /var/run/nrpe/nrpe.pid 7 | __nagios_nrpe_server_user: nrpe 8 | __nagios_nrpe_server_group: nrpe 9 | __nagios_nrpe_server_service: nrpe 10 | __nagios_nrpe_server_dir: /etc/nagios 11 | -------------------------------------------------------------------------------- /vars/Solaris.yml: -------------------------------------------------------------------------------- 1 | __nagios_nrpe_server_dir: /etc/opt/csw 2 | __nagios_nrpe_server_group: nagios 3 | __nagios_nrpe_server_pid: /var/run/nrpe.pid 4 | __nagios_nrpe_server_plugins_dir: /opt/csw/libexec/nagios-plugins 5 | __nagios_nrpe_server_service: svc:/network/cswnrpe:default 6 | __nagios_nrpe_server_user: nagios 7 | --------------------------------------------------------------------------------