[WIP] Perform installation of HomeAssistant host #71

Draft
noby wants to merge 13 commits from noby/ansible:homeassistant into master
6 changed files with 1171 additions and 1 deletions
Showing only changes of commit 6e55e4ff78 - Show all commits

View File

@ -42,3 +42,4 @@ ha_pg_db_pass: "{{ vault_ha_pg_db_pass }}"
pgadmin4_db_password: "{{ vault_pgadmin4_db_password }}" pgadmin4_db_password: "{{ vault_pgadmin4_db_password }}"
pgadmin4_initial_user_email: noby@binary-kitchen.de 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 }}"

View File

@ -16,3 +16,7 @@ ha_pg_db_version: 15
ha_pg_db_name: homeassistant ha_pg_db_name: homeassistant
ha_pg_db_user: homeassistant ha_pg_db_user: homeassistant
ha_pg_db_pass: xxxxx ha_pg_db_pass: xxxxx
ha_pg_grafana_db_name: grafana
ha_pg_grafana_db_user: grafana
ha_pg_grafana_db_pass: xxxxx

View File

@ -9,3 +9,8 @@
ansible.builtin.service: ansible.builtin.service:
name: home-assistant name: home-assistant
state: restarted state: restarted
- name: Restart grafana
ansible.builtin.service:
name: grafana-server
state: restarted

View 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

View File

@ -11,3 +11,4 @@
- postgres.yml - postgres.yml
- systemd.yml - systemd.yml
- installation.yml - installation.yml
- grafana.yml

File diff suppressed because it is too large Load Diff