From 6e15f45a83837c735650bbcde0d43716daf16532 Mon Sep 17 00:00:00 2001 From: Anarion Date: Mon, 25 Dec 2023 14:19:56 +0100 Subject: [PATCH] :sparkles: Adds HA Fusion --- README.md | 1 + nas.yml | 4 ++ roles/hafusion/defaults/main.yml | 23 ++++++++++ roles/hafusion/docs/hafusion.md | 11 +++++ roles/hafusion/molecule/default/molecule.yml | 6 +++ .../hafusion/molecule/default/side_effect.yml | 10 +++++ roles/hafusion/molecule/default/verify.yml | 19 ++++++++ .../molecule/default/verify_stopped.yml | 19 ++++++++ roles/hafusion/tasks/main.yml | 43 +++++++++++++++++++ .../applications/home-automation/hafusion.md | 14 ++++++ 10 files changed, 150 insertions(+) create mode 100644 roles/hafusion/defaults/main.yml create mode 100644 roles/hafusion/docs/hafusion.md create mode 100644 roles/hafusion/molecule/default/molecule.yml create mode 100644 roles/hafusion/molecule/default/side_effect.yml create mode 100644 roles/hafusion/molecule/default/verify.yml create mode 100644 roles/hafusion/molecule/default/verify_stopped.yml create mode 100644 roles/hafusion/tasks/main.yml create mode 100644 website/docs/applications/home-automation/hafusion.md diff --git a/README.md b/README.md index 8622ffa274..e9f47953ec 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ If you have a spare domain name you can configure applications to be accessible * [Graylog](https://www.graylog.org/) - Free and open source log management * [Grocy](https://grocy.info/) - web-based self-hosted groceries & household management solution for your home * [Guacamole](https://guacamole.apache.org/) - Web based remote desktop gateway, supports VNC, RDP and SSH +* [HA Fusion](https://github.com/matt8707/ha-fusion) - A modern, easy-to-use and performant custom Home Assistant dashboard * [healthchecks.io](https://healthchecks.io/) - Ensure your NAS is online and get notified otherwise * [Heimdall](https://heimdall.site/) - Home server dashboard * [Home Assistant](https://www.home-assistant.io) - Open source home automation diff --git a/nas.yml b/nas.yml index bfedc26503..31041ffa22 100644 --- a/nas.yml +++ b/nas.yml @@ -250,6 +250,10 @@ tags: - guacamole + - role: hafusion + tags: + - hafusion + - role: healthchecks.io tags: - healthchecks.io diff --git a/roles/hafusion/defaults/main.yml b/roles/hafusion/defaults/main.yml new file mode 100644 index 0000000000..2f3d0e563f --- /dev/null +++ b/roles/hafusion/defaults/main.yml @@ -0,0 +1,23 @@ +--- +hafusion_enabled: false +hafusion_available_externally: false + +# directories +hafusion_data_directory: "{{ docker_home }}/hafusion" + +# network +hafusion_port: "5051" +hafusion_hostname: "hafusion" + +# specs +hafusion_memory: 1g + +# docker +hafusion_container_name: hafusion +hafusion_image_name: "ghcr.io/matt8707/ha-fusion" +hafusion_image_version: latest +hafusion_user_id: "1000" +hafusion_group_id: "1000" + +# hafusion +hafusion_hass_url: "http://192.168.1.241:8123" diff --git a/roles/hafusion/docs/hafusion.md b/roles/hafusion/docs/hafusion.md new file mode 100644 index 0000000000..3e2e67f4d1 --- /dev/null +++ b/roles/hafusion/docs/hafusion.md @@ -0,0 +1,11 @@ +# HA Fusion + +Homepage: + +A modern, easy-to-use and performant custom Home Assistant dashboard + +## Usage + +Set `hafusion_enabled: true` in your `inventories//nas.yml` file. + +hafusion web interface can be found at . diff --git a/roles/hafusion/molecule/default/molecule.yml b/roles/hafusion/molecule/default/molecule.yml new file mode 100644 index 0000000000..02743b2053 --- /dev/null +++ b/roles/hafusion/molecule/default/molecule.yml @@ -0,0 +1,6 @@ +--- +provisioner: + inventory: + group_vars: + all: + hafusion_enabled: true diff --git a/roles/hafusion/molecule/default/side_effect.yml b/roles/hafusion/molecule/default/side_effect.yml new file mode 100644 index 0000000000..f8366308f8 --- /dev/null +++ b/roles/hafusion/molecule/default/side_effect.yml @@ -0,0 +1,10 @@ +--- +- name: Stop + hosts: all + become: true + tasks: + - name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role" + ansible.builtin.include_role: + name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" + vars: + hafusion_enabled: false diff --git a/roles/hafusion/molecule/default/verify.yml b/roles/hafusion/molecule/default/verify.yml new file mode 100644 index 0000000000..4cb6f47574 --- /dev/null +++ b/roles/hafusion/molecule/default/verify.yml @@ -0,0 +1,19 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Include vars + ansible.builtin.include_vars: + file: ../../defaults/main.yml + + - name: Get hafusion container state + community.docker.docker_container: + name: "{{ hafusion_container_name }}" + register: result + + - name: Check if hafusion containers are running + ansible.builtin.assert: + that: + - result.container['State']['Status'] == "running" + - result.container['State']['Restarting'] == false diff --git a/roles/hafusion/molecule/default/verify_stopped.yml b/roles/hafusion/molecule/default/verify_stopped.yml new file mode 100644 index 0000000000..bc3829ec6f --- /dev/null +++ b/roles/hafusion/molecule/default/verify_stopped.yml @@ -0,0 +1,19 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Include vars + ansible.builtin.include_vars: + file: ../../defaults/main.yml + + - name: Try and stop and remove hafusion + community.docker.docker_container: + name: "{{ hafusion_container_name }}" + state: absent + register: result + + - name: Check if hafusion is stopped + ansible.builtin.assert: + that: + - not result.changed diff --git a/roles/hafusion/tasks/main.yml b/roles/hafusion/tasks/main.yml new file mode 100644 index 0000000000..dbe80d0545 --- /dev/null +++ b/roles/hafusion/tasks/main.yml @@ -0,0 +1,43 @@ +--- +- name: Start HA Fusion + block: + - name: Create HA Fusion Directories + ansible.builtin.file: + path: "{{ item }}" + state: directory + with_items: + - "{{ hafusion_data_directory }}" + + - name: Create HA Fusion Docker Container + community.docker.docker_container: + container_default_behavior: no_defaults + name: "{{ hafusion_container_name }}" + image: "{{ hafusion_image_name }}:{{ hafusion_image_version }}" + pull: true + volumes: + - "{{ hafusion_data_directory }}/data:/app/data" + ports: + - "{{ hafusion_port }}:5050" + env: + TZ: "{{ ansible_nas_timezone }}" + PUID: "{{ hafusion_user_id | quote }}" + PGID: "{{ hafusion_group_id | quote }}" + HASS_URL: "{{ hafusion_hass_url }}" + restart_policy: unless-stopped + memory: "{{ hafusion_memory }}" + labels: + traefik.enable: "{{ hafusion_available_externally | string }}" + traefik.http.routers.hafusion.rule: "Host(`{{ hafusion_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.hafusion.tls.certresolver: "letsencrypt" + traefik.http.routers.hafusion.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.hafusion.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.hafusion.loadbalancer.server.port: "5050" + when: hafusion_enabled is true + +- name: Stop HA Fusion + block: + - name: Stop HA Fusion + community.docker.docker_container: + name: "{{ hafusion_container_name }}" + state: absent + when: hafusion_enabled is false diff --git a/website/docs/applications/home-automation/hafusion.md b/website/docs/applications/home-automation/hafusion.md new file mode 100644 index 0000000000..78d35b73b9 --- /dev/null +++ b/website/docs/applications/home-automation/hafusion.md @@ -0,0 +1,14 @@ +--- +title: "HA Fusion" +description: "A modern, easy-to-use and performant custom Home Assistant dashboard" +--- + +Homepage: + +A modern, easy-to-use and performant custom Home Assistant dashboard + +## Usage + +Set `hafusion_enabled: true` in your `inventories//nas.yml` file. + +hafusion web interface can be found at .