From 4e4cd461027bce28f8ca1693f61d7da7a0fe725d Mon Sep 17 00:00:00 2001 From: David Kilias Date: Fri, 11 Nov 2022 23:30:04 +0100 Subject: [PATCH 1/2] 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 From cc0dcb31880520c97b765210e664e892c86143d3 Mon Sep 17 00:00:00 2001 From: David Kilias Date: Sat, 12 Nov 2022 15:22:34 +0100 Subject: [PATCH 2/2] update requirements.yml to correctly install collection --- configure-grafana.yml | 20 +++----------------- host_vars/localhost/vars.yml | 5 ----- host_vars/localhost/vault | 15 ++++++--------- requirements.yml | 27 +++++++++++++++------------ 4 files changed, 24 insertions(+), 43 deletions(-) diff --git a/configure-grafana.yml b/configure-grafana.yml index 5453b29..13df535 100644 --- a/configure-grafana.yml +++ b/configure-grafana.yml @@ -2,11 +2,12 @@ - name: Configure Grafana hosts: localhost tasks: - - name: create netz39 user + - 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'] }}" + url_password: > + "{{ hostvars['pottwal.n39.eu']['grafana_admin_password'] }}" name: "{{ item.name }}" email: "{{ item.email }}" login: "{{ item.login }}" @@ -14,18 +15,3 @@ 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_vars/localhost/vars.yml b/host_vars/localhost/vars.yml index 20ccd5d..cd3c13d 100644 --- a/host_vars/localhost/vars.yml +++ b/host_vars/localhost/vars.yml @@ -3,8 +3,3 @@ grafana_users: 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 index b66a087..540574d 100644 --- a/host_vars/localhost/vault +++ b/host_vars/localhost/vault @@ -1,10 +1,7 @@ $ANSIBLE_VAULT;1.1;AES256 -63656563373764373039316666323737643030646338353161383534333266363663346537353465 -3966323233643737393035643461663533373230656232360a626165653365386339376563303531 -38643864353234663839326631633634303233353736393631303834343839363831616132636565 -6462353664653130620a306435303963643663303363653738616535386465623336666538626161 -30383732393464313139343464626131303464393564333865633861303136363035623534656435 -37376636663564666234636164623339383136653565366432343762396138663763356330383832 -62386363326164363165373265623863323634363538626132366132616135646332366133323535 -39633831616463633637636362623733303039313666666662616666383232656231653363643538 -3864 +66303836663730383331396265363534666661326163643634306332613038653530333333326236 +3163343062656262363364373561646163623666623738620a373039353861306261643435346330 +64333139336536346130646435393235643838356634636233363035306437353230333864346437 +6562366564373461380a393265656437303531396234613266383334373762646536643733323565 +61366261303965316263303434313462656661666530636662306633663336316462303339633531 +3832643731646535306562326162363864646338343165633834 diff --git a/requirements.yml b/requirements.yml index b8259ae..a733ef5 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,13 +1,16 @@ --- -- src: hifis.unattended_upgrades - version: v1.12.2 -- src: git+https://github.com/adriagalin/ansible.timezone.git - version: 3.0.0 -- src: git+https://github.com/24367dfa/ansible-role-dehydrated.git - version: 1.0.3 -- src: penguineer.dehydrated_cron - 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 +roles: + - src: hifis.unattended_upgrades + version: v1.12.2 + - src: git+https://github.com/adriagalin/ansible.timezone.git + version: 3.0.0 + - src: git+https://github.com/24367dfa/ansible-role-dehydrated.git + version: 1.0.3 + - src: penguineer.dehydrated_cron + version: v1.0.0 + - src: git+https://github.com/maz3max/ble-keykeeper-role.git + version: v1.1.0 + +collections: + - name: community.grafana + version: 1.5.3