community.grafana.grafana_dashboard module – Manage Grafana dashboards
Note
This module is part of the community.grafana collection (version 1.5.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.grafana
.
To use it in a playbook, specify: community.grafana.grafana_dashboard
.
New in version 1.0.0: of community.grafana
Parameters
Parameter |
Comments |
---|---|
PEM formatted certificate chain file to be used for SSL client authentication. This file can also include the key as well, and if the key is included, client_key is not required |
|
PEM formatted file that contains your private key to be used for SSL client authentication. If client_cert contains both the certificate and key, this option is not required. |
|
Set a commit message for the version history. Only used when
|
|
Public Grafana.com dashboard id to import |
|
Revision of the public grafana dashboard to import Default: “1” |
|
The Grafana folder where this dashboard will be imported to. Default: “General” |
|
The Grafana API key. If set, |
|
The Grafana Organisation ID where the dashboard will be imported / exported. Not used when grafana_api_key is set, because the grafana_api_key only belongs to one organisation.. Default: 1 |
|
Override existing dashboard when state is present. Choices:
|
|
The path to the json file containing the Grafana dashboard to import or export. A http URL is also accepted (since 2.10). Required if |
|
Deprecated since Grafana 5. Use grafana dashboard uid instead. slug of the dashboard. It’s the friendly url name of the dashboard. When If you want to import a json dashboard exported directly from the interface (not from the api), you have to specify the slug parameter because there is no meta section in the exported json. |
|
State of the dashboard. Choices:
|
|
uid of the dashboard to export when |
|
The Grafana URL. |
|
The Grafana password for API authentication. Default: “admin” |
|
The Grafana user for API authentication. Default: “admin” |
|
If Choices:
|
|
If This should only set to Choices:
|
Examples
- hosts: localhost
connection: local
tasks:
- name: Import Grafana dashboard foo
community.grafana.grafana_dashboard:
grafana_url: http://grafana.company.com
grafana_api_key: "{{ grafana_api_key }}"
state: present
commit_message: Updated by ansible
overwrite: yes
path: /path/to/dashboards/foo.json
- name: Import Grafana dashboard Zabbix
community.grafana.grafana_dashboard:
grafana_url: http://grafana.company.com
grafana_api_key: "{{ grafana_api_key }}"
folder: zabbix
dashboard_id: 6098
dashbord_revision: 1
- name: Import Grafana dashboard zabbix
community.grafana.grafana_dashboard:
grafana_url: http://grafana.company.com
grafana_api_key: "{{ grafana_api_key }}"
folder: public
dashboard_url: https://grafana.com/api/dashboards/6098/revisions/1/download
- name: Export dashboard
community.grafana.grafana_dashboard:
grafana_url: http://grafana.company.com
grafana_user: "admin"
grafana_password: "{{ grafana_password }}"
org_id: 1
state: export
uid: "000000653"
path: "/path/to/dashboards/000000653.json"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
uid or slug of the created / deleted / exported dashboard. Returned: success Sample: 51 |
Authors
Thierry Sallé (@seuf)