Skip to content

Commit 2f49338

Browse files
authored
Merge pull request #175 from infrawatch/test_alerts_detect_observability_api
Determine API versions based on observability strategy
2 parents fb5fcab + 12413ed commit 2f49338

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: "Get the observability strategy"
3+
ansible.builtin.shell:
4+
cmd: |
5+
oc get stf default -ojsonpath='{.spec.observabilityStrategy}'
6+
changed_when: false
7+
register: observability_strategy
8+
9+
- name: "Set the observability api based on the observability strategy"
10+
ansible.builtin.set_fact:
11+
observability_api: "{{ 'monitoring.rhobs' if observability_strategy.stdout == 'use_redhat' else 'monitoring.coreos.com' }}"
12+

roles/test_alerts/tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
vars:
77
prom_auth_method: token
88

9+
- name: "Get the observability strategy and set the observability_api"
10+
ansible.builtin.include_tasks:
11+
file: get_observability_api.yml
12+
913
- name: "Test Creating an alert rule in Prometheus"
1014
ansible.builtin.include_tasks:
1115
file: test_create_an_alert.yml

roles/test_alerts/tasks/test_create_an_alert.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
ansible.builtin.shell:
88
cmd: |
99
oc apply -f - <<EOF
10-
apiVersion: monitoring.coreos.com/v1
10+
apiVersion: {{ observability_api }}/v1
1111
kind: PrometheusRule
1212
metadata:
1313
creationTimestamp: null

roles/test_verify_email/tasks/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
---
22
# tasks file for roles/test_verify_email
3+
- name: "Get the observability strategy and set observability_api"
4+
ansible.builtin.include_role:
5+
name: test_alerts
6+
tasks_from: get_observability_api.yml
37

48
- name: "RHELOSP-176042 Create the alert"
59
ansible.builtin.shell:
610
cmd: |
711
oc apply -f - <<EOF
8-
apiVersion: monitoring.coreos.com/v1
12+
apiVersion: {{ observability_api }}/v1
913
kind: PrometheusRule
1014
metadata:
1115
creationTimestamp: null

0 commit comments

Comments
 (0)