From ddc843b3d5320016014157a59f723f26908f6353 Mon Sep 17 00:00:00 2001 From: Stavros Kois Date: Wed, 5 Feb 2025 19:27:39 +0200 Subject: [PATCH] home-assistant --- cspell.config.yaml | 1 + ix-dev/stable/home-assistant/app.yaml | 4 +- ix-dev/stable/home-assistant/migrations.yaml | 4 ++ .../migrations/ip_port_migration | 23 +++++++++ ix-dev/stable/home-assistant/questions.yaml | 50 ++++++++++++++++--- .../templates/docker-compose.yaml | 5 +- .../templates/test_values/basic-values.yaml | 4 +- 7 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 ix-dev/stable/home-assistant/migrations.yaml create mode 100755 ix-dev/stable/home-assistant/migrations/ip_port_migration diff --git a/cspell.config.yaml b/cspell.config.yaml index d0f6ab53a1..f3c1823924 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -10,6 +10,7 @@ words: - audiobookshelf - authentik - autobrr + - automations - backblaze - bazarr - bindir diff --git a/ix-dev/stable/home-assistant/app.yaml b/ix-dev/stable/home-assistant/app.yaml index a86259a7fe..b30a2495d7 100644 --- a/ix-dev/stable/home-assistant/app.yaml +++ b/ix-dev/stable/home-assistant/app.yaml @@ -1,3 +1,5 @@ +annotations: + min_scale_version: '25.04' app_version: 2025.1.4 capabilities: - description: Home Assistant is able to change file ownership. @@ -45,4 +47,4 @@ sources: - https://github.com/truenas/charts/tree/master/charts/home-assistant title: Home Assistant train: stable -version: 1.4.19 +version: 1.5.0 diff --git a/ix-dev/stable/home-assistant/migrations.yaml b/ix-dev/stable/home-assistant/migrations.yaml new file mode 100644 index 0000000000..b9eb2d279d --- /dev/null +++ b/ix-dev/stable/home-assistant/migrations.yaml @@ -0,0 +1,4 @@ +migrations: + - file: ip_port_migration + target: + min_version: 1.5.0 diff --git a/ix-dev/stable/home-assistant/migrations/ip_port_migration b/ix-dev/stable/home-assistant/migrations/ip_port_migration new file mode 100755 index 0000000000..381ef3d30d --- /dev/null +++ b/ix-dev/stable/home-assistant/migrations/ip_port_migration @@ -0,0 +1,23 @@ +#!/usr/bin/python3 + +import os +import sys +import yaml + + +def migrate(values): + values["network"]["web_port"] = { + "port_number": values["network"]["web_port"], + "bind_mode": "published", + "host_ips": [], + } + return values + + +if __name__ == "__main__": + if len(sys.argv) != 2: + exit(1) + + if os.path.exists(sys.argv[1]): + with open(sys.argv[1], "r") as f: + print(yaml.dump(migrate(yaml.safe_load(f.read())))) diff --git a/ix-dev/stable/home-assistant/questions.yaml b/ix-dev/stable/home-assistant/questions.yaml index 9fb6de2e03..3bfdbc93b0 100644 --- a/ix-dev/stable/home-assistant/questions.yaml +++ b/ix-dev/stable/home-assistant/questions.yaml @@ -152,13 +152,51 @@ questions: attrs: - variable: web_port label: WebUI Port - description: The port for Home Assistant WebUI schema: - type: int - default: 30103 - required: true - $ref: - - definitions/port + type: dict + attrs: + - variable: bind_mode + label: Port Bind Mode + description: | + The port bind mode.
+ - Publish: The port will be published on the host for external access.
+ - Expose: The port will be exposed for inter-container communication.
+ - None: The port will not be exposed or published.
+ Note: If the Dockerfile defines an EXPOSE directive, + the port will still be exposed for inter-container communication regardless of this setting. + schema: + type: string + default: "published" + enum: + - value: "published" + description: Publish port on the host for external access + - value: "exposed" + description: Expose port for inter-container communication + - value: "" + description: None + - variable: port_number + label: Port Number + schema: + type: int + show_if: [["bind_mode", "=", "published"]] + default: 30103 + required: true + $ref: + - definitions/port + - variable: host_ips + label: Host IPs + description: IPs on the host to bind this port + schema: + type: list + default: [] + items: + - variable: host_ip + label: Host IP + schema: + type: string + required: true + $ref: + - definitions/node_bind_ip - variable: dns_opts label: DNS Options description: | diff --git a/ix-dev/stable/home-assistant/templates/docker-compose.yaml b/ix-dev/stable/home-assistant/templates/docker-compose.yaml index bcf9766c0f..d6bd571ddd 100644 --- a/ix-dev/stable/home-assistant/templates/docker-compose.yaml +++ b/ix-dev/stable/home-assistant/templates/docker-compose.yaml @@ -44,7 +44,7 @@ {% do c1.healthcheck.set_test("wget", {"port": values.consts.internal_web_port, "path": "/manifest.json"}) %} {% do c1.environment.add_user_envs(values.home_assistant.additional_envs) %} -{% do c1.ports.add_port(values.network.web_port, values.consts.internal_web_port) %} +{% do c1.add_port(values.network.web_port, {"container_port": values.consts.internal_web_port}) %} {% do c1.add_storage(values.consts.config_path, values.storage.config) %} {% do init.add_storage(values.consts.config_path, values.storage.config) %} @@ -60,6 +60,7 @@ {% do postgres.container.depends.add_dependency(values.consts.perms_container_name, "service_completed_successfully") %} {% endif %} -{% do tpl.portals.add_portal({"port": values.network.web_port}) %} +{% set port = values.consts.internal_web_port if values.network.host_network else values.network.web_port.port_number %} +{% do tpl.portals.add_portal({"port": port}) %} {{ tpl.render() | tojson }} diff --git a/ix-dev/stable/home-assistant/templates/test_values/basic-values.yaml b/ix-dev/stable/home-assistant/templates/test_values/basic-values.yaml index af487e2923..5e76a36706 100644 --- a/ix-dev/stable/home-assistant/templates/test_values/basic-values.yaml +++ b/ix-dev/stable/home-assistant/templates/test_values/basic-values.yaml @@ -14,7 +14,9 @@ home_assistant: additional_envs: [] network: - web_port: 8080 + web_port: + bind_mode: published + port_number: 8080 dns_opts: [] run_as: