From 885588910a7a8d75cbead7cb21e2ca3206b0d3d3 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sat, 5 Feb 2022 15:17:45 +0100 Subject: [PATCH] wip --- bundles/icinga2/files/ido-pgsql.conf | 8 ++++ bundles/icinga2/items.py | 54 +++++++++++++++++++++++++++ bundles/icinga2/metadata.py | 44 ++++++++++++++++++++++ data/apt/keys/packages.icinga.com.asc | 30 +++++++++++++++ nodes/home.server.py | 2 +- 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 bundles/icinga2/files/ido-pgsql.conf create mode 100644 bundles/icinga2/items.py create mode 100644 bundles/icinga2/metadata.py create mode 100644 data/apt/keys/packages.icinga.com.asc diff --git a/bundles/icinga2/files/ido-pgsql.conf b/bundles/icinga2/files/ido-pgsql.conf new file mode 100644 index 0000000..bbdf288 --- /dev/null +++ b/bundles/icinga2/files/ido-pgsql.conf @@ -0,0 +1,8 @@ +library "db_ido_pgsql" + +object IdoPgsqlConnection "ido-pgsql" { + user = "icinga2", + password = "${db_password}", + host = "localhost", + database = "icinga2" +} diff --git a/bundles/icinga2/items.py b/bundles/icinga2/items.py new file mode 100644 index 0000000..1cad764 --- /dev/null +++ b/bundles/icinga2/items.py @@ -0,0 +1,54 @@ +# Git-Hash for Icinga1: b63bb0ef52bf213715e567c81e3ed097024e61af + +from json import load +from os.path import join + +ICINGA_PLUGINS = { +} + +ENABLED_FEATURES = [ + 'ido-pgsql', + 'notification', +] +for feature in ENABLED_FEATURES: + symlinks[f'/etc/icinga2/features-enabled/{feature}.conf'] = { + 'target': f'/etc/icinga2/features-available/{feature}.conf', + 'owner': 'nagios', + 'group': 'nagios', + 'needs': [ + 'pkg_apt:icinga2-ido-pgsql', + ], + 'triggers': [ + 'svc_systemd:icinga2:restart', + ], + } + +svc_systemd = { + 'icinga2': { + 'needs': [ + 'pkg_apt:icinga2-ido-pgsql', + 'svc_systemd:postgresql', + ], + }, +} + +directories = { + '/etc/icinga2/features-enabled': { + 'purge': True, + }, +} + +files = { + '/etc/icinga2/features-available/ido-pgsql.conf': { + 'source': 'ido-pgsql.conf', + 'content_type': 'mako', + 'context': { + 'db_password': node.metadata.get('postgresql/roles/icinga2/password') + }, + 'owner': 'nagios', + 'group': 'nagios', + 'needs': [ + 'pkg_apt:icinga2-ido-pgsql', + ], + }, +} diff --git a/bundles/icinga2/metadata.py b/bundles/icinga2/metadata.py new file mode 100644 index 0000000..c988f7a --- /dev/null +++ b/bundles/icinga2/metadata.py @@ -0,0 +1,44 @@ +defaults = { + 'apt': { + 'packages': { + 'icinga2': {}, + 'icingaweb2': {}, + 'icinga2-ido-pgsql': {}, + 'icingacli': {}, + 'monitoring-plugins': {}, + }, + 'sources': { + 'deb https://packages.icinga.com/debian icinga-{release} main', + }, + }, + 'postgresql': { + 'databases': { + 'icinga2': { + 'owner': 'icinga2', + }, + 'icingaweb2': { + 'owner': 'icingaweb2', + }, + }, + 'roles': { + 'icinga2': { + 'password': repo.vault.password_for(f'psql icinga2 on {node.name}'), + }, + 'icingaweb2': { + 'password': repo.vault.password_for(f'psql icingaweb2 on {node.name}'), + }, + }, + }, + 'zfs': { + 'datasets': { + 'tank/icinga2': { + 'mountpoint': '/var/lib/icinga2', + 'needed_by': { + 'pkg_apt:icinga2', + 'pkg_apt:icingaweb2', + 'pkg_apt:icinga2-ido-pgsql', + }, + }, + }, + }, +} diff --git a/data/apt/keys/packages.icinga.com.asc b/data/apt/keys/packages.icinga.com.asc new file mode 100644 index 0000000..901c78c --- /dev/null +++ b/data/apt/keys/packages.icinga.com.asc @@ -0,0 +1,30 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v2.0.19 (GNU/Linux) + +mQGiBFKHzk4RBACSHMIFTtfw4ZsNKAA03Gf5t7ovsKWnS7kcMYleAidypqhOmkGg +0petiYsMPYT+MOepCJFGNzwQwJhZrdLUxxMSWay4Xj0ArgpD9vbvU+gj8Tb02l+x +SqNGP8jXMV5UnK4gZsrYGLUPvx47uNNYRIRJAGOP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MI7izCPDcD32B5oxNVxlfj428KGllYWCFj+edY+xKTvw/PHnn+drKs +LE65Gwx4BPHm9EqWHIBX6aPzbgbJZZ06f6jWVBi/N7e/5n8lkxXqS23DBKemapyu +S1i56sH7mQSMaRZP/iiOroAJemPNxv1IQkykxw2woWMmTLKLMCD/i+4DxejE50tK +dxaOLTc4HDCsattw/RVJO6fwE414IXHMv330z4HKWJevMQ+CmQGfswvCwgeBP9n8 +PItLjBQAXIhJBBgRAgAJBQJSh85OAhsMAAoJEMbjGcM0QQaCzpAAmwUNoRyySf9p +5G3/2UD1PMueIwOtAKDVVDXEq5LJPVg4iafNu0SRMwgP0Q== +=icbY +-----END PGP PUBLIC KEY BLOCK----- diff --git a/nodes/home.server.py b/nodes/home.server.py index 5fbf9b0..a1ca3e1 100644 --- a/nodes/home.server.py +++ b/nodes/home.server.py @@ -18,7 +18,7 @@ 'gitea', # 'gollum', 'grafana', - 'grub', + 'icinga2', 'influxdb2', 'mirror', 'postgresql',