From 65d8adc94ee1e9b0129b26e4ef5bb6587dfa5035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <remi@le-filament.com> Date: Mon, 2 Aug 2021 10:31:02 +0200 Subject: [PATCH] [IMP] add list of webhooks to be triggered daily --- README.md | 2 +- defaults/main.yml | 9 +++++++-- templates/commands.cfg.j2 | 4 ++-- templates/localhost.cfg.j2 | 6 ++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 18258d0..c35dc67 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Variables from default directory : * nagios_url: URL on which Nagios will be listening * win_srv_ip: IP address of Windows server * win_b2b_url: URL for B2B exchange server -* docker_hub_uri: URI of DockerHub to trigger build of images daily +* webhooks_to_be_called_daily: list of WebHooks to be called daily * services_to_be_monitored: list of extra services to be monitored Variables used on other hosts for monitoring : diff --git a/defaults/main.yml b/defaults/main.yml index 87b71de..d487c0a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,8 +6,13 @@ nagios_url: "nagios.example.org" win_srv_ip: 10.12.12.12 win_b2b_url: b2b.example.org -# Docker Hub URI -docker_hub_uri: /api/build/v1/source/test/trigger/test2/call/ +# Webhooks to be triggered daily +webhooks_to_be_called_daily: + - name: Docker Odoo + url: gitlab.example.org + uri: "/api/v4/projects/xx/ref/REF_NAME/trigger/pipeline?token=TOKEN" + +# List of external services to be monitored services_to_be_monitored: - name: Webmail period: generic diff --git a/templates/commands.cfg.j2 b/templates/commands.cfg.j2 index cac0120..cd57198 100644 --- a/templates/commands.cfg.j2 +++ b/templates/commands.cfg.j2 @@ -80,9 +80,9 @@ define command { command_line $USER1$/check_nrpe -2 -H $HOSTADDRESS$ -c $ARG1$ $ARG2$ } -# trigger_docker_hub +# trigger_webhook define command { - command_name trigger_docker_hub + command_name trigger_webhook command_line $USER1$/check_http -H $ARG1$ -S -u $ARG2$ -j POST } diff --git a/templates/localhost.cfg.j2 b/templates/localhost.cfg.j2 index ef1254b..343e9fb 100644 --- a/templates/localhost.cfg.j2 +++ b/templates/localhost.cfg.j2 @@ -44,13 +44,15 @@ define service{ check_command check_local_procs!20!2:!nagios } +{% for webhook in webhooks_to_be_called_daily %} define service{ use daily-service host_name Nagios Server - service_description Trigger Build Odoo Images - check_command trigger_docker_hub!hub.docker.com!{{ docker_hub_uri }} + service_description WebHook {{ webhook.name }} + check_command trigger_webhook!{{ webhook.url }}!{{ webhook.uri }} } +{% endfor %} {% for service in services_to_be_monitored %} define service{ use {{ service.period }}-service -- GitLab