sadsfae.ansible_nagios

ansible-nagios

This is a playbook for installing and setting up the Nagios monitoring server and clients on CentOS, Rocky, RHEL, Fedora, and FreeBSD.

Nagios

GA

What does it do?

  • Automatically installs Nagios Server on CentOS7, Rocky 8/9, or RHEL 7/8/9.
  • Installs the Nagios client on various systems like CentOS, RHEL, Rocky, Fedora, and FreeBSD.
    • Creates service checks based on your hosts listed in Ansible inventory.
    • Sets up checks for the Nagios server itself.
    • Monitors all hosts/services via NRPE.
    • Uses jinja2 templates for most configurations.
    • Wraps Nagios in SSL using Apache.
    • Configures firewall rules.
    • Sends alerts via email and webhooks.
    • Available on Ansible Galaxy.

How do I use it?

  • Specify your Nagios server in the [nagios] section of the hosts inventory.
  • Add respective services and hosts in their inventory group; remember, a host can belong to only one group.
  • Modify settings like email addresses and users in install/group_vars/all.yml.
  • Run the playbook described below.

Requirements

  • Nagios server needs CentOS7 or RHEL7/8/9 or Rocky 8/9.
  • For the NRPE client, use RHEL6/7/8/9, CentOS6/7/8/9, Fedora, or FreeBSD.
  • For SuperMicro monitoring via IPMI (optional):
    • Install perl-IPC-Run and perl-IO-Tty RPMs for RHEL7.
    • Update install/group_vars/all.yml to set supermicro_enable_checks: true.
  • IPMI sensor monitoring might be removed due to reliability issues; SNMP is better.

Notes

  • The default nagiosadmin password is changeme; change it to something secure.
  • A read-only user is created, set nagios_create_guest_user: false to disable this.
  • Adjust firewall rules management via install/group_vars/all.yml.
  • Adding new hosts regenerates the Nagios configs.

Supported Service Checks

  • Easy implementation with checks for:
    • Basic interfaces (ping, ssh, http).
    • Linux server health (load, users, uptime, disk space).
    • ELK servers, webservers (with SSL checks), DNS servers.
    • Jenkins and FreeNAS checks.
    • IoT devices, network switches, and Dell iDRAC health checks.
  • Notification settings are in install/group_vars/all.yml.

Nagios Server Instructions

  • Clone the repo and set up your Ansible inventory file:
git clone https://github.com/sadsfae/ansible-nagios
cd ansible-nagios
sed -i 's/host-01/yournagioshost/' hosts
  • Add hosts for monitoring in the hosts inventory.
  • Ensure hosts belong to only one category.
  • For special hosts (like IDRAC), provide only IP addresses.
  • For others, use FQDN.

Run the playbook:

ansible-playbook -i hosts install/nagios.yml
  • Access the server via https://yourhost/nagios.
  • Default login is nagiosadmin / changeme.

Known Issues

  • For non-root users, you'll need to set ansible_system_user: ec2-user in install/group_vars/all.yml.
  • SELinux might cause issues; if Nagios doesn't start, create an SELinux policy module:
# cat /var/log/audit/audit.log | audit2allow -M mynagios
# semodule -i mynagios.pp

Then restart Nagios and Apache:

systemctl restart nagios
systemctl restart httpd

If needed, switch SELinux to permissive until it's working:

setenforce 1
  • For RHEL7 errors, install extra Perl packages if using SuperMicro monitoring.

Mass-generating Ansible Inventory

If managing with QUADS, generate iDRAC or OOB interfaces with:

quads-cli --ls-hosts | sed -e 's/^/mgmt-/g' > /tmp/all_ipmi_2019-10-23
for ipmi in $(cat all_ipmi_2019-10-23); do printf $ipmi ; echo " ansible_host=$(host $ipmi | awk '{print $NF}')"; done > /tmp/add_oobserver

Paste /tmp/add_oobserver into your Ansible inventory.

Demonstration

Watch a video demonstration of the deployment here:

Ansible Nagios

iDRAC Server Health Details

Choose which iDRAC health checks to monitor, with detailed health information provided.

CHECK iDRAC

Files Overview

.
├── hosts
├── install
│   ├── group_vars
│   │   └── all.yml
│   ├── nagios.yml
│   └── roles
│       ├── firewall
│       │   └── tasks
│       │       └── main.yml
│       ├── firewall_client
│       │   └── tasks
│       │       └── main.yml
│       ├── instructions
│       │   └── tasks
│       │       └── main.yml
│       ├── nagios
│       │   ├── files
│       │   ├── handlers
│       │   ├── tasks
│       │   └── templates
│       └── nagios_client
│           ├── files
│           ├── handlers
│           ├── tasks
│           └── templates
├── meta
│   └── main.yml
└── tests
    └── test-requirements.txt

Total: 21 directories, 43 files.

Informazioni sul progetto

Playbook for setting up the Nagios monitoring server and clients.

Installa
ansible-galaxy install sadsfae.ansible_nagios
Licenza
apache-2.0
Download
441
Proprietario
hobo devop/sysadmin/SRE