Icinga is a great monitoring solution, especially when you use director module to perform configuration in top down environment. It makes application more accessible to more people as you can use web-interface and role based permissions to allow developers and testers to write and use their own checks and notifications.

Install git.

$ sudo apt-get install git

Create database user and password for Director module.

$ sudo -u postgres psql -c "CREATE ROLE icinga_director WITH LOGIN PASSWORD 'icinga_director_pwd'"
$ sudo -u postgres createdb -O icinga_director -E UTF8 icinga_director
$ sudo -u postgres psql -c "CREATE EXTENSION pgcrypto"

Configure database authentication for created user.

$ cat << EOF | sudo tee -a /etc/postgresql/9.6/main/pg_hba.conf
# icinga_director
host    icinga_director      icinga_director      127.0.0.1/32          md5
EOF

Reload PostgreSQL server configuration.

$ sudo -u postgres psql -c "SELECT pg_reload_conf()"

Clone latest release (tag v1.4.1 at this moment) of the icingaweb2-module-director to the modules directory.

$ sudo git clone --branch v1.4.1 --depth=1 https://github.com/Icinga/icingaweb2-module-director /usr/share/icingaweb2/modules/director

You can use web-browser to continue setup process, but I prefer to use terminal.

Create database resource.

$ cat << EOF | sudo tee -a /etc/icingaweb2/resources.ini

[icinga_director]
type = "db"
db = "pgsql"
host = "localhost"
port = "5432"
dbname = "icinga_director"
username = "icinga_director"
password = "icinga_director_pwd"
charset = "UTF-8"
persistent = "0"
EOF

Create configuration directory and set proper permissions.

$ sudo mkdir /etc/icingaweb2/modules/director/
$ sudo chown www-data:icingaweb2 /etc/icingaweb2/modules/director
$ sudo chmod 2770 /etc/icingaweb2/modules/director

Create initial configuration.

$ cat << EOF | sudo tee -a /etc/icingaweb2/modules/director/config.ini
[db]
resource = icinga_director
EOF

Set proper permissions.

$ sudo chown www-data:icingaweb2 /etc/icingaweb2/modules/director/config.ini
$ sudo chmod 660 /etc/icingaweb2/modules/director/config.ini

Define kickstart configuration (API access).

$ cat << EOF | sudo tee -a /etc/icingaweb2/modules/director/kickstart.ini
[config]
endpoint = icinga.example.org
; host = 127.0.0.1
; port = 5665
username = root
password = f40b1360f3a35988
EOF

Set proper permissions.

$ sudo chown www-data:icingaweb2 /etc/icingaweb2/modules/director/kickstart.ini
$ sudo chmod 660 /etc/icingaweb2/modules/director/kickstart.ini

Edit zones.conf file to add missing director-global zone.

$ grep --quiet director-global /etc/icinga2/zones.conf || cat << EOF | sudo tee -a /etc/icinga2/zones.conf
object Zone "director-global" {
  global = true
}
EOF

Restart icinga2 service.

$ sudo systemctl restart icinga2

Enable director module.

$ sudo icingacli module enable director

Execute database migration.

$ sudo icingacli director migration run

Confirm that that there are no pending migrations.

$ sudo icingacli director migration pending --verbose
There are no pending migrations

Kickstart configuration.

$ sudo icingacli director kickstart run

Confirm that you do not need to trigger the kickstart helper.

$ sudo icingacli director kickstart required --verbose
Kickstart configured, execution is not required

Deploy the current configuration.

$ sudo icingacli director config deploy 
Config '27b6a5d329b75cda2ce6340f59cf271fbc45abdc' has been deployed

Restart icinga2 service.

$ sudo systemctl restart icinga2

Create systemd unit file.

$ cat << EOF | sudo tee /etc/systemd/system/director-jobs.service
[Unit]
Description=Director Job runner

[Service]
Type=simple
ExecStart=/usr/bin/icingacli director jobs run forever
Restart=on-success
EOF

Reload systemd manager configuration.

$ sudo systemctl daemon-reload

Enable automount service at boot time.

$ sudo systemctl enable director-jobs

Start director-jobs service right away.

$ sudo systemctl start director-jobs

Issues

Missing director-global zone can be identified by the following error.

Attribute 'zone': Object 'director-global' of type 'Zone' does not exist.

Additional information

ko-fi