From 4b93f96818f4735b8a70b5b78394a00f2930a68b Mon Sep 17 00:00:00 2001 From: Antoine <38678863+nutgood@users.noreply.github.com> Date: Thu, 4 Apr 2024 16:26:01 -0400 Subject: [PATCH 01/12] docs(grafana_datasource): add influxdb flux example --- plugins/modules/grafana_datasource.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/modules/grafana_datasource.py b/plugins/modules/grafana_datasource.py index 29cdbea7..9b1aea6a 100644 --- a/plugins/modules/grafana_datasource.py +++ b/plugins/modules/grafana_datasource.py @@ -400,6 +400,23 @@ time_interval: ">10s" tls_ca_cert: "/etc/ssl/certs/ca.pem" +- name: Create influxdbv2 datasource using fluxql + community.grafana.grafana_datasource: + name: "datasource-influxdb-flux" + grafana_url: "https://grafana.company.com" + grafana_user: "admin" + grafana_password: "xxxxxx" + org_id: "1" + ds_type: "influxdb" + ds_url: "https://influx.company.com:8086" + additional_json_data: + version: "Flux" + organization: "organization" + defaultBucket: "bucket" + tlsSkipVerify: false + additional_secure_json_data: + token: "token" + - name: Create postgres datasource community.grafana.grafana_datasource: name: "datasource-postgres" From 45b4fb2a7157cfcff4c81f1689231b1b0c9f6756 Mon Sep 17 00:00:00 2001 From: Antoine <38678863+nutgood@users.noreply.github.com> Date: Fri, 5 Apr 2024 09:13:46 -0400 Subject: [PATCH 02/12] docs(grafana_datasource) - add changelog fragment --- changelogs/fragments/353-docs-add-influxdb-flux-example.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/353-docs-add-influxdb-flux-example.yml diff --git a/changelogs/fragments/353-docs-add-influxdb-flux-example.yml b/changelogs/fragments/353-docs-add-influxdb-flux-example.yml new file mode 100644 index 00000000..d9c80879 --- /dev/null +++ b/changelogs/fragments/353-docs-add-influxdb-flux-example.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - grafana_datasource - (docs) add influxdb v2 flux example \ No newline at end of file From 268542f64fa4bb24377e82e3d25a74bc662a01ef Mon Sep 17 00:00:00 2001 From: Antoine <38678863+nutgood@users.noreply.github.com> Date: Fri, 5 Apr 2024 09:23:32 -0400 Subject: [PATCH 03/12] docs(grafana_datasource): update changelog fragment to trivial Co-authored-by: Moritz <15136847+Nemental@users.noreply.github.com> --- changelogs/fragments/353-docs-add-influxdb-flux-example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/353-docs-add-influxdb-flux-example.yml b/changelogs/fragments/353-docs-add-influxdb-flux-example.yml index d9c80879..b3baa1bc 100644 --- a/changelogs/fragments/353-docs-add-influxdb-flux-example.yml +++ b/changelogs/fragments/353-docs-add-influxdb-flux-example.yml @@ -1,3 +1,3 @@ --- -minor_changes: +trivial: - grafana_datasource - (docs) add influxdb v2 flux example \ No newline at end of file From 5af2c560f6b45753bbe4c5bdbe46e7cabad6918e Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:32:30 +0200 Subject: [PATCH 04/12] fix: remove message argument --- plugins/modules/grafana_dashboard.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/plugins/modules/grafana_dashboard.py b/plugins/modules/grafana_dashboard.py index 77a5a756..60cd5b86 100644 --- a/plugins/modules/grafana_dashboard.py +++ b/plugins/modules/grafana_dashboard.py @@ -81,8 +81,6 @@ description: - Set a commit message for the version history. - Only used when C(state) is C(present). - - C(message) alias is deprecated in Ansible 2.10, since it is used internally by Ansible Core Engine. - aliases: [ 'message' ] type: str extends_documentation_fragment: - community.grafana.basic_auth @@ -620,15 +618,7 @@ def main(): dashboard_id=dict(type="str"), dashboard_revision=dict(type="str", default="1"), overwrite=dict(type="bool", default=False), - commit_message=dict( - type="str", - aliases=["message"], - deprecated_aliases=[ - dict( - name="message", version="2.0.0", collection_name="community.grafana" - ) - ], - ), + commit_message=dict(type="str"), ) module = AnsibleModule( argument_spec=argument_spec, @@ -647,11 +637,6 @@ def main(): module.params["url"] = clean_url(module.params["url"]) - if "message" in module.params: - module.fail_json( - msg="'message' is reserved keyword, please change this parameter to 'commit_message'" - ) - try: if module.params["state"] == "present": result = grafana_create_dashboard(module, module.params) From 25453f22d29eb117a1a1c236f8e45d15bac276b5 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:41:22 +0200 Subject: [PATCH 05/12] docs: changelog fragment --- changelogs/fragments/355-rm-dashboard-message-argument.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/355-rm-dashboard-message-argument.yml diff --git a/changelogs/fragments/355-rm-dashboard-message-argument.yml b/changelogs/fragments/355-rm-dashboard-message-argument.yml new file mode 100644 index 00000000..3f54afa5 --- /dev/null +++ b/changelogs/fragments/355-rm-dashboard-message-argument.yml @@ -0,0 +1,3 @@ +--- +removed_features: + - removed deprecated `message` argument in `grafana_dashboard` From d1a9f81a8f33a32aa1a5a1e94556a8cc2536835b Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:17:16 +0200 Subject: [PATCH 06/12] fix: find grafana releases for latest 3 major versions --- hacking/find_grafana_versions.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/hacking/find_grafana_versions.py b/hacking/find_grafana_versions.py index b31fc530..add6ea9e 100644 --- a/hacking/find_grafana_versions.py +++ b/hacking/find_grafana_versions.py @@ -7,12 +7,12 @@ def get_by_major(version): if version.startswith("v"): version = version[1:] - return (version[0], version, int(version.replace(".", ""))) + return int(version.split(".")[0]), version, tuple(map(int, version.split("."))) def get_grafana_releases(): r = requests.get( - "https://api.github.com/repos/grafana/grafana/releases?per_page=50", + "https://api.github.com/repos/grafana/grafana/releases?per_page=100", headers={"Accept": "application/vnd.github.v3+json"}, ) if r.status_code != 200: @@ -20,19 +20,18 @@ def get_grafana_releases(): return r.json() -by_major = {} - if __name__ == "__main__": releases = get_grafana_releases() - for item in releases: - if item.get("prerelease"): + by_major = {} + + for release in releases: + if release.get("prerelease"): continue - major, version, as_int = get_by_major(item.get("tag_name")) - if major not in by_major.keys() or by_major[major]["as_int"] < as_int: - by_major[major] = {"version": version, "as_int": as_int} - latest_3_majors = sorted(list(by_major.keys()), reverse=True)[:3] - - latest_releases = [] - for idx in latest_3_majors: - latest_releases.append(by_major[idx]["version"]) + major, version, as_tuple = get_by_major(release.get("tag_name")) + if major not in by_major.keys() or by_major[major]["as_tuple"] < as_tuple: + by_major[major] = {"version": version, "as_tuple": as_tuple} + + latest_3_majors = sorted(list(by_major.keys()))[:3] + latest_releases = [by_major[idx]["version"] for idx in latest_3_majors] + print(json.dumps(latest_releases)) From d11b9a5f6c8dcbfc8e65e0554b6f051d937eec06 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:33:41 +0200 Subject: [PATCH 07/12] docs: changelog fragment --- changelogs/fragments/354-fix-find-grafana-versions.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/354-fix-find-grafana-versions.yml diff --git a/changelogs/fragments/354-fix-find-grafana-versions.yml b/changelogs/fragments/354-fix-find-grafana-versions.yml new file mode 100644 index 00000000..4ba22771 --- /dev/null +++ b/changelogs/fragments/354-fix-find-grafana-versions.yml @@ -0,0 +1,3 @@ +--- +trivial: + - fix find grafana versions python script comparation From 7ac1cd7711c5dc37ef376643f46f0482eaaa62a9 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:35:37 +0200 Subject: [PATCH 08/12] chore: remove dangling whitespace --- .../unit/modules/grafana/grafana_plugin/test_grafana_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py b/tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py index ec691a46..7cc04a99 100644 --- a/tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py +++ b/tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py @@ -21,7 +21,7 @@ def run_command_ls(): def run_command_install_zip(): STDERR = "" STDOUT = """ -installing alexanderzobnin-grafana-zabbix @ +installing alexanderzobnin-grafana-zabbix @ from: /home/grafana//alexanderzobnin-grafana-zabbix-v3.10.5-1-g2219691.zip into: /var/lib/grafana/plugins From 355bb65a9d69c3981fc34b22de21449750f77a35 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:42:44 +0200 Subject: [PATCH 09/12] test: shebang sanity --- hacking/check_fragment.sh | 6 +++--- hacking/find_grafana_versions.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hacking/check_fragment.sh b/hacking/check_fragment.sh index bf90cae6..3173b342 100755 --- a/hacking/check_fragment.sh +++ b/hacking/check_fragment.sh @@ -1,7 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash function fail() { - cat << EOF + cat < Date: Fri, 12 Apr 2024 17:18:47 +0200 Subject: [PATCH 10/12] fix: skip pre or build release tags --- hacking/find_grafana_versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hacking/find_grafana_versions.py b/hacking/find_grafana_versions.py index 6ea344f9..780d07e6 100644 --- a/hacking/find_grafana_versions.py +++ b/hacking/find_grafana_versions.py @@ -25,7 +25,7 @@ def get_grafana_releases(): by_major = {} for release in releases: - if release.get("prerelease"): + if release.get("prerelease") or any(char in release.get("tag_name") for char in "-+"): continue major, version, as_tuple = get_by_major(release.get("tag_name")) if major not in by_major.keys() or by_major[major]["as_tuple"] < as_tuple: From 87bdf0f780474162e41393142f71b46480abdd72 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:20:55 +0200 Subject: [PATCH 11/12] chore: lint --- hacking/find_grafana_versions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hacking/find_grafana_versions.py b/hacking/find_grafana_versions.py index 780d07e6..716f877a 100644 --- a/hacking/find_grafana_versions.py +++ b/hacking/find_grafana_versions.py @@ -25,7 +25,9 @@ def get_grafana_releases(): by_major = {} for release in releases: - if release.get("prerelease") or any(char in release.get("tag_name") for char in "-+"): + if release.get("prerelease") or any( + char in release.get("tag_name") for char in "-+" + ): continue major, version, as_tuple = get_by_major(release.get("tag_name")) if major not in by_major.keys() or by_major[major]["as_tuple"] < as_tuple: From b64db9de485f46b4329169aff26f638b95c77dee Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Thu, 18 Apr 2024 08:30:51 +0200 Subject: [PATCH 12/12] ci: remove sanity ignore files --- tests/sanity/ignore-2.15.txt | 4 ---- tests/sanity/ignore-2.16.txt | 4 ---- 2 files changed, 8 deletions(-) delete mode 100644 tests/sanity/ignore-2.15.txt delete mode 100644 tests/sanity/ignore-2.16.txt diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt deleted file mode 100644 index 5c82494f..00000000 --- a/tests/sanity/ignore-2.15.txt +++ /dev/null @@ -1,4 +0,0 @@ -plugins/modules/grafana_dashboard.py validate-modules:invalid-argument-name -tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291 -hacking/check_fragment.sh shebang -hacking/find_grafana_versions.py shebang diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt deleted file mode 100644 index 5c82494f..00000000 --- a/tests/sanity/ignore-2.16.txt +++ /dev/null @@ -1,4 +0,0 @@ -plugins/modules/grafana_dashboard.py validate-modules:invalid-argument-name -tests/unit/modules/grafana/grafana_plugin/test_grafana_plugin.py pep8:W291 -hacking/check_fragment.sh shebang -hacking/find_grafana_versions.py shebang