From 4e4cd461027bce28f8ca1693f61d7da7a0fe725d Mon Sep 17 00:00:00 2001 From: David Kilias Date: Fri, 11 Nov 2022 23:30:04 +0100 Subject: [PATCH] feat: :sparkles: add playbook for grafana configuration --- configure-grafana.yml | 31 +++++++++++++++++++++++++++++++ host-pottwal.yml | 6 +++--- host_vars/localhost/vars.yml | 10 ++++++++++ host_vars/localhost/vault | 10 ++++++++++ host_vars/pottwal.n39.eu/vars.yml | 1 + requirements.yml | 2 ++ 6 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 configure-grafana.yml create mode 100644 host_vars/localhost/vars.yml create mode 100644 host_vars/localhost/vault diff --git a/configure-grafana.yml b/configure-grafana.yml new file mode 100644 index 0000000..5453b29 --- /dev/null +++ b/configure-grafana.yml @@ -0,0 +1,31 @@ +--- +- name: Configure Grafana + hosts: localhost + tasks: + - name: create netz39 user + community.grafana.grafana_user: + url: "https://{{ hostvars['pottwal.n39.eu']['grafana_domain_name'] }}" + url_username: admin + url_password: "{{ hostvars['pottwal.n39.eu']['grafana_admin_password'] }}" + name: "{{ item.name }}" + email: "{{ item.email }}" + login: "{{ item.login }}" + password: "{{ item.password }}" + is_admin: true + state: present + loop: "{{ grafana_users }}" + + - name: Create influxdb datasource + community.grafana.grafana_datasource: + name: "datasource-influxdb" + url: "https://{{ hostvars['pottwal.n39.eu']['grafana_domain_name'] }}" + url_username: admin + url_password: "{{ hostvars['pottwal.n39.eu']['grafana_admin_password'] }}" + org_id: "1" + ds_type: "influxdb" + ds_url: "https://{{ hostvars['pottwal.n39.eu']['influxdb_domain_name'] }}:8086" + database: "{{ item.database }}" + user: "{{ item.user }}" + password: "{{ item.password }}" + time_interval: ">10s" + loop: "{{ grafana_datasources }}" \ No newline at end of file diff --git a/host-pottwal.yml b/host-pottwal.yml index ae833e0..e4f6791 100644 --- a/host-pottwal.yml +++ b/host-pottwal.yml @@ -22,7 +22,7 @@ - conference.jabber.n39.eu deploy_cert_hook: "docker exec prosody prosodyctl --root cert import ${DOMAIN} /var/lib/dehydrated/certs" - name: redmine.n39.eu - - name: influx.n39.eu + - name: "{{ influxdb_domain_name }}" - name: uptime.n39.eu - name: "{{ grafana_domain_name }}" - role: penguineer.dehydrated_cron @@ -279,11 +279,11 @@ volumes: - "{{ data_dir }}/influxdb:/var/lib/influxdb2" - - name: Setup proxy site influx.n39.eu + - name: Setup proxy site {{ influxdb_domain_name }} include_role: name: setup_http_site_proxy vars: - site_name: influx.n39.eu + site_name: "{{ influxdb_domain_name }}" proxy_port: "{{ influxdb_host_port }}" # Expected setup for the data directory diff --git a/host_vars/localhost/vars.yml b/host_vars/localhost/vars.yml new file mode 100644 index 0000000..20ccd5d --- /dev/null +++ b/host_vars/localhost/vars.yml @@ -0,0 +1,10 @@ +grafana_users: + - name: Netz39 + email: accounts+grafana@netz39.de + login: netz39 + password: "{{ vault_grafana_user_password }}" + +grafana_datasources: + - database: "power_usage" + user: "grafana" + password: "{{ vault_influx_user_pasword }}" \ No newline at end of file diff --git a/host_vars/localhost/vault b/host_vars/localhost/vault new file mode 100644 index 0000000..b66a087 --- /dev/null +++ b/host_vars/localhost/vault @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.1;AES256 +63656563373764373039316666323737643030646338353161383534333266363663346537353465 +3966323233643737393035643461663533373230656232360a626165653365386339376563303531 +38643864353234663839326631633634303233353736393631303834343839363831616132636565 +6462353664653130620a306435303963643663303363653738616535386465623336666538626161 +30383732393464313139343464626131303464393564333865633861303136363035623534656435 +37376636663564666234636164623339383136653565366432343762396138663763356330383832 +62386363326164363165373265623863323634363538626132366132616135646332366133323535 +39633831616463633637636362623733303039313666666662616666383232656231653363643538 +3864 diff --git a/host_vars/pottwal.n39.eu/vars.yml b/host_vars/pottwal.n39.eu/vars.yml index 35a5522..1139a67 100644 --- a/host_vars/pottwal.n39.eu/vars.yml +++ b/host_vars/pottwal.n39.eu/vars.yml @@ -23,6 +23,7 @@ redmine_database: redmine redmine_database_password: "{{ vault_redmine_database_password }}" influxdb_host_port: 8088 +influxdb_domain_name: influx.n39.eu influxdb_image: influxdb:2.4-alpine influxdb_init_username: admin influxdb_init_password: "{{ vault_influxdb_init_password }}" diff --git a/requirements.yml b/requirements.yml index cc463d4..b8259ae 100644 --- a/requirements.yml +++ b/requirements.yml @@ -9,3 +9,5 @@ version: v1.0.0 - src: git+https://github.com/maz3max/ble-keykeeper-role.git version: v1.1.0 +- src: community.grafana + version: 1.5.3