grafana.grafana.datasource module – Manage Data sources in Grafana

Note

This module is part of the grafana.grafana collection (version 0.0.7).

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.

To use it in a playbook, specify: grafana.grafana.datasource.

New in version 0.0.1: of grafana.grafana

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

datasource

dictionary / required

JSON source code for the Data source

grafana_api_key

string / required

CLoud API Key to authenticate with Grafana Cloud.

stack_slug

string / required

Name of the Grafana Cloud stack to which the data source will be added

state

string

State for the Grafana CLoud stack.

Choices:

  • present ← (default)

  • absent

Examples

- name: Create/Update Data sources
  grafana.grafana.datasource:
    datasource: "{{ lookup('ansible.builtin.file', 'datasource.json') }}"
    stack_slug: "{{ stack_slug }}"
    grafana_api_key: "{{ grafana_api_key }}"
    state: present

- name: Delete Data sources
  grafana.grafana.datasource:
    datasource: "{{ lookup('ansible.builtin.file', 'datasource.json') }}"
    stack_slug: "{{ stack_slug }}"
    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

output

dictionary

Dict object containing Data source information

Returned: On success

datasource

dictionary

The response body content for the data source configuration.

Returned: state is present and on success

id

integer

The ID assigned to the data source

Returned: on success

message

string

The message returned after the operation on the Data source

Returned: on success

name

string

The name of the data source defined in the JSON source code

Returned: state is present and on success

Authors

  • Ishan Jain (@ishanjainn)