ansible-grafana icon indicating copy to clipboard operation
ansible-grafana copied to clipboard

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

Open nop33 opened this issue 4 years ago • 4 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

nop33 avatar Feb 03 '21 10:02 nop33

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"

nop33 avatar Feb 03 '21 11:02 nop33

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.

nop33 avatar Feb 03 '21 11:02 nop33

I just tried but I cannot reproduce your issue

tabic avatar Feb 19 '21 15:02 tabic

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

baronfel avatar May 24 '21 15:05 baronfel

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

SuperQ avatar May 31 '23 04:05 SuperQ