ansible-collections / community.grafana

Grafana Collection for Ansible
http://galaxy.ansible.com/community/grafana
GNU General Public License v3.0
131 stars 83 forks source link

Version Check broken with Security Release (Grafana v11.2.2+security-01 ) #404

Open shakalandy opened 1 month ago

shakalandy commented 1 month ago
SUMMARY

The Version Check currently done is broken against the recent Grafana Security Release (Grafana v11.2.2+security-01 )

The error was: ValueError: invalid literal for int() with base 10: '2+security-01

ISSUE TYPE
COMPONENT NAME

All Grafana Modules using the Version check, if not disabled via skip_version_check

ANSIBLE VERSION
  config file = /home/ansible/gitlab/ansible-hosting/ansible.cfg
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
----------------- -------
community.general 9.0.0

# /usr/lib/python3/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 9.5.0
OS / ENVIRONMENT

Ubuntu 24.04.1 LTS on ansible host

STEPS TO REPRODUCE
  1. Use a Grafana Module with version check enabled
  2. Update Grafana to latest Version (Version String: Grafana v11.2.2+security-01 )
  3. Execute Playbook
      community.grafana.grafana_folder:
        grafana_url: "{{ grafana_url }}"
        grafana_api_key: "{{ grafana_api_key }}"
        title: "{{ folder_name }}"
        state: present
      register: grafana_folder
      delegate_to: localhost
EXPECTED RESULTS

Playbook works

ACTUAL RESULTS

Playbook throws an error as the grafana version string can't be interpreted

fatal: [sentry.brandmeister.dev -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1729490200.123352-1861563-12274287438230/AnsiballZ_grafana_team.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1729490200.123352-1861563-12274287438230/AnsiballZ_grafana_team.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1729490200.123352-1861563-12274287438230/AnsiballZ_grafana_team.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.grafana.plugins.modules.grafana_team', init_globals=dict(_module_fqn='ansible_collections.community.grafana.plugins.modules.grafana_team', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/tmp/ansible_community.grafana.grafana_team_payload_9kpb17lh/ansible_community.grafana.grafana_team_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_team.py\", line 376, in <module>\n  File \"/tmp/ansible_community.grafana.grafana_team_payload_9kpb17lh/ansible_community.grafana.grafana_team_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_team.py\", line 334, in main\n  File \"/tmp/ansible_community.grafana.grafana_team_payload_9kpb17lh/ansible_community.grafana.grafana_team_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_team.py\", line 202, in __init__\n  File \"/tmp/ansible_community.grafana.grafana_team_payload_9kpb17lh/ansible_community.grafana.grafana_team_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_team.py\", line 246, in get_version\nValueError: invalid literal for int() with base 10: '2+security-01'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Possible Workaround: enable skip_version_check:

      community.grafana.grafana_folder:
        grafana_url: "{{ grafana_url }}"
        grafana_api_key: "{{ grafana_api_key }}"
        title: "{{ customer }}"
        state: present
        skip_version_check: true
      register: grafana_folder
      delegate_to: localhost
Yannek-JS commented 3 weeks ago

It breaks for official Grafana OSS docker images too.

e.g.

Grafana

$ curl localhost:3000/api/health
{
  "database": "ok",
  "version": "11.4.0-205570",
  "commit": "403b60723d9960b29c1ad9b1fd5b22b3bc340bef"

Ansible

 fatal: [localhost]: FAILED! => {
 (...)
 init__\n  File \"/tmp/ansible_community.grafana.grafana_folder_payload_6beyh4e6/ansible_community.grafana.grafana_folder_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_folder.py\", line 305, in get_version\nValueError: invalid literal for int() with base 10: '0-205570'\n"
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}