add_datasource.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Get grafana service IP
  16. command: kubectl get svc "{{ grafana_k8s }}" -n "{{ grafana_namespace }}" -o=jsonpath='{.spec.clusterIP}'
  17. changed_when: false
  18. register: grafana_svc_ip
  19. - name: Get grafana service port
  20. command: kubectl get svc "{{ grafana_k8s }}" -n "{{ grafana_namespace }}" -o=jsonpath='{.spec.ports[0].port}'
  21. changed_when: false
  22. register: grafana_svc_port
  23. - name: Get timescaleDB svc IP
  24. command: kubectl get svc "{{ timescaledb_k8s_name }}" -n "{{ namespace }}" -o=jsonpath='{.spec.clusterIP}'
  25. changed_when: false
  26. register: timescale_svc_ip
  27. - name: Get timescaleDB svc port
  28. command: kubectl get svc "{{ timescaledb_k8s_name }}" -n "{{ namespace }}" -o=jsonpath='{.spec.ports[0].port}'
  29. changed_when: false
  30. register: timescale_svc_port
  31. - name: Wait for grafana pod to come to ready state
  32. command: kubectl wait --for=condition=ready --timeout=10m -n "{{ grafana_namespace }}" pod -l app="{{ grafana_k8s }}"
  33. changed_when: false
  34. - name: Add timescale datasource on grafana
  35. community.grafana.grafana_datasource:
  36. name: telemetry-postgres
  37. grafana_url: "http://{{ grafana_svc_ip.stdout }}:{{ grafana_svc_port.stdout }}"
  38. grafana_user: "{{ grafana_username }}"
  39. grafana_password: "{{ grafana_password }}"
  40. ds_type: "postgres"
  41. database: "{{ timescaledb_name }}"
  42. ds_url: "{{ timescale_svc_ip.stdout }}:{{ timescale_svc_port.stdout }}"
  43. user: "{{ timescaledb_user }}"
  44. sslmode: "disable"
  45. additional_json_data:
  46. postgresVersion: 12+
  47. timescaledb: true
  48. additional_secure_json_data:
  49. password: "{{ timescaledb_password }}"
  50. no_log: true