W3cubDocs

/Ansible

community.grafana.grafana_dashboard – Manage Grafana dashboards

Note

This plugin is part of the community.grafana collection (version 1.2.3).

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

Synopsis

  • Create, update, delete, export Grafana dashboards via API.

Parameters

Parameter Choices/Defaults Comments
client_cert
path
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
client_key
path
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.
commit_message
string
Set a commit message for the version history.
Only used when state is present.
message alias is deprecated in Ansible 2.10, since it is used internally by Ansible Core Engine.

aliases: message
dashboard_id
string
added in 1.0.0 of community.grafana
Public Grafana.com dashboard id to import
dashboard_revision
string
added in 1.0.0 of community.grafana
Default:
1
Revision of the public grafana dashboard to import
folder
string
added in 1.0.0 of community.grafana
Default:
"General"
The Grafana folder where this dashboard will be imported to.
grafana_api_key
string
The Grafana API key.
If set, url_username and url_password will be ignored.
org_id
integer
Default:
1
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..
overwrite
boolean
    Choices:
  • no
  • yes
Override existing dashboard when state is present.
path
string
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 state is export or present.

aliases: dashboard_url
slug
string
Deprecated since Grafana 5. Use grafana dashboard uid instead.
slug of the dashboard. It's the friendly url name of the dashboard.
When state is present, this parameter can override the slug in the meta section of the json file.
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
string
    Choices:
  • absent
  • export
  • present
State of the dashboard.
uid
string
added in 1.0.0 of community.grafana
uid of the dashboard to export when state is export or absent.
url
string / required
The Grafana URL.

aliases: grafana_url
url_password
string
Default:
"admin"
The Grafana password for API authentication.

aliases: grafana_password
url_username
string
Default:
"admin"
The Grafana user for API authentication.

aliases: grafana_user
use_proxy
boolean
    Choices:
  • no
  • yes
If no, it will not use a proxy, even if one is defined in an environment variable on the target hosts.
validate_certs
boolean
    Choices:
  • no
  • yes
If no, SSL certificates will not be validated.
This should only set to no used on personally controlled sites using self-signed certificates.

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 Returned Description
uid
string
success
uid or slug of the created / deleted / exported dashboard.

Sample:
51


Authors

  • Thierry Sallé (@seuf)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_dashboard_module.html