aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/grafana/tasks/post_config.yml
blob: 949ef31f67b5c9efae1c9722817f81a7f0787545 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
- name: Wait for grafana application ready
  become: true
  kolla_toolbox:
    container_engine: "{{ kolla_container_engine }}"
    module_name: uri
    module_args:
      url: "{{ grafana_internal_endpoint }}/login"
      status_code: 200
  register: result
  until: result.get('status') == 200
  retries: 30
  delay: 2
  run_once: true
  when: not ansible_check_mode

- name: Remove old grafana docker volume
  become: true
  kolla_container:
    action: "remove_volume"
    name: grafana
  when: grafana_remove_old_volume | bool

- name: Enable grafana datasources
  become: true
  kolla_toolbox:
    container_engine: "{{ kolla_container_engine }}"
    module_name: uri
    module_args:
      url: "{{ grafana_internal_endpoint }}/api/datasources"
      method: POST
      user: "{{ grafana_admin_username }}"
      password: "{{ grafana_admin_password }}"
      body: "{{ item.value.data | to_json }}"
      body_format: json
      force_basic_auth: true
      status_code: 200, 409
  register: response
  run_once: true
  changed_when: response.status == 200
  failed_when: response.status not in [200, 409] or response.status == 409 and ("name already exists" not in response.json.message | default(""))
  with_dict: "{{ grafana_data_sources }}"
  when: item.value.enabled | bool