Unnamed repository; edit this file 'description' to name the repository.
Find a file
2023-04-03 18:05:29 +03:00
defaults Add custom theme 2023-03-27 11:49:35 +03:00
handlers Initial commit with previous code 2022-10-11 10:19:02 +03:00
meta Add meta 2022-10-11 10:55:06 +03:00
tasks fix path and set ownership 2023-04-03 18:05:29 +03:00
templates separate dictories 2023-03-27 12:11:40 +03:00
.gitignore Add .gitignore and readme 2022-10-21 10:02:45 +03:00
README.md fix vhostname 2022-12-08 14:00:05 +02:00

Ansible Role Nagios server (version 4)

This role install Apache2 and Nagios4 servers.

Supported distributions:

  • Ubuntu 20.04 focal

Requirements

  • Manually run httpwd to create the authentication file
  • Check the template apache_vhost.j2 for the path to SSL certificates and update it.

To-Do

  • Option to generate SSL certificate with let's encrypt

Role Variables

Check defaults/main.yml for a working example.

General variables

nagios_user: System user to run nagios nagios_group: System group of the nagios_user auth_user_file: File to store user and password with access to the web interface. nagios_admin_user: Admin user for the web interface nagios_admin_password: Admin user password

Dictionary nagios4_config

This dictionary will be read (using .items()) to generate the file /etc/nagios4/nagios.cfg so any supported Nagios4 configuration can be included

Dictionary cgi_config

This dictionary will be read (using .items()) to generate the file /etc/nagios4/cgi.cfg so any supported Nagios4 configuration can be included

List monitored_hosts

This is list of monitored hosts clients, optionally can include services specific for the host, but it's recommended to reduce this usage and include as many services as possible in the hostgroups list.

Example:

  - host_name: localhost
    use: linux-server
    alias: Server0
    address: 127.0.0.1
    services:
      - use: local-service
        description: PING
        check_command: check_ping!100.0,20%!500.0,60%

List hostgroups

This is a list of groups and their members (you have to declare the same members as hosts in monitored_hosts).

  - hostgroup_name: linux servers
    alias: Linux Servers
    members:
      - localhost
      - server1
    services:
      - service_description: 'PING'
        check_command: "check_ping!200.0,20%!500.0,60%"

Other lists

There are similar list of objects supported by Nagios like:

  • commands
  • contacts
  • templates
  • timeperiods

Apache specific virtual hosts list

The list vhosts contains at least one virtual host to configure Apache2.

  - vhostname: nagios4.example.org
    serveradmin: webmaster@example.org
    vhost_aliases: nagios.example.org
    ssl_certificate_file: "/etc/letsencrypt/live/nagios4.example.org/fullchain.pem"
    ssl_certificate_key_file: "/etc/letsencrypt/live/nagios4.example.org/privkey.pem"
    ssl_certificate_chain_file: "/usr/local/apache2/conf/ssl/ca_bundle.crt" # optional

Dependencies

None

License

GPLv3

Author Information

This role was created in 2022 by Antonio J. Delgado (ajdelgado).