grafana.grafana.datasource module – Manage Data sources in Grafana
Note
This module is part of the grafana.grafana collection (version 5.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 grafana.grafana
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: grafana.grafana.datasource
.
New in grafana.grafana 0.0.1
Synopsis
Create, Update and delete Data sources using Ansible.
Requirements
The below requirements are needed on the host that executes this module.
requests >= 1.0.0
Parameters
Parameter |
Comments |
---|---|
JSON source code for the Data source. |
|
Grafana API Key to authenticate with Grafana Cloud. |
|
URL of the Grafana instance. |
|
State for the Grafana Datasource. Choices:
|
Notes
Note
Does not support
check_mode
.Does not support
Idempotency
.
Examples
- name: Create/Update Data sources
grafana.grafana.datasource:
dataSource: |
{
"name": "Prometheus",
"type": "prometheus",
"access": "proxy",
"url": "http://localhost:9090",
"jsonData": {
"httpMethod": "POST",
"manageAlerts": true,
"prometheusType": "Prometheus",
"cacheLevel": "High"
}
}
grafana_url: "{{ grafana_url }}"
grafana_api_key: "{{ grafana_api_key }}"
state: present
- name: Delete Data sources
grafana.grafana.datasource:
dataSource: "{{ lookup('ansible.builtin.file', 'datasource.json') }}"
grafana_url: "{{ grafana_url }}"
grafana_api_key: "{{ grafana_api_key }}"
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Dict object containing Data source information. Returned: On success |
|
The response body content for the data source configuration. Returned: state is present and on success Sample: |
|
The ID assigned to the data source. Returned: on success Sample: |
|
The message returned after the operation on the Data source. Returned: on success Sample: |
|
The name of the data source defined in the JSON source code. Returned: state is present and on success Sample: |