feat: add playbook for grafana configuration

This commit is contained in:
David Kilias 2022-11-11 23:30:04 +01:00
parent ce770f9467
commit 4e4cd46102
6 changed files with 57 additions and 3 deletions

31
configure-grafana.yml Normal file
View file

@ -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 }}"

View file

@ -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

View file

@ -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 }}"

10
host_vars/localhost/vault Normal file
View file

@ -0,0 +1,10 @@
$ANSIBLE_VAULT;1.1;AES256
63656563373764373039316666323737643030646338353161383534333266363663346537353465
3966323233643737393035643461663533373230656232360a626165653365386339376563303531
38643864353234663839326631633634303233353736393631303834343839363831616132636565
6462353664653130620a306435303963643663303363653738616535386465623336666538626161
30383732393464313139343464626131303464393564333865633861303136363035623534656435
37376636663564666234636164623339383136653565366432343762396138663763356330383832
62386363326164363165373265623863323634363538626132366132616135646332366133323535
39633831616463633637636362623733303039313666666662616666383232656231653363643538
3864

View file

@ -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 }}"

View file

@ -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