ansible / ansible

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
https://www.ansible.com/
GNU General Public License v3.0
62.64k stars 23.86k forks source link

grafana_plugin with offline .zip package fails #67042

Closed rockaut closed 4 years ago

rockaut commented 4 years ago
SUMMARY

If using an offline .zip package for plugin installation the command fails while the plugin is actually installed correctly.

ISSUE TYPE
COMPONENT NAME

grafana_plugin

ANSIBLE VERSION
ansible 2.9.4
  config file = /mnt/d/Code/gitlab/poi-central-grafana/ansbile/ansible.cfg
  configured module search path = ['/home/fism/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /mnt/d/Code/gitlab/grafana/venv/lib/python3.6/site-packages/ansible
  executable location = /mnt/d/Code/gitlab/grafana/venv/bin/ansible
  python version = 3.6.9 (default, Nov  7 2019, 10:44:02) [GCC 8.3.0]
OS / ENVIRONMENT

Grafana 6.6.0 on RHEL7

STEPS TO REPRODUCE
tasks:
    - name: Install/update zabbix plugin
      become: yes
      grafana_plugin:
        name: alexanderzobnin-grafana-zabbix
        grafana_plugin_url: "/tmp/alexanderzobnin-grafana-zabbix-v3.10.5-1-g2219691.zip"
        state: present

Running this task results in the error seen below while grafana-cli ls reports:

installed plugins:
alexanderzobnin-zabbix-app @ 3.10.5

Restart grafana after installing plugins . <service grafana-server restart>

Also tried to manually execute the command the module is triggering: /sbin/grafana-cli --pluginUrl /tmp/alexanderzobnin-grafana-zabbix-v3.10.5-1-g2219691.zip plugins install alexanderzobnin-grafana-zabbix

Which results in:

installing alexanderzobnin-grafana-zabbix @
from: /tmp/alexanderzobnin-grafana-zabbix-v3.10.5-1-g2219691.zip
into: /var/lib/grafana/plugins

✔ Installed alexanderzobnin-grafana-zabbix successfully

Restart grafana after installing plugins . <service grafana-server restart>
EXPECTED RESULTS

as the plugin is correctly installing the plugin it should report a success.

ACTUAL RESULTS

Module error:

The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_grafana_plugin_payload_39EwDA/ansible_grafana_plugin_payload.zip/ansible/modules/monitoring/grafana_plugin.py", line 236, in main
  File "/tmp/ansible_grafana_plugin_payload_39EwDA/ansible_grafana_plugin_payload.zip/ansible/modules/monitoring/grafana_plugin.py", line 210, in grafana_plugin

fatal: [****]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "grafana_plugin_url": "/tmp/alexanderzobnin-grafana-zabbix-v3.10.5-1-g2219691.zip",
            "grafana_plugins_dir": null,
            "grafana_repo": null,
            "name": "alexanderzobnin-grafana-zabbix",
            "state": "present",
            "version": null
        }
    },
    "msg": "<type 'exceptions.ValueError'> : need more than 1 value to unpack "
}
rockaut commented 4 years ago

Also tried with several other .zip plugins and all got the same error.

Looking into it it's because installing alexanderzobnin-grafana-zabbix @ is not reporting the plugin version and at module line 210 ( plugin_name, plugin_version = line.split(' @ ') ) breaks.

ansibot commented 4 years ago

cc @rrey @seuf click here for bot help

seuf commented 4 years ago

ansible grafana modules are now versionned on a new dedicated collection repo : https://github.com/ansible-collections/grafana. Can you please do a new pull requests on this repo ?

gundalow commented 4 years ago

Closing as issue has been raised in Grafana collection