Git Product home page Git Product logo

ansible-nagios-1's Introduction

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.

ansible-nagios-1's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.