aboutsummaryrefslogtreecommitdiff
path: root/terraform/unifi-controller/unifi.tf
diff options
context:
space:
mode:
Diffstat (limited to 'terraform/unifi-controller/unifi.tf')
-rw-r--r--terraform/unifi-controller/unifi.tf85
1 files changed, 45 insertions, 40 deletions
diff --git a/terraform/unifi-controller/unifi.tf b/terraform/unifi-controller/unifi.tf
index 8e6c7d7..4f1317f 100644
--- a/terraform/unifi-controller/unifi.tf
+++ b/terraform/unifi-controller/unifi.tf
@@ -1,34 +1,36 @@
-data "docker_network" "traefik" {
- name = "traefik"
-}
+# data "docker_network" "traefik" {
+# name = "traefik"
+# }
-data "docker_registry_image" "unifi-controller" {
+data "docker_registry_image" "unifi-network-application" {
name = local.docker_image_controller
}
-resource "docker_image" "unifi-controller" {
- name = data.docker_registry_image.unifi-controller.name
- pull_triggers = [data.docker_registry_image.unifi-controller.sha256_digest]
+resource "docker_image" "unifi-network-application" {
+ name = data.docker_registry_image.unifi-network-application.name
+ pull_triggers = [data.docker_registry_image.unifi-network-application.sha256_digest]
}
-resource "docker_volume" "unifi-controller" {
- name = "unifi-controller-new"
+resource "docker_volume" "unifi-network-application" {
+ name = "unifi-network-application"
}
-resource "docker_container" "unifi-controller" {
- image = docker_image.unifi-controller.image_id
- name = "unifi-controller"
- hostname = "unifi-controller"
+resource "docker_container" "unifi-network-application" {
+ image = docker_image.unifi-network-application.image_id
+ name = "unifi-network-application"
+ hostname = "unifi-network-application"
# privileged = true
- # must_run = false
+ must_run = true
- networks_advanced {
- name = data.docker_network.traefik.name
- }
+ network_mode = "host"
- networks_advanced {
- name = docker_network.unifi.name
- }
+# networks_advanced {
+# name = data.docker_network.traefik.name
+# }
+
+# networks_advanced {
+# name = docker_network.unifi.name
+# }
dynamic "ports" {
for_each = [
@@ -40,7 +42,8 @@ resource "docker_container" "unifi-controller" {
{ port = 8080, proto = "tcp" }, # Required for device communication
# Public HTTP is handled by traefik
- # { port = 8443, proto = "tcp" }, # Unifi web admin port
+ # Not anymore!
+ { port = 8443, proto = "tcp" }, # Unifi web admin port
# Not used
# { port = 8843, proto = "tcp" }, # Unifi guest portal HTTPS redirect port
@@ -52,31 +55,32 @@ resource "docker_container" "unifi-controller" {
internal = ports.value["port"]
external = ports.value["port"]
protocol = ports.value["proto"]
- ip = "fdf3:aad9:a885:77dd::2"
+ ip = local.public_ip
}
}
volumes {
- volume_name = docker_volume.unifi-controller.name
+ volume_name = docker_volume.unifi-network-application.name
+ read_only = false
container_path = "/config"
}
- dynamic "labels" {
- for_each = [
- { label = "traefik.enable", value = "true" },
- { label = "traefik.http.routers.unifi-controller.rule", value = "Host(`${local.domain_name}`)" },
- { label = "traefik.http.routers.unifi-controller.entrypoints", value = "websecure" },
- { label = "traefik.http.routers.unifi-controller.tls.certresolver", value = "linode" },
- { label = "traefik.http.services.unifi-controller.loadbalancer.server.port", value = "8443" },
- { label = "traefik.http.services.unifi-controller.loadbalancer.server.scheme", value = "https" },
- { label = "traefik.docker.network", value = "traefik" },
- # { label = "traefik.http.services.unifi-controller.loadbalancer.passHostHeader", value = "false" },
- ]
- content {
- label = labels.value["label"]
- value = labels.value["value"]
- }
- }
+# dynamic "labels" {
+# for_each = [
+# { label = "traefik.enable", value = "true" },
+# { label = "traefik.http.routers.unifi-network-application.rule", value = "Host(`${local.domain_name}`)" },
+# { label = "traefik.http.routers.unifi-network-application.entrypoints", value = "websecure" },
+# { label = "traefik.http.routers.unifi-network-application.tls.certresolver", value = "linode" },
+# { label = "traefik.http.services.unifi-network-application.loadbalancer.server.port", value = "8443" },
+# { label = "traefik.http.services.unifi-network-application.loadbalancer.server.scheme", value = "https" },
+# { label = "traefik.docker.network", value = "traefik" },
+# # { label = "traefik.http.services.unifi-network-application.loadbalancer.passHostHeader", value = "false" },
+# ]
+# content {
+# label = labels.value["label"]
+# value = labels.value["value"]
+# }
+# }
env = [
"PUID=1000",
@@ -85,7 +89,8 @@ resource "docker_container" "unifi-controller" {
"MEM_LIMIT=default",
"MONGO_USER=${local.mongo_username}",
"MONGO_PASS=${local.mongo_password}",
- "MONGO_HOST=${docker_container.unifi-mongo.hostname}",
+ #"MONGO_HOST=${docker_container.unifi-mongo.hostname}",
+ "MONGO_HOST=localhost",
"MONGO_PORT=27017",
"MONGO_DBNAME=${local.mongo_database}",
]