From 397baf522787a7213e099135ff04dc6980395810 Mon Sep 17 00:00:00 2001 From: stakater-nordmart-bot Date: Fri, 13 Dec 2024 18:32:35 +0500 Subject: [PATCH] Add owner label as a prefix while creating integration --- .../tasks/grafana_oncall_hub_spoke.yml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/roles/grafana_cloud_operator/tasks/grafana_oncall_hub_spoke.yml b/roles/grafana_cloud_operator/tasks/grafana_oncall_hub_spoke.yml index 96f519bd..36497068 100644 --- a/roles/grafana_cloud_operator/tasks/grafana_oncall_hub_spoke.yml +++ b/roles/grafana_cloud_operator/tasks/grafana_oncall_hub_spoke.yml @@ -43,9 +43,9 @@ kind: ManagedCluster register: managed_clusters_raw -- name: Extract the list of ManagedCluster CRs +- name: Extract ManagedCluster details with owner label ansible.builtin.set_fact: - managed_clusters: "{{ managed_clusters | default([]) + [{'name': item.metadata.name}] }}" + managed_clusters: "{{ managed_clusters | default([]) + [{'name': item.metadata.name, 'owner': item.metadata.labels.owner }}" loop: "{{ managed_clusters_raw.resources }}" loop_control: loop_var: item @@ -100,19 +100,19 @@ {{ { "type": "alertmanager", - "name": item.name, + "name": (item.owner + '-' + item.name), "default_route": { - "slack": { - "channel_id": slack_channel_validated[loop_index].slack_id, - "enabled": slack_cond - } + "slack": { + "channel_id": slack_channel_validated[loop_index].slack_id, + "enabled": slack_cond } - } if slack_channel_validated is defined and - slack_channel_validated | length > loop_index and - slack_channel_validated[loop_index].slack_id | length > 0 - else { - "type": "alertmanager", - "name": item.name + } + } if slack_channel_validated is defined and + slack_channel_validated | length > loop_index and + slack_channel_validated[loop_index].slack_id | length > 0 + else { + "type": "alertmanager", + "name": (item.owner + '-' + item.name) } }} status_code: [200, 201]