Skip to content

isabella232/ansible-nagios-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Role: Nagios

Installs Nagios, NRPE (both client and server), and configures Nagios automatically based on Ansible's existing inventory of hosts. The goal is to have a complete Nagios monitoring system in a single Ansible role, and without too much manual configuration required.

Prerequisites

Make sure that DNS or /etc/hosts name resolution is working. For example that you can ping web3 at web3.example.com. Email is a recommended prerequisite, with choices of Exim, Postfix, and others.

Role Variables

All the variables in the defaults/ directory may be overridden or changed.

The default ansible inventory group monitoring-servers can be customized with the nagios_monitoring_servers_group_name variable.

If the variable nagios_host_name is defined for a host this value will be used for the host_name attribute in hosts and services definitions.

Contacts/Users:

Add users who should be allowed to login to the Nagios web GUI in the nagios_users variable:
nagios_users:

Another and better way to add both nagios contacts and nagios admins is the users variable, compatible with https://github.com/mivok/ansible-users

This playbook will look for users in the sysadmin group and those will become nagios admins.

Create the users var, a good place is group_vars/all. Here is an example.

users:

  • username: foo
    name: Foo Barrington
    groups: ['sysadmin']
    uid: 1001
    ssh_key:

Where did that htpasswd value come from? Generate the htpasswds manually, and then paste them into users.
htpasswd -n mario
mario:$apr1$SheSL4Et$xry6RljdWWvUVrh42s7OA0

You must configure at minimum one sysadmin user, as just explained, or nagios contacts won't work.

Nagios Commands:

The nagios commands are in the nagios_commands variable, see defaults/main.yml. You can add more commands by adding to, or overriding, the variable.

Nagios Services:

The nagios services are currently in the "checks" per hostgroup variables, see defaults/main.yml. You can add more services by adding to, or overriding, the variable.

Nagios Custom Checks:

You can define a list of custom check scripts in the nagios_custom_checks variable. Files with these names will be templated to the nrpe_client_plugins_dir directory on the Nagios server and can be used in commands and local services definitions.

Nagios Hosts:

Ansible hosts in the 'all' group are converted to nagios monitored hosts. No configuration required.

Nagios Hostgroups:

Ansible groups are converted to nagios hostgroups. No configuration required.

Skipping Hosts and Hostgroups

The following values are set in defaults/main.yml :

nagios_hosts_ignore: ""
nagios_groups_ignore: ""

They can be overridden to include Hosts or Hostgroups that should be skipped entirely. Examples:

nagios_hosts_ignore:
  - host1_skip_this_host
nagios_groups_ignore:
  - hostgroup_dev_to_skip
  - and_this_one

This determines which hosts the nagios server will ignore/skip, because these hosts will be excluded from the configs.

Another consideration is whether the ansible playbook should run on all servers. The example playbook test.yml has "- hosts: all", which installs the nagios client on all known servers. You could adjust your top-level playbook and set a different "hosts: " directive. However it's probably fine to install the monitoring client on all servers.

Example Playbook

Refer to test.yml in the root of this role.

To install the client:
roles:
- { role: 'sdarwin.nagios', run_nagios_client: true }

To install the server:
roles:
- { role: 'sdarwin.nagios', run_nagios_server: true }

Add nagios servers to the monitoring-servers group in the Ansible inventory.

License

BSD

Author Information

By Sam Darwin, 2016. Based on pre-existing roles, see ACKNOWLEDGEMENTS.md file. Feedback and bug reports welcome.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%