From 9f64b522ebe9004ea5a66a40f5f642143f318611 Mon Sep 17 00:00:00 2001 From: Gael Lepetit Date: Thu, 26 Sep 2024 16:52:20 +0200 Subject: [PATCH 1/2] define all_group_name --- roles/ceph-defaults/defaults/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/ceph-defaults/defaults/main.yml b/roles/ceph-defaults/defaults/main.yml index eb34908c87..d6f578f17b 100644 --- a/roles/ceph-defaults/defaults/main.yml +++ b/roles/ceph-defaults/defaults/main.yml @@ -40,6 +40,7 @@ ceph_release_num: cluster: ceph # Inventory host group variables +all_group_name: all # useful if runned against a global inventory that includes non-ceph hosts mon_group_name: mons osd_group_name: osds rgw_group_name: rgws From 0bf0581b584d997dcbffb3ef098ce86341062e8b Mon Sep 17 00:00:00 2001 From: Gael Lepetit Date: Thu, 5 Sep 2024 18:00:31 +0200 Subject: [PATCH 2/2] Replace hardcoded groupname with groupname variable --- dashboard.yml | 2 +- roles/ceph-prometheus/templates/alertmanager.yml.j2 | 2 +- roles/ceph-prometheus/templates/prometheus.yml.j2 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dashboard.yml b/dashboard.yml index e998e1e539..e22eee5798 100644 --- a/dashboard.yml +++ b/dashboard.yml @@ -105,7 +105,7 @@ # using groups[] here otherwise it can't fallback to the mon if there's no mgr group. # adding an additional | default(omit) in case where no monitors are present (external ceph cluster) - name: Deploy dashboard - hosts: "{{ groups['mgrs'] | default(groups['mons']) | default(omit) }}" + hosts: "{{ groups[mgr_group_name] | default(groups[mon_group_name]) | default(omit) }}" gather_facts: false become: true pre_tasks: diff --git a/roles/ceph-prometheus/templates/alertmanager.yml.j2 b/roles/ceph-prometheus/templates/alertmanager.yml.j2 index 63dfbf7014..97eefc1218 100644 --- a/roles/ceph-prometheus/templates/alertmanager.yml.j2 +++ b/roles/ceph-prometheus/templates/alertmanager.yml.j2 @@ -10,7 +10,7 @@ route: receivers: - name: 'ceph-dashboard' webhook_configs: -{% for host in groups['mgrs'] | default(groups['mons']) %} +{% for host in groups[mgr_group_name] | default(groups[mon_group_name]) %} - url: '{{ dashboard_protocol }}://{{ hostvars[host]['ansible_facts']['fqdn'] }}:{{ dashboard_port }}/api/prometheus_receiver' {% if dashboard_protocol == 'https' and alertmanager_dashboard_api_no_ssl_verify | bool %} http_config: diff --git a/roles/ceph-prometheus/templates/prometheus.yml.j2 b/roles/ceph-prometheus/templates/prometheus.yml.j2 index 2476495bb5..a37175c47f 100644 --- a/roles/ceph-prometheus/templates/prometheus.yml.j2 +++ b/roles/ceph-prometheus/templates/prometheus.yml.j2 @@ -19,7 +19,7 @@ scrape_configs: {% endfor %} - job_name: 'node' static_configs: -{% for host in (groups['all'] | difference(groups[monitoring_group_name] | union(groups.get(client_group_name, []))) | union(groups.get(osd_group_name, []))) %} +{% for host in (groups[all_group_name] | difference(groups[monitoring_group_name] | union(groups.get(client_group_name, []))) | union(groups.get(osd_group_name, []))) %} - targets: ['{{ host }}:{{ node_exporter_port }}'] labels: instance: "{{ hostvars[host]['ansible_facts']['nodename'] }}"