diff --git a/services/home-assistant/Taskfile.dist.yml b/services/home-assistant/Taskfile.dist.yml new file mode 100644 index 0000000..b989fb2 --- /dev/null +++ b/services/home-assistant/Taskfile.dist.yml @@ -0,0 +1,8 @@ +version: "3" + +includes: + tf: + vars: + SERVICE: "home-assistant" + ENVIRONMENT: "main" + taskfile: ../../taskfiles/Taskfile_service.dist.yml diff --git a/services/home-assistant/_common/main.tf b/services/home-assistant/_common/main.tf new file mode 100644 index 0000000..bb7b96f --- /dev/null +++ b/services/home-assistant/_common/main.tf @@ -0,0 +1,29 @@ +resource "docker_container" "home-assistant" { + image = "homeassistant/home-assistant:${var.container_tag}" + name = var.container_name + + network_mode = "host" + privileged = true + restart = "always" + + mounts { + target = "/etc/localtime" + source = "/etc/localtime" + read_only = true + type = "bind" + } + + mounts { + target = "/run/dbus" + source = "/run/dbus" + read_only = true + type = "bind" + } + + mounts { + target = "/config" + source = "/volume1/cloud/${var.container_name}/config" + read_only = false + type = "bind" + } +} diff --git a/services/home-assistant/_common/vars.tf b/services/home-assistant/_common/vars.tf new file mode 100644 index 0000000..219cbdc --- /dev/null +++ b/services/home-assistant/_common/vars.tf @@ -0,0 +1,9 @@ +variable "container_tag" { + description = "Container tag" + type = string +} + +variable "container_name" { + description = "Container name" + type = string +} diff --git a/services/home-assistant/_common/versions.tf b/services/home-assistant/_common/versions.tf new file mode 100644 index 0000000..b433ffb --- /dev/null +++ b/services/home-assistant/_common/versions.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + docker = { + source = "kreuzwerker/docker" + } + } +} diff --git a/services/home-assistant/main/main.tf b/services/home-assistant/main/main.tf new file mode 100644 index 0000000..60e0fc9 --- /dev/null +++ b/services/home-assistant/main/main.tf @@ -0,0 +1,7 @@ +module "home-assistant" { + source = "../_common" + + container_name = "home-assistant" + container_tag = "2024.5" + +} diff --git a/services/home-assistant/main/versions.tf b/services/home-assistant/main/versions.tf new file mode 100644 index 0000000..b433ffb --- /dev/null +++ b/services/home-assistant/main/versions.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + docker = { + source = "kreuzwerker/docker" + } + } +}