Debian Codegraph @

ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/postgres.yml

raw
1 ---
2 - name: Create postgres datasource
3 register: result
4 community.grafana.grafana_datasource:
5 name: datasource-postgres
6 org_id: "1"
7 ds_type: postgres
8 ds_url: postgres.company.com:5432
9 database: db
10 user: postgres
11 password: iampgroot
12 sslmode: verify-full
13 additional_json_data:
14 timescaledb: true
15
16 - ansible.builtin.debug:
17 var: result
18
19 - ansible.builtin.assert:
20 that:
21 - result.changed
22 - result.msg == 'Datasource datasource-postgres created'
23
24 - name: Check postgres datasource creation idempotency
25 register: result
26 community.grafana.grafana_datasource:
27 name: datasource-postgres
28 org_id: "1"
29 ds_type: postgres
30 ds_url: postgres.company.com:5432
31 database: db
32 user: postgres
33 password: iampgroot
34 sslmode: verify-full
35 additional_json_data:
36 timescaledb: true
37
38 - ansible.builtin.debug:
39 var: result
40
41 - ansible.builtin.assert:
42 that:
43 - not result.changed
44 - result.datasource.basicAuth == false
45 - result.datasource.database == 'db'
46 - result.datasource.isDefault == false
47 - result.datasource.jsonData.sslmode == 'verify-full'
48 - result.datasource.jsonData.tlsAuth == false
49 - result.datasource.jsonData.tlsAuthWithCACert == false
50 - result.datasource.jsonData.timescaledb == true
51 - result.datasource.name == 'datasource-postgres'
52 - result.datasource.orgId == 1
53 - result.datasource.type in ['postgres', 'grafana-postgresql-datasource']
54 - result.datasource.url == 'postgres.company.com:5432'
55 - result.datasource.user == 'postgres'
56 - result.datasource.withCredentials == false
57
58 - name: Delete postgres datasource
59 register: result
60 community.grafana.grafana_datasource:
61 name: datasource-postgres
62 state: absent
63
64 - ansible.builtin.debug:
65 var: result
66
67 - ansible.builtin.assert:
68 that:
69 - result.changed
70
71 - name: Delete postgres datasource
72 register: result
73 community.grafana.grafana_datasource:
74 name: datasource-postgres
75 state: absent
76
77 - ansible.builtin.debug:
78 var: result
79
80 - ansible.builtin.assert:
81 that:
82 - not result.changed