ansible / ansible.builtin / v2.5.15 / module / grafana_datasource Manage Grafana datasources | "added in version" 2.5 of ansible.builtin" Authors: Thierry Sallé (@tsalle) preview | supported by communityansible.builtin.grafana_datasource (v2.5.15) — module
pip
Install with pip install ansible==2.5.15
Create/update/delete Grafana datasources via API.
--- - name: Create elasticsearch datasource grafana_datasource: name: my_elastic grafana_url: http://grafana.company.com type: elasticsearch url: https://elasticsearch.company.com:9200 database: my-index_* basic_auth: yes basic_auth_user: grafana basic_auth_password: xxxxxxxx json_data: '{"esVersion":5, "timeField": "@timestamp"}' state: present
url: description: - The URL of the datasource. required: true name: description: - The name of the datasource. required: true user: description: - The datasource login user for influxdb datasources. state: choices: - absent - present default: present description: - Status of the datasource access: choices: - direct - proxy default: proxy description: - The access mode for this datasource. org_id: default: 1 description: - Grafana Organisation ID in which the datasource should be created. - Not used when C(grafana_api_key) is set, because the C(grafana_api_key) only belong to one organisation. ds_type: choices: - elasticsearch - graphite - influxdb - mysql - opentsdb - postgres - prometheus description: - The type of the datasource. required: true sslmode: choices: - disable - require - verify-ca - verify-full description: - SSL mode for C(postgres) datasoure type. database: description: - Name of the database for the datasource. - This options is required when the C(ds_type) is C(influxdb), C(elasticsearch) (index name), C(mysql) or C(postgres). required: false interval: choices: - '' - Hourly - Daily - Weekly - Monthly - Yearly description: - For elasticsearch C(ds_type), this is the index pattern used. password: description: - The datasource password es_version: choices: - 2 - 5 - 56 default: 5 description: - Elasticsearch version (for C(ds_type = elasticsearch) only) - Version 56 is for elasticsearch 5.6+ where tou can specify the C(max_concurrent_shard_requests) option. is_default: default: 'no' description: - Make this datasource the default one. type: bool time_field: default: timestamp description: - Name of the time field in elasticsearch ds. - For example C(@timestamp) grafana_url: description: - The Grafana URL. required: true tls_ca_cert: description: - The TLS CA certificate for self signed certificates. - Only used when C(tls_client_cert) and C(tls_client_key) are set. grafana_user: default: admin description: - The Grafana API user. tsdb_version: choices: - 1 - 2 - 3 default: 1 description: - The opentsdb version. - Use C(1) for <=2.1, C(2) for ==2.2, C(3) for ==2.3. time_interval: description: - Minimum group by interval for C(influxdb) or C(elasticsearch) datasources. - for example C(>10s) tls_client_key: description: - The client TLS private key - Starts with ----- BEGIN RSA PRIVATE KEY ----- validate_certs: default: 'yes' description: - Whether to validate the Grafana certificate. type: bool basic_auth_user: description: - The datasource basic auth user. - Setting this option with basic_auth_password will enable basic auth. grafana_api_key: description: - The Grafana API key. - If set, C(grafana_user) and C(grafana_password) will be ignored. tls_client_cert: description: - The client TLS certificate. - If C(tls_client_cert) and C(tls_client_key) are set, this will enable TLS authentication. - Starts with ----- BEGIN CERTIFICATE ----- tsdb_resolution: choices: - millisecond - second default: second description: - The opentsdb time resolution. grafana_password: default: admin description: - The Grafana API password. with_credentials: default: 'no' description: - Whether credentials such as cookies or auth headers should be sent with cross-site requests. type: bool basic_auth_password: description: - The datasource basic auth password, when C(basic auth) is C(yes). max_concurrent_shard_requests: default: 256 description: - Starting with elasticsearch 5.6, you can specify the max concurrent shard per requests.
after: description: datasource updated by module returned: changed sample: access: proxy basicAuth: false database: test_* id: 1035 isDefault: false jsonData: esVersion: 5 timeField: '@timestamp' timeInterval: 10s name: grafana_datasource_test orgId: 1 password: '' type: elasticsearch url: http://elastic.company.com:9200 user: '' withCredentials: false type: dict before: description: datasource returned by grafana api returned: changed sample: access: proxy basicAuth: false database: test_* id: 1035 isDefault: false jsonData: esVersion: 5 timeField: '@timestamp' timeInterval: 1m name: grafana_datasource_test orgId: 1 password: '' type: elasticsearch url: http://elastic.company.com:9200 user: '' withCredentials: false type: dict id: description: Id of the datasource returned: success sample: 42 type: int name: description: name of the datasource created. returned: success sample: test-ds type: string