From 86cb52265a84525aa1358095cbe4224e44284cb8 Mon Sep 17 00:00:00 2001 From: John R Barker Date: Mon, 23 Oct 2023 12:43:08 +0100 Subject: [PATCH 1/7] CODEOWNERS: Reduce review requirements You folks know what you are doing, you don't need my reviews. --- .github/CODEOWNERS | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3035cfbb..2cc40362 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,13 +1,9 @@ .github # Repo maintainers, and goverance team (like Anisble's @ansible-commit-external) -* @rrey @seuf @gundalow-collections/community-goverance-team +* @rrey @seuf # or possibly, we may want to define teams at the org level. -# * @gundalow-collections/grafana-maintainers # Example of maintainer of just a single plugin #grafana/plugins/modules/grafana_plugin.py @someone-else - - -.github/ @gundalow From f5f65d0a6aa829527ca59fd5c4b5ea773bd1a3e8 Mon Sep 17 00:00:00 2001 From: Hiromasa Ihara Date: Sat, 19 Aug 2023 16:55:58 +0900 Subject: [PATCH 2/7] Bump requests from 2.28.2 to 2.31.0 --- hacking/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hacking/requirements.txt b/hacking/requirements.txt index ced51d09..2c24336e 100644 --- a/hacking/requirements.txt +++ b/hacking/requirements.txt @@ -1 +1 @@ -requests==2.28.0 +requests==2.31.0 From 9471c98315063d4d14516fcfb11eda38c58f8a87 Mon Sep 17 00:00:00 2001 From: rrey Date: Sun, 29 Oct 2023 01:26:27 +0000 Subject: [PATCH 3/7] Update tested Grafana versions --- .github/workflows/ansible-test.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index e8f2cd6b..65b0443e 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -45,7 +45,7 @@ jobs: strategy: fail-fast: false matrix: - grafana_version: ["9.2.6", "8.5.15", "7.5.16"] + grafana_version: ["9.5.13", "8.5.27", "10.2.0"] ansible_version: ["stable-2.13", "stable-2.14", "devel"] python_version: ["3.9"] services: diff --git a/README.md b/README.md index c2e7eb65..1d4ddb2c 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,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.2.6", "8.5.15", "7.5.16"] +grafana_version: ["9.5.13", "8.5.27", "10.2.0"] ``` ## Installation and Usage From fdd5e6ee506d94e37d95bdf08c52a31ee1e48450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20REY?= Date: Sat, 4 Nov 2023 18:53:37 +0100 Subject: [PATCH 4/7] Bump Python version to 3.10 for tests --- .github/workflows/ansible-test.yml | 6 +++--- changelogs/fragments/294-bump-grafana-version.yml | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/294-bump-grafana-version.yml diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 65b0443e..fff19d23 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -12,7 +12,7 @@ jobs: timeout-minutes: 30 strategy: matrix: - python_version: ["3.9"] + python_version: ["3.10"] ansible_version: ["stable-2.13", "stable-2.14", "devel"] steps: - name: Perform testing @@ -29,7 +29,7 @@ jobs: timeout-minutes: 30 strategy: matrix: - python_version: ["3.9"] + python_version: ["3.10"] ansible_version: ["stable-2.13", "stable-2.14", "devel"] steps: - name: Perform testing @@ -47,7 +47,7 @@ jobs: matrix: grafana_version: ["9.5.13", "8.5.27", "10.2.0"] ansible_version: ["stable-2.13", "stable-2.14", "devel"] - python_version: ["3.9"] + python_version: ["3.10"] services: grafana: image: grafana/grafana:${{ matrix.grafana_version }} diff --git a/changelogs/fragments/294-bump-grafana-version.yml b/changelogs/fragments/294-bump-grafana-version.yml new file mode 100644 index 00000000..f171f15c --- /dev/null +++ b/changelogs/fragments/294-bump-grafana-version.yml @@ -0,0 +1,2 @@ +minor_changes: + - Bump version of Python used in tests to 3.10 From aca73d92f793598b4283f4b8bfd011d25a68b83b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20REY?= Date: Sat, 4 Nov 2023 20:23:11 +0100 Subject: [PATCH 5/7] fix(folders): make sure to return a json response if Grafana returns an empty response Since Grafana 9.3 the folders endpoint stopped sending back json in response breaking the module response handling. See https://github.com/grafana/grafana/issues/77673 --- changelogs/fragments/294-bump-grafana-version.yml | 2 ++ plugins/modules/grafana_folder.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelogs/fragments/294-bump-grafana-version.yml b/changelogs/fragments/294-bump-grafana-version.yml index f171f15c..a3050c01 100644 --- a/changelogs/fragments/294-bump-grafana-version.yml +++ b/changelogs/fragments/294-bump-grafana-version.yml @@ -1,2 +1,4 @@ minor_changes: - Bump version of Python used in tests to 3.10 +bugfixes: + - grafana_folder, fix an issue during delete (starting Grafana 9.3) diff --git a/plugins/modules/grafana_folder.py b/plugins/modules/grafana_folder.py index d39e56e4..380a510c 100644 --- a/plugins/modules/grafana_folder.py +++ b/plugins/modules/grafana_folder.py @@ -215,7 +215,10 @@ def _send_request(self, url, data=None, headers=None, method="GET"): error_msg = resp.read()['message'] self._module.fail_json(failed=True, msg=error_msg) elif status_code == 200: - return self._module.from_json(resp.read()) + # XXX: Grafana folders endpoint stopped sending back json in response for delete operations + # see https://github.com/grafana/grafana/issues/77673 + response = resp.read() or "{}" + return self._module.from_json(response) self._module.fail_json(failed=True, msg="Grafana Folders API answered with HTTP %d" % status_code) def get_version(self): From 3d55a3b69490e3b73cd70c2374e5c8b2e1efbcd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20REY?= Date: Sat, 4 Nov 2023 22:07:49 +0100 Subject: [PATCH 6/7] fix(syntax): replace include by include_tasks It was removed from ansible-core in a release after 2023-05-16 --- .../targets/grafana_dashboard/tasks/main.yml | 12 +++---- .../targets/grafana_datasource/tasks/main.yml | 22 ++++++------ .../tasks/main.yml | 36 +++++++++---------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/tests/integration/targets/grafana_dashboard/tasks/main.yml b/tests/integration/targets/grafana_dashboard/tasks/main.yml index 4d9138fc..570fb4d8 100644 --- a/tests/integration/targets/grafana_dashboard/tasks/main.yml +++ b/tests/integration/targets/grafana_dashboard/tasks/main.yml @@ -1,7 +1,7 @@ - block: - - include: dashboard-from-url.yml - - include: delete-dashboard.yml - - include: dashboard-from-id.yml - - include: dashboard-from-file.yml - - include: dashboard-export.yml - - include: dashboard-folder-destination.yml + - include_tasks: dashboard-from-url.yml + - include_tasks: delete-dashboard.yml + - include_tasks: dashboard-from-id.yml + - include_tasks: dashboard-from-file.yml + - include_tasks: dashboard-export.yml + - include_tasks: dashboard-folder-destination.yml diff --git a/tests/integration/targets/grafana_datasource/tasks/main.yml b/tests/integration/targets/grafana_datasource/tasks/main.yml index b5798e9a..312ad347 100644 --- a/tests/integration/targets/grafana_datasource/tasks/main.yml +++ b/tests/integration/targets/grafana_datasource/tasks/main.yml @@ -1,16 +1,16 @@ --- - block: - - include: errors.yml - - include: elastic.yml - - include: influx.yml - - include: postgres.yml - - include: cloudwatch.yml - - include: thruk.yml - - include: loki.yml - - include: zabbix.yml - - include: redis.yml - - include: azure.yml - - include: uid.yml + - include_tasks: errors.yml + - include_tasks: elastic.yml + - include_tasks: influx.yml + - include_tasks: postgres.yml + - include_tasks: cloudwatch.yml + - include_tasks: thruk.yml + - include_tasks: loki.yml + - include_tasks: zabbix.yml + - include_tasks: redis.yml + - include_tasks: azure.yml + - include_tasks: uid.yml ... diff --git a/tests/integration/targets/grafana_notification_channel/tasks/main.yml b/tests/integration/targets/grafana_notification_channel/tasks/main.yml index ada6338c..ceaf72ad 100644 --- a/tests/integration/targets/grafana_notification_channel/tasks/main.yml +++ b/tests/integration/targets/grafana_notification_channel/tasks/main.yml @@ -1,20 +1,20 @@ --- - block: - - include: dingding.yml - - include: discord.yml - - include: email.yml - - include: googlechat.yml - - include: hipchat.yml - - include: kafka.yml -# - include: line.yml - - include: teams.yml - - include: opsgenie.yml - - include: pagerduty.yml - - include: prometheus.yml - - include: pushover.yml - - include: sensu.yml - - include: slack-and-beyond.yml - - include: telegram.yml -# - include: threema.yml - - include: victorops.yml - - include: webhook.yml + - include_tasks: dingding.yml + - include_tasks: discord.yml + - include_tasks: email.yml + - include_tasks: googlechat.yml + - include_tasks: hipchat.yml + - include_tasks: kafka.yml +# - include_tasks: line.yml + - include_tasks: teams.yml + - include_tasks: opsgenie.yml + - include_tasks: pagerduty.yml + - include_tasks: prometheus.yml + - include_tasks: pushover.yml + - include_tasks: sensu.yml + - include_tasks: slack-and-beyond.yml + - include_tasks: telegram.yml +# - include_tasks: threema.yml + - include_tasks: victorops.yml + - include_tasks: webhook.yml From 4e0195eb58358ee426849bcad315a165d5ec4fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20REY?= Date: Sat, 4 Nov 2023 22:17:50 +0100 Subject: [PATCH 7/7] test(sanity): create the ignore file for devel --- changelogs/fragments/294-bump-grafana-version.yml | 1 + plugins/modules/grafana_datasource.py | 7 +++++-- tests/sanity/ignore-2.16.txt | 4 ++++ tests/sanity/ignore-2.17.txt | 4 ++++ .../grafana/grafana_datasource/test_grafana_datasource.py | 2 +- .../unit/modules/grafana/grafana_team/test_grafana_team.py | 2 +- .../unit/modules/grafana/grafana_user/test_grafana_user.py | 2 +- 7 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 tests/sanity/ignore-2.16.txt create mode 100644 tests/sanity/ignore-2.17.txt diff --git a/changelogs/fragments/294-bump-grafana-version.yml b/changelogs/fragments/294-bump-grafana-version.yml index a3050c01..7149cfe0 100644 --- a/changelogs/fragments/294-bump-grafana-version.yml +++ b/changelogs/fragments/294-bump-grafana-version.yml @@ -1,4 +1,5 @@ minor_changes: - Bump version of Python used in tests to 3.10 + - Now testing against Grafana 9.5.13, 8.5.27, 10.2.0 bugfixes: - grafana_folder, fix an issue during delete (starting Grafana 9.3) diff --git a/plugins/modules/grafana_datasource.py b/plugins/modules/grafana_datasource.py index 154dc451..b0496a97 100644 --- a/plugins/modules/grafana_datasource.py +++ b/plugins/modules/grafana_datasource.py @@ -67,15 +67,18 @@ (index name), C(mysql) or C(postgres). required: false type: str + default: '' user: description: - The datasource login user for influxdb datasources. type: str + default: '' password: description: - The datasource password. - Stored as secure data, see C(enforce_secure_data) and notes! type: str + default: '' basic_auth_user: description: - The datasource basic auth user. @@ -180,6 +183,7 @@ - Monthly - Yearly type: str + default: '' tsdb_version: description: - The opentsdb version. @@ -280,7 +284,6 @@ aws_custom_metrics_namespaces: description: - Namespaces of Custom Metrics for CloudWatch datasource type - default: '' required: false type: str azure_cloud: @@ -494,7 +497,7 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.six.moves.urllib.parse import quote -from ansible.module_utils.urls import fetch_url, url_argument_spec, basic_auth_header +from ansible.module_utils.urls import fetch_url, basic_auth_header from ansible_collections.community.grafana.plugins.module_utils import base diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt new file mode 100644 index 00000000..5c82494f --- /dev/null +++ b/tests/sanity/ignore-2.16.txt @@ -0,0 +1,4 @@ +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.17.txt b/tests/sanity/ignore-2.17.txt new file mode 100644 index 00000000..5c82494f --- /dev/null +++ b/tests/sanity/ignore-2.17.txt @@ -0,0 +1,4 @@ +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/unit/modules/grafana/grafana_datasource/test_grafana_datasource.py b/tests/unit/modules/grafana/grafana_datasource/test_grafana_datasource.py index d2fba0fe..0a68fda7 100644 --- a/tests/unit/modules/grafana/grafana_datasource/test_grafana_datasource.py +++ b/tests/unit/modules/grafana/grafana_datasource/test_grafana_datasource.py @@ -1,7 +1,7 @@ from __future__ import (absolute_import, division, print_function) from unittest import TestCase -from unittest.mock import call, patch, MagicMock +from unittest.mock import patch from ansible_collections.community.grafana.plugins.modules import grafana_datasource from ansible.module_utils._text import to_bytes from ansible.module_utils import basic diff --git a/tests/unit/modules/grafana/grafana_team/test_grafana_team.py b/tests/unit/modules/grafana/grafana_team/test_grafana_team.py index c59953af..491b863d 100644 --- a/tests/unit/modules/grafana/grafana_team/test_grafana_team.py +++ b/tests/unit/modules/grafana/grafana_team/test_grafana_team.py @@ -1,7 +1,7 @@ from __future__ import (absolute_import, division, print_function) from unittest import TestCase -from unittest.mock import patch, MagicMock +from unittest.mock import patch from ansible_collections.community.grafana.plugins.modules import grafana_team from ansible.module_utils._text import to_bytes from ansible.module_utils import basic diff --git a/tests/unit/modules/grafana/grafana_user/test_grafana_user.py b/tests/unit/modules/grafana/grafana_user/test_grafana_user.py index 925c0165..80c51409 100644 --- a/tests/unit/modules/grafana/grafana_user/test_grafana_user.py +++ b/tests/unit/modules/grafana/grafana_user/test_grafana_user.py @@ -1,7 +1,7 @@ from __future__ import (absolute_import, division, print_function) from unittest import TestCase -from unittest.mock import call, patch, MagicMock +from unittest.mock import call, patch from ansible_collections.community.grafana.plugins.modules import grafana_user from ansible.module_utils._text import to_bytes from ansible.module_utils import basic