From a1befa9968dc879d762a59d3d6d6bfb2329d53b3 Mon Sep 17 00:00:00 2001 From: Zolfa Date: Thu, 7 May 2020 00:26:44 +0200 Subject: [PATCH] roles/gitlab: advanced http monitoring --- roles/gitlab/defaults/main.yaml | 1 + roles/gitlab/tasks/main.yaml | 39 +++++++++++++++++---------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/roles/gitlab/defaults/main.yaml b/roles/gitlab/defaults/main.yaml index a8473f9..78455cb 100644 --- a/roles/gitlab/defaults/main.yaml +++ b/roles/gitlab/defaults/main.yaml @@ -1,5 +1,6 @@ --- host_fqdn: '{{ ansible_hostname }}.dmz.{{ domain }}' +monitoring_vhosts: [] gitlab_nginx_main_fqdn: '{{ ansible_hostname }}.{{ domain }}' gitlab_nginx_mattermost_fqdn: 'mattermost.{{ domain }}' gitlab_ssh_port: 8022 diff --git a/roles/gitlab/tasks/main.yaml b/roles/gitlab/tasks/main.yaml index 2c83440..9c0d656 100644 --- a/roles/gitlab/tasks/main.yaml +++ b/roles/gitlab/tasks/main.yaml @@ -91,34 +91,35 @@ block: - name: 'MONITORING | add HTTP/gitlab to monitored service' set_fact: - vhosts: > - {{ hostvars[monitoring_host]['monitoring_facts'][host_fqdn]['vhosts'] - | default([]) }} + monitoring_vhosts: '{{ monitoring_vhosts + [gitlab_nginx_main_fqdn] }}' + when: gitlab_enable_https - name: 'MONITORING | add HTTP/mattermost to monitored service' set_fact: - vhosts: '{{ vhosts + [gitlab_fqdn] }}' - when: enable_https - - name: 'MONITORING | update host monitoring entry' + monitoring_vhosts: '{{ monitoring_vhosts + [gitlab_nginx_mattermost_fqdn] }}' + when: gitlab_enable_mattermost + - name: 'MONITORING | add vhosts to host monitoring entry' set_fact: - vhosts: '{{ vhosts + [mattermost_fqdn] }}' - when: enable_mattermost - - name: 'MONITORING | create host monitoring entry' + monitoring_entry: > + {{ monitoring_entry | default({}) | combine({ + 'address': ansible_host, + 'vhosts': monitoring_vhosts, + }) }} + - name: 'MONITORING | add vhosts_uri to host monitoring entry' set_fact: - gitlab_monitoring_entry: > - {{ { - host_fqdn: { - 'address': ansible_host, - 'vhosts': vhosts, - } - } }} + monitoring_entry: > + {{ monitoring_entry | default({}) | combine({ + 'address': ansible_host, + 'vhosts_uri': { gitlab_nginx_main_fqdn: {'/': 'Sign in ยท GitLab'}, + gitlab_nginx_mattermost_fqdn: { '/': 'Mattermost' } }, + }, recursive=true) }} - name: 'MONITORING | update monitoring facts' set_fact: monitoring_facts: > {{ hostvars[monitoring_host]['monitoring_facts'] | default({}) - | combine(gitlab_monitoring_entry, recursive=true) }} - delegate_facts: true - delegate_to: '{{ monitoring_host }}' + | combine({host_fqdn: monitoring_entry}) }} + delegate_facts: true + delegate_to: '{{ monitoring_host }}' tags: - 'monitoring' ...