Skip to content

Commit

Permalink
fix: 🎨 Manage datasource UID
Browse files Browse the repository at this point in the history
  • Loading branch information
cmon33 committed May 27, 2024
1 parent 6126c2b commit 47c8451
Show file tree
Hide file tree
Showing 9 changed files with 578 additions and 560 deletions.
21 changes: 19 additions & 2 deletions roles/grafana-dashboards/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@
- app={{ grafana_label }}
register: gf_instance

- name: Manage missing Grafana instance.
- name: Manage missing Grafana instance
when: gf_instance.resources | length == 0
ansible.builtin.fail:
msg: "Missing Grafana instance. Please execute 'ansible-playbook install.yaml -t grafana' before trying to install the default datasource."
msg: "Missing Grafana instance. Please execute 'ansible-playbook install.yaml -t grafana'."

- name: Get Grafana datasource
kubernetes.core.k8s_info:
api_version: grafana.integreatly.org/v1beta1
namespace: "{{ dsc.grafana.namespace }}"
kind: GrafanaDatasource
name: datasource-prom-{{ grafana_label }}
register: gf_datasource

- name: Manage missing Grafana datasource
when: gf_instance.resources | length == 0
ansible.builtin.fail:
msg: "Missing Grafana datasource. Please execute 'ansible-playbook install.yaml -t grafana-datasource'."

- name: Get datasource UID
ansible.builtin.set_fact:
gf_datasource_uid: "{{ gf_datasource.resources[0].metadata.uid }}"

- name: Create Grafana dashboards
kubernetes.core.k8s:
Expand Down
Loading

0 comments on commit 47c8451

Please sign in to comment.