forked from infra/ansible
homeassistant: Add installation procedures for grafana
This commit is contained in:
parent
3e87601013
commit
6e55e4ff78
@ -41,4 +41,5 @@ mosquitto_bridges:
|
||||
ha_pg_db_pass: "{{ vault_ha_pg_db_pass }}"
|
||||
pgadmin4_db_password: "{{ vault_pgadmin4_db_password }}"
|
||||
pgadmin4_initial_user_email: noby@binary-kitchen.de
|
||||
pgadmin4_initial_user_password: "{{ vault_pgadmin4_initial_user_password }}"
|
||||
pgadmin4_initial_user_password: "{{ vault_pgadmin4_initial_user_password }}"
|
||||
ha_pg_grafana_db_pass: "{{ vault_ha_pg_grafana_db_pass }}"
|
||||
|
@ -16,3 +16,7 @@ ha_pg_db_version: 15
|
||||
ha_pg_db_name: homeassistant
|
||||
ha_pg_db_user: homeassistant
|
||||
ha_pg_db_pass: xxxxx
|
||||
|
||||
ha_pg_grafana_db_name: grafana
|
||||
ha_pg_grafana_db_user: grafana
|
||||
ha_pg_grafana_db_pass: xxxxx
|
||||
|
@ -9,3 +9,8 @@
|
||||
ansible.builtin.service:
|
||||
name: home-assistant
|
||||
state: restarted
|
||||
|
||||
- name: Restart grafana
|
||||
ansible.builtin.service:
|
||||
name: grafana-server
|
||||
state: restarted
|
||||
|
77
roles/homeassistant/tasks/grafana.yml
Normal file
77
roles/homeassistant/tasks/grafana.yml
Normal file
@ -0,0 +1,77 @@
|
||||
---
|
||||
|
||||
- name: Grafana | add GPG signing key
|
||||
become: true
|
||||
ansible.builtin.apt_key:
|
||||
url: "https://apt.grafana.com/gpg.key"
|
||||
state: present
|
||||
validate_certs: true
|
||||
|
||||
- name: Grafana | add official repository
|
||||
become: true
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb https://apt.grafana.com stable main"
|
||||
state: present
|
||||
filename: grafana
|
||||
update_cache: true
|
||||
tags: install
|
||||
|
||||
- name: Grafana | establish dependencies
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop: ["grafana"]
|
||||
tags: install
|
||||
|
||||
- name: Grafana | Configure PostgreSQL database
|
||||
community.general.postgresql_db:
|
||||
name: "{{ ha_pg_grafana_db_name }}"
|
||||
template: template0
|
||||
encoding: utf8
|
||||
become: true
|
||||
become_user: postgres
|
||||
|
||||
- name: Grafana | Configure PostgreSQL user
|
||||
community.general.postgresql_user:
|
||||
db: "{{ ha_pg_grafana_db_name }}"
|
||||
name: "{{ ha_pg_grafana_db_user }}"
|
||||
password: "{{ ha_pg_grafana_db_pass }}"
|
||||
become: true
|
||||
become_user: postgres
|
||||
|
||||
- name: Grafana | GRANT ALL PRIVILEGES ON SCHEMA public TO {{ pgadmin4_db_user }}
|
||||
community.postgresql.postgresql_privs:
|
||||
db: "{{ ha_pg_grafana_db_name }}"
|
||||
privs: ALL
|
||||
type: schema
|
||||
objs: public
|
||||
role: "{{ ha_pg_grafana_db_user }}"
|
||||
become: true
|
||||
become_user: postgres
|
||||
|
||||
- name: GRANT SELECT PRIVILEGES ON DATABASE {{ ha_pg_db_name }} TO {{ ha_pg_grafana_db_user }}
|
||||
community.general.postgresql_privs:
|
||||
db: "{{ ha_pg_db_name }}"
|
||||
privs: SELECT
|
||||
type: table
|
||||
objs: statistics,statistics_meta
|
||||
role: "{{ ha_pg_grafana_db_user }}"
|
||||
become: true
|
||||
become_user: postgres
|
||||
ignore_errors: true
|
||||
|
||||
- name: Grafana | install config file
|
||||
ansible.builtin.template:
|
||||
src: grafana.ini.j2
|
||||
dest: "/etc/grafana/grafana.ini"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Restart grafana
|
||||
|
||||
- name: Grafana | Start service
|
||||
ansible.builtin.service:
|
||||
name: grafana-server
|
||||
state: started
|
||||
enabled: true
|
@ -11,3 +11,4 @@
|
||||
- postgres.yml
|
||||
- systemd.yml
|
||||
- installation.yml
|
||||
- grafana.yml
|
||||
|
1082
roles/homeassistant/templates/grafana.ini.j2
Normal file
1082
roles/homeassistant/templates/grafana.ini.j2
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user