Skip to content

Commit

Permalink
Merge branch 'main' into rel-190
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemental authored May 8, 2024
2 parents 11a5903 + 9015fdd commit 4493ee1
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
strategy:
fail-fast: false
matrix:
grafana_version: ["9.5.14", "8.5.27", "10.2.2"]
grafana_version: ["8.5.27", "9.5.18", "10.4.2"]
ansible_version: ["stable-2.15", "stable-2.16", "devel"]
python_version: ["3.10"]
services:
Expand All @@ -67,7 +67,7 @@ jobs:
strategy:
fail-fast: false
matrix:
grafana_version: ["9.5.14", "8.5.27", "10.2.2"]
grafana_version: ["8.5.27", "9.5.18", "10.4.2"]
ansible_version: ["stable-2.15", "stable-2.16", "devel"]
python_version: ["3.10"]
services:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Click on the name of a plugin or module to view that content's documentation:
We aim at keeping the last 3 Major versions of Grafana tested.
This collection is currently testing the modules against following versions of Grafana:
```
grafana_version: ["9.5.14", "8.5.27", "10.2.2"]
grafana_version: ["8.5.27", "9.5.18", "10.4.2"]
```

## Installation and Usage
Expand Down
3 changes: 3 additions & 0 deletions changelogs/fragments/364-first-datasource-default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bugfixes:
- Handling of desired default state for first `grafana_datasource`
- Ignore `type` argument for diff comparison if `grafana-postgresq-datasource` alias `postgres` is used
6 changes: 6 additions & 0 deletions plugins/modules/grafana_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ def compare_datasources(new, current, compareSecureData=True):
del current["password"]
if "basicAuthPassword" in current:
del current["basicAuthPassword"]
if current["type"] == "grafana-postgresql-datasource" and new["type"] == "postgres":
del current["type"]
del new["type"]

# check if secureJsonData should be compared
if not compareSecureData:
Expand Down Expand Up @@ -945,6 +948,9 @@ def main():
if ds is None:
grafana_iface.create_datasource(payload)
ds = grafana_iface.datasource_by_name(name)
if ds.get("isDefault") != module.params["is_default"]:
grafana_iface.update_datasource(ds.get("id"), payload)
ds = grafana_iface.datasource_by_name(name)
module.exit_json(
changed=True, datasource=ds, msg="Datasource %s created" % name
)
Expand Down
26 changes: 26 additions & 0 deletions tests/integration/targets/grafana_datasource/tasks/elastic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,32 @@
- result.datasource.secureJsonFields.secureTest == true
- result.diff.after.secureJsonData is defined

- name: Delete elasticsearch legacy datasource
register: result
community.grafana.grafana_datasource:
name: datasource/elasticLegacy
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent

- ansible.builtin.assert:
that:
- result.changed

- name: Delete elasticsearch legacy datasource (idempotency)
register: result
community.grafana.grafana_datasource:
name: datasource/elasticLegacy
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent

- ansible.builtin.assert:
that:
- not result.changed

- name: Delete elasticsearch datasource
register: result
community.grafana.grafana_datasource:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
- result.datasource.jsonData.timescaledb == true
- result.datasource.name == 'datasource-postgres'
- result.datasource.orgId == 1
- result.datasource.type == 'postgres'
- result.datasource.type in ['postgres', 'grafana-postgresql-datasource']
- result.datasource.url == 'postgres.company.com:5432'
- result.datasource.user == 'postgres'
- result.datasource.withCredentials == false
Expand Down

0 comments on commit 4493ee1

Please sign in to comment.