1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- ---
- - name: Get grafana service IP
- command: kubectl get svc "{{ grafana_k8s }}" -n "{{ grafana_namespace }}" -o=jsonpath='{.spec.clusterIP}'
- changed_when: false
- register: grafana_svc_ip
- - name: Get grafana service port
- command: kubectl get svc "{{ grafana_k8s }}" -n "{{ grafana_namespace }}" -o=jsonpath='{.spec.ports[0].port}'
- changed_when: false
- register: grafana_svc_port
- - name: Get timescaleDB svc IP
- command: kubectl get svc -n "{{ namespace }}" -o=jsonpath='{.items[0].spec.clusterIP}'
- changed_when: false
- register: timescale_svc_ip
- - name: Get timescaleDB svc port
- command: kubectl get svc -n "{{ namespace }}" -o=jsonpath='{.items[0].spec.ports[0].port}'
- changed_when: false
- register: timescale_svc_port
- - name: Wait for grafana pod to come to ready state
- command: kubectl wait --for=condition=ready --timeout=10m -n "{{ grafana_namespace }}" pod -l app="{{ grafana_k8s }}"
- changed_when: false
- - name: Add timescale datasource on grafana
- community.grafana.grafana_datasource:
- name: telemetry-postgres
- grafana_url: "http://{{ grafana_svc_ip.stdout }}:{{ grafana_svc_port.stdout }}"
- grafana_user: "{{ grafana_username }}"
- grafana_password: "{{ grafana_password }}"
- ds_type: "postgres"
- ds_url: "http://{{ timescale_svc_ip.stdout }}:{{ timescale_svc_port.stdout }}"
- user: "{{ timescaledb_user }}"
- sslmode: "disable"
- additional_json_data:
- postgresVersion: 12
- timescaledb: true
- additional_secure_json_data:
- password: "{{ timescaledb_password }}"
- no_log: true
|