CoffeeITWorks.ansible_nagios4_server_config
Build Status
Role Name
This role configures Nagios and syncs its configuration from Git repositories. It works well with other Ansible Coffee Nagios role plugins, the Thruk interface, PNP4Nagios, and more.
Requirements
No specific requirements, but ensure your system is updated. Currently, it's only tested on Ubuntu 14.04.
Supported Role Distribution
- Ubuntu: Yes
- RedHat: Not ready
Role Variables
You can find all variables in defaults/main.yml.
Add the following to your host_vars
or group_vars
:
Extra Nagios Configuration Options
Add to the readonly list:
nagios_cgi_authorized_for_read_only: user1, user2
Or adjust the permissions:
nagios_cgi_authorized_for_system_information: nagiosadmin
nagios_cgi_authorized_for_configuration_information: nagiosadmin
nagios_cgi_authorized_for_system_commands: nagiosadmin
nagios_cgi_authorized_for_all_services: nagiosadmin,user1,user2
nagios_cgi_authorized_for_all_hosts: nagiosadmin,user1,user2
nagios_cgi_authorized_for_all_service_commands: nagiosadmin
nagios_cgi_authorized_for_all_host_commands: nagiosadmin
To disable notifications on specific hosts, use host_vars/hostname
:
nagios_config_enable_notifications: 0
Clone Repositories Feature
You can set up Git repositories to clone configurations into specific directories. For example:
- Network Repository: directory "net"
- Servers Repository: directory "servers"
- Server Services Repository: directory "services"
You can mix these configurations for different hosts, such as remote hosts or testing servers with a separate repository. To sync all servers when updating, use the tag config_nagios
in your Ansible playbook.
For automatic synchronization, consider using Jenkins Git hooks to trigger the synchronization whenever you push updates to the Nagios configuration repositories.
Example Configuration
nagios_config_cfg_dirs_git:
- { repo: "http://server/user/repo.git", version: "master", dir: "repo"}
- { repo: "http://users:password@server/user/repo2.git", version: "master", dir: "repo2"}
Using SSH Keys
You can use an SSH key for Git access. First, create a directory for keys on the remote server:
cd
mkdir keys
Then generate SSH keys and save them as nagios_key_rsa
:
nagios_config_cfg_dirs_git_rsa:
- { repo: "git@server:user/repo.git", version: "master", dir: "repo"}
When the nagios_config_cfg_dirs_git_rsa
variable is used, the role will look for the key at /home/remoteuser/keys/nagios_key_rsa
.
Dependencies
List any other roles from Galaxy that are required here, along with any parameters that might need adjusting.
Example Playbook
Complete List of Roles:
- name: Apply Nagios Settings
hosts: nagios4_servers
become: yes
become_method: sudo
roles:
- { role: nagios4_server, tags: ["install", "nagios4_server_all", "nagios4_server"] }
- { role: nagios4_server_plugins, tags: ["install", "nagios4_server_all", "nagios4_server_plugins"] }
- { role: nagios4_server_pnp4nagios, tags: ["install", "nagios4_server_all", "nagios4_server_pnp4nagios"] }
- { role: nagios4_server_snmptrap, tags: ["install", "nagios4_server_all", "nagios4_server_snmptrap"] }
- { role: ANXS.mysql, tags: ["install", "nagios4_server_all", "nagios4_server_thruk", "ANXS.mysql"] }
- { role: nagios4_server_thruk, tags: ["install", "nagios4_server_all", "nagios4_server_thruk"] }
- { role: postfix_client, tags: ["install", "nagios4_server_all", "postfix_client"] }
Tags
nagios4_server_main_config
nagios_config
config_nagios_cron
Behind Firewalls
To enable communication with firewalled hosts, open the following ports:
TCP:
- Ping: Host availability
- 5666: NRPE (for Windows and Linux)
- 1248: NSClient (Windows only)
- 9666: Custom NRPE if 5666 is in use
- 22: SSH checks
- 80, 443: HTTP and HTTPS checks
UDP:
- 161: SNMP checks
License
BSD
Author Information
Main authors are Diego Daguerre and Pablo Estigarribia. You can find more at our site.
Configure nagios, prepared to be compatible with thruk, pnp4nagios, nagios_plugins. Has feature to clone nagios config from git repos.
ansible-galaxy install CoffeeITWorks.ansible_nagios4_server_config