cloudalchemy / ansible-grafana

Platform for analytics and monitoring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot install dashboards ([Errno 2] No such file or directory)

nop33 opened this issue · comments

What happened?

Specified dashboards could not be installed

Did you expect to see some different?

The dashboards to have been installed

How to reproduce it (as minimally and precisely as possible):

Just define the following variable:

grafana_dashboards:
  - dashboard_id: 3662
    revision_id: 2
    datasource: prometheus

Link to the dashboard: https://grafana.com/grafana/dashboards/3662

Environment

  • Role version:

    0.17.0

  • Ansible version information:

    2.10.5

  • Variables:

grafana_dashboards:
  - dashboard_id: 3662
    revision_id: 2
    datasource: prometheus
  • Ansible playbook execution Logs:
TASK [cloudalchemy.grafana : download grafana dashboard from grafana.net to local directory] *************************
FAILED - RETRYING: download grafana dashboard from grafana.net to local directory (5 retries left).
FAILED - RETRYING: download grafana dashboard from grafana.net to local directory (4 retries left).
FAILED - RETRYING: download grafana dashboard from grafana.net to local directory (3 retries left).
FAILED - RETRYING: download grafana dashboard from grafana.net to local directory (2 retries left).
FAILED - RETRYING: download grafana dashboard from grafana.net to local directory (1 retries left).
failed: [monitoring.plte.ch] (item={'dashboard_id': 3662, 'revision_id': 2, 'datasource': 'prometheus'}) => {"ansible_loop_var": "item", "attempts": 5, "changed": false, "cmd": "curl --fail --compressed https://grafana.com/api/dashboards/3662/revisions/2/download -o /tmp/ansible.ly5d9mvh/3662.json", "item": {"dashboard_id": 3662, "datasource": "prometheus", "revision_id": 2}, "msg": "[Errno 2] No such file or directory: b'curl'", "rc": 2}

Anything else we need to know?:

The dashboard URL works, I can fetch it:

curl --fail --compressed https://grafana.com/api/dashboards/3662/revisions/2/download

When I replace curl with get_url, it works. However, I see that in #77 it was changed from get_url to curl because:

[some] dashboards are so big that they don't fit into some cache used by get_url module

get_url:
  url: "https://grafana.com/api/dashboards/{{ item.dashboard_id }}/revisions/{{ item.revision_id }}/download"
  dest: "{{ _tmp_dashboards.path }}/{{ item.dashboard_id }}.json"

I tested all dashboards that were said to have an issue when using get_url (6239, 704 and 5566) and I am happy to report that it worked for all of them:

TASK [cloudalchemy.grafana : download grafana dashboard from grafana.net to local directory] *************************
ok: [monitoring.plte.ch] => (item={'dashboard_id': 3662, 'revision_id': 2, 'datasource': 'PL Prometheus'})
ok: [monitoring.plte.ch] => (item={'dashboard_id': 12019, 'revision_id': 2, 'datasource': 'PL Loki'})
ok: [monitoring.plte.ch] => (item={'dashboard_id': 6239, 'revision_id': 1, 'datasource': 'PL Prometheus'})
ok: [monitoring.plte.ch] => (item={'dashboard_id': 704, 'revision_id': 1, 'datasource': 'PL Prometheus'})
ok: [monitoring.plte.ch] => (item={'dashboard_id': 5566, 'revision_id': 5, 'datasource': 'PL Prometheus'})

TASK [cloudalchemy.grafana : Set the correct data source name in the dashboard] **************************************
ok: [monitoring.plte.ch] => (item={'dashboard_id': 3662, 'revision_id': 2, 'datasource': 'PL Prometheus'})
ok: [monitoring.plte.ch] => (item={'dashboard_id': 12019, 'revision_id': 2, 'datasource': 'PL Loki'})
ok: [monitoring.plte.ch] => (item={'dashboard_id': 6239, 'revision_id': 1, 'datasource': 'PL Prometheus'})
ok: [monitoring.plte.ch] => (item={'dashboard_id': 704, 'revision_id': 1, 'datasource': 'PL Prometheus'})
ok: [monitoring.plte.ch] => (item={'dashboard_id': 5566, 'revision_id': 5, 'datasource': 'PL Prometheus'})

TASK [cloudalchemy.grafana : Import grafana dashboards through API] **************************************************
[WARNING]: Unable to find 'dashboards' in expected paths (use -vvvvv to see paths)
skipping: [monitoring.plte.ch] => (item=None)
skipping: [monitoring.plte.ch] => (item=None)
skipping: [monitoring.plte.ch] => (item=None)
skipping: [monitoring.plte.ch] => (item=None)
skipping: [monitoring.plte.ch] => (item=None)
skipping: [monitoring.plte.ch]

TASK [cloudalchemy.grafana : Create/Update dashboards file (provisioning)] *******************************************
ok: [monitoring.plte.ch]

TASK [cloudalchemy.grafana : Register previously copied dashboards] **************************************************
skipping: [monitoring.plte.ch]

TASK [cloudalchemy.grafana : Import grafana dashboards] **************************************************************
[WARNING]: Unable to find 'dashboards' in expected paths (use -vvvvv to see paths)
ok: [monitoring.plte.ch] => (item=/tmp/ansible.uq60auor/3662.json)
changed: [monitoring.plte.ch] => (item=/tmp/ansible.uq60auor/704.json)
changed: [monitoring.plte.ch] => (item=/tmp/ansible.uq60auor/5566.json)
ok: [monitoring.plte.ch] => (item=/tmp/ansible.uq60auor/12019.json)
ok: [monitoring.plte.ch] => (item=/tmp/ansible.uq60auor/6239.json)

So, I will consider switching back to get_url is a valid solution and switch back to it. I'll create a PR.

commented

I just tried but I cannot reproduce your issue

I've had this problem on my own debian 10 hosts for months now, thanks for linking to the PR that fixes it.

This role has been deprecated in favor of a the grafana-ansible-collection collection.