From 477446c348870219b5389c8d8bd23d0405d2ef5f Mon Sep 17 00:00:00 2001 From: Wilfried OLLIVIER Date: Wed, 10 Jul 2019 17:12:40 +0200 Subject: [PATCH] Bootstrap grafana role --- LICENCE | 13 ++++++++++++ README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++ defaults/main.yml | 23 +++++++++++++++++++++ meta/main.yml | 23 +++++++++++++++++++++ tasks/main.yml | 19 ++++++++++++++++++ tests/inventory | 1 + tests/test.yml | 5 +++++ 7 files changed, 135 insertions(+) create mode 100644 LICENCE create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml create mode 100644 tests/inventory create mode 100644 tests/test.yml diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..5568253 --- /dev/null +++ b/LICENCE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2019 Wilfried OLLIVIER + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/README.md b/README.md new file mode 100644 index 0000000..30646b9 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +galaxy-grafana.ds.influx +======================== + +Add an InfluxDB datasource to Grafana + +Requirements +------------ + +An InfluxDB service up and running + +Role Variables +-------------- + +- grafana_proto: https or http, used by grafana +- grafana_domain: domain name used by grafana +- grafana_port: port used by grafana +- grafana_url_port: port used by grafana in url + +- grafana_admin_user: grafana admin user +- grafana_admin_pass: grafana admin passwd + +- datasource_name: name of the datasource to link grafana with influx +- influx_url: url of inluxdb +- influx_proto: proto http or https used by influx +- influx_port: port used influx +- influx_db_name: influxdb name to link to grafana +- influx_user: influxdb username +- influx_pass: influxdb passe to link to grafana +- grafana_org_id: org ig (number) +- is_default: yes/no is this the default source + +Dependencies +------------ + +None + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - role: galaxy-grafana.ds.influx + +Run tests +--------- + +Ensure galaxy-vagrant is up + + ansible-playbook -i tests/inventory tests/test.yml \ No newline at end of file diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..629e08c --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,23 @@ +--- + +# Protocol and networking stuff +grafana_proto: http +grafana_domain: galaxy-vagrant.example.com +grafana_port: 3000 +grafana_url_port: 3000 + +# Admmin user stuff +grafana_admin_user: admin +grafana_admin_pass: not24get + +# InfluxDB datasource +influx_datasource_setup: true +datasource_name: influxdb-telegraf +influx_url: localhost +influx_proto: http +influx_port: 8086 +influx_db_name: telegraf +influx_user: telegraf +influx_pass: not24get +grafana_org_id: 1 +is_default: yes \ No newline at end of file diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..3a32c2d --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,23 @@ +galaxy_info: + author: Wilfried OLLIVIER + description: Galaxy role to add an InfluxDB data source to Grafana + company: none + + license: WTFPL + + min_ansible_version: 2.4 + + platforms: + - name: Debian + versions: + - Stretch + - Buster + + galaxy_tags: + - grafana + - datasource + - influx + - debian + - timeseries + +dependencies: [] \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..7b5b4dd --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,19 @@ +--- + +# https://grafana.com/docs/installation/debian/ + +- name: Create InfluxDB datasource + grafana_datasource: + name: "{{ datasource_name }}" + grafana_url: "{{ grafana_proto }}://{{ grafana_domain }}:{{ grafana_port }}" + grafana_user: "{{ grafana_admin_user }}" + grafana_password: "{{ grafana_admin_pass }}" + org_id: "{{ grafana_org_id }}" + ds_type: "influxdb" + url: "{{ influx_proto }}://{{ influx_url }}:{{ influx_port }}" + database: "{{ influx_db_name }}" + basic_auth_user: "{{ influx_user }}" + basic_auth_password: "{{ influx_pass }}" + is_default: "{{ is_default }}" + time_interval: ">10s" + when: influx_datasource_setup \ No newline at end of file diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..38d0757 --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +galaxy-vagrant.example.com diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..820b154 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: galaxy-vagrant.example.com + remote_user: root + roles: + - role: ../galaxy-grafana.ds.influx \ No newline at end of file