dorancemc.ansible_nagioscore
Nagios Core
=========
This guide helps you deploy Nagios Core.
Requirements
No specific requirements.
Role Variables
- Objects are defined in YAML files and turned into configuration files using templates.
- Check the default/main folder for more details on variables.
- OS-specific variables are in the vars/ folder.
- Update the values in the
vars.yamlfile and encrypt it. - To change variable data, copy the
nagiosfolder from the main folder to your local inventory folder, ideally undergroup_vars/orhost_vars/.
- Hosts and Services
You can define hosts and services in a single variable or in separate files.
Look at
localhost.yamlfor an example of how to define new hosts.Copy the
files/nagiosfolder to your preferred location.You can create individual files for each host to define their services. Create the folder and update the variable to specify the file path like this:
# nagios_hosts_path: inventory/nagios_hostsIn the inventory folder, create a file with this structure:
_host:
host_name: hostname #required
address: 192.168.0.1 # if not defined, it will use the hostname
alias: Server Description
use: template # if not defined, the default template is used
_services:
servicename: servicecommand!arguments # uses 'nagios_service_template_default' as the default template
servicename-other:
use: service_template
check_command: servicecommand!arguments!arguments # syntax: <command_name>!$ARG1$!$ARG2$
# Refer to commands.yaml to validate service commands and parameters
- Define hostgroups and servicegroups using the
nagios_hostgroupsandnagios_servicegroupsvariables, and specify if hosts and services belong to them.
- Contacts
- Check
contacts.yamlfor details on contacts. - To delete a user from the
httpasswdfile, addstate: absentin the contact definition. This will remove the user from both the contact list and thehtpasswdfile.
- Contact Groups
- Contact groups simplify notification management. If a contact group is assigned to a host, all services under that host inherit this group. You can also assign a separate contact group for each service.
Dependencies
None
Example Playbook
- Define your Nagios group and include all your Nagios servers:
[nagios]
nagios.example.com ansible_host=192.168.243.220
- Add the following to your main playbook:
- hosts: nagios
roles:
- { role: dorancemc.ansible-nagioscore, tags: [ nagioscore ] }
- Run your playbook to apply the role:
ansible-playbook --limit ubuntu playbook.yaml --tags nagioscore
- If you only want to apply the configuration, use the
nagios_configtag:
ansible-playbook --limit ubuntu playbook.yaml --tags nagios_config
Grafana
This deployment supports integration with Grafana. After deploying, you can install Grafana manually and follow the instructions for integration here:
Integration Instructions
Alternatively, use the Ansible recipe and set these variables for integration:
Ansible Grafana Repository
grafana_plugins:
- sni-pnp-datasource
grafana_datasources:
- name: PNP
type: sni-pnp-datasource
isDefault: true
access: proxy
url: 'http://127.0.0.1/pnp4nagios/'
basicAuth: false
License
BSD
Author Information
Dorance Martinez @dorancemc
Role to install Nagios Core and run hosts configuration
ansible-galaxy install dorancemc.ansible_nagioscore