From fe66cb713f4ceacf7006460eadd9742e6d003cc8 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Thu, 5 Jan 2023 20:43:49 +0100 Subject: [PATCH] feat: generate icinga2 service conf for async --- backup.py | 6 ++++ .../async-icinga-services-dynamic.conf.j2 | 33 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 templates/async-icinga-services-dynamic.conf.j2 diff --git a/backup.py b/backup.py index e1fcb4b..f0e23b9 100644 --- a/backup.py +++ b/backup.py @@ -82,3 +82,9 @@ def createBackupScriptStructure(backupList, baseDomain=""): ansibleFilename = "./ansible/files/async-icinga-config-dynamic.json" with open(ansibleFilename, "w") as f: f.write(json.dumps(asyncIcingaConf)) + + # write async icinga services in ansible # + ansibleFilename = "./ansible/files/async-icinga-services-dynamic.conf" + icingaServiceTemplate = environment.get_template("async-icinga-services-dynamic.conf.j2") + with open(ansibleFilename, "w") as f: + f.write(icingaServiceTemplate.render(asyncIcingaConf=asyncIcingaConf)) diff --git a/templates/async-icinga-services-dynamic.conf.j2 b/templates/async-icinga-services-dynamic.conf.j2 new file mode 100644 index 0000000..cf7a652 --- /dev/null +++ b/templates/async-icinga-services-dynamic.conf.j2 @@ -0,0 +1,33 @@ +object Host "AsyncIcinga" { + + import "generic-host" + + address = "localhost" + name = "async_icinga" + vars.async = "true" + vars.linux = "true" + + vars.ssl_address = "async-icinga.atlantishq.de" + vars.ssl_port = "443" + + check_command = "http" + + max_check_attempts = 5 + retry_interval = 1m + + vars.notification["mail"] = { + groups = ["icingaadmins"] + } + +} + +{% for service in asyncIcingaConf.keys() %} +apply Service "{{ service }}" { + import "generic-service" + check_command = "gateway" + vars.protocol = "https" + vars.host = "async-icinga.atlantishq.de" + vars.service_name = "{{ service }}" + assign where host.name == "async_icinga" +} +{% endfor %}