diff options
Diffstat (limited to 'terraform')
43 files changed, 1218 insertions, 180 deletions
diff --git a/terraform/conflatorio-docker/network.tf b/terraform/conflatorio-docker/network.tf deleted file mode 100644 index 32e1bfb..0000000 --- a/terraform/conflatorio-docker/network.tf +++ /dev/null @@ -1,9 +0,0 @@ -resource "docker_network" "public" { - name = "public" - - ipv6 = true - - ipam_config { - subnet = "fdf3:aad9:a885:77dd:bbbb::/120" - } -} diff --git a/terraform/conflatorio-docker/traefik.tf b/terraform/conflatorio-docker/traefik.tf index d15ac5c..cb5f2a0 100644 --- a/terraform/conflatorio-docker/traefik.tf +++ b/terraform/conflatorio-docker/traefik.tf @@ -12,6 +12,8 @@ resource "docker_container" "traefik" { privileged = false must_run = false + network_mode = "bridge" + networks_advanced { name = docker_network.traefik.name } @@ -23,20 +25,20 @@ resource "docker_container" "traefik" { ports { internal = 80 external = 80 - ip = "fdf3:aad9:a885:77dd::2" + ip = "${local.public_ip}" } ports { internal = 443 external = 443 - ip = "fdf3:aad9:a885:77dd::2" + ip = "${local.public_ip}" } # for buildfarm-server ports { internal = 8980 external = 8980 - ip = "fdf3:aad9:a885:77dd::2" + ip = "${local.public_ip}" } command = [ diff --git a/terraform/grafana/.terraform.lock.hcl b/terraform/conflatorio-prometheus/.terraform.lock.hcl index 4362198..9e1ccff 100644 --- a/terraform/grafana/.terraform.lock.hcl +++ b/terraform/conflatorio-prometheus/.terraform.lock.hcl @@ -23,8 +23,28 @@ provider "registry.terraform.io/cyrilgdn/postgresql" { ] } +provider "registry.terraform.io/hashicorp/null" { + version = "3.2.2" + hashes = [ + "h1:zT1ZbegaAYHwQa+QwIFugArWikRJI9dqohj8xb0GY88=", + "zh:3248aae6a2198f3ec8394218d05bd5e42be59f43a3a7c0b71c66ec0df08b69e7", + "zh:32b1aaa1c3013d33c245493f4a65465eab9436b454d250102729321a44c8ab9a", + "zh:38eff7e470acb48f66380a73a5c7cdd76cc9b9c9ba9a7249c7991488abe22fe3", + "zh:4c2f1faee67af104f5f9e711c4574ff4d298afaa8a420680b0cb55d7bbc65606", + "zh:544b33b757c0b954dbb87db83a5ad921edd61f02f1dc86c6186a5ea86465b546", + "zh:696cf785090e1e8cf1587499516b0494f47413b43cb99877ad97f5d0de3dc539", + "zh:6e301f34757b5d265ae44467d95306d61bef5e41930be1365f5a8dcf80f59452", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:913a929070c819e59e94bb37a2a253c228f83921136ff4a7aa1a178c7cce5422", + "zh:aa9015926cd152425dbf86d1abdbc74bfe0e1ba3d26b3db35051d7b9ca9f72ae", + "zh:bb04798b016e1e1d49bcc76d62c53b56c88c63d6f2dfe38821afef17c416a0e1", + "zh:c23084e1b23577de22603cff752e59128d83cfecc2e6819edadd8cf7a10af11e", + ] +} + provider "registry.terraform.io/hashicorp/random" { - version = "3.5.1" + version = "3.5.1" + constraints = "3.5.1" hashes = [ "h1:VSnd9ZIPyfKHOObuQCaKfnjIHRtR7qTw19Rz8tJxm+k=", "zh:04e3fbd610cb52c1017d282531364b9c53ef72b6bc533acb2a90671957324a64", diff --git a/terraform/grafana/backend.tf b/terraform/conflatorio-prometheus/backend.tf index e796c2e..9f2eed0 100644 --- a/terraform/grafana/backend.tf +++ b/terraform/conflatorio-prometheus/backend.tf @@ -2,7 +2,7 @@ terraform { backend "s3" { bucket = "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05" - key = "grafana/terraform.tfstate" + key = "conflatorio-prometheus/terraform.tfstate" skip_region_validation = true skip_credentials_validation = true skip_metadata_api_check = true diff --git a/terraform/conflatorio-prometheus/main.tf b/terraform/conflatorio-prometheus/main.tf new file mode 100644 index 0000000..f5c5a7f --- /dev/null +++ b/terraform/conflatorio-prometheus/main.tf @@ -0,0 +1,34 @@ +terraform { + required_version = "~> 1.3.5" + + required_providers { + docker = { + source = "kreuzwerker/docker" + version = "2.24.0" + } + postgresql = { + source = "cyrilgdn/postgresql" + version = "1.21.0" + } + random = { + source = "hashicorp/random" + version = "3.5.1" + } + sops = { + source = "lokkersp/sops" + version = "0.6.10" + } + } +} + +provider "docker" { + host = "ssh://conflatorio.vpn.trygvis.io" +} + +data "docker_network" "traefik" { + name = "traefik" +} + +data "docker_network" "private" { + name = "private" +} diff --git a/terraform/conflatorio-prometheus/prometheus.tf b/terraform/conflatorio-prometheus/prometheus.tf new file mode 100644 index 0000000..04dd406 --- /dev/null +++ b/terraform/conflatorio-prometheus/prometheus.tf @@ -0,0 +1,66 @@ +resource "docker_image" "prometheus" { + name = "prom/prometheus:v2.53.2" +} + +resource "docker_volume" "prometheus" { + name = "prometheus" +} + +resource "docker_container" "prometheus" { + image = docker_image.prometheus.image_id + name = "prometheus" + must_run = true + + env = [ + ] + + networks_advanced { + name = data.docker_network.private.name + } + + # networks_advanced { + # name = data.docker_network.traefik.name + # } + + # dynamic "labels" { + # for_each = [ + # { label = "traefik.enable", value = "true" }, + # { label = "traefik.docker.network", value = data.docker_network.traefik.name }, + # { label = "traefik.http.routers.prometheus.rule", value = "Host(`prometheus.trygvis.io`)" }, + # { label = "traefik.http.routers.prometheus.entrypoints", value = "websecure" }, + # { label = "traefik.http.routers.prometheus.tls.certresolver", value = "linode" }, + # ] + # content { + # label = labels.value["label"] + # value = labels.value["value"] + # } + # } + + mounts { + source = "${local.path}" + target = "/etc/prometheus" + type = "bind" + } + + volumes { + volume_name = docker_volume.prometheus.name + read_only = false + container_path = "/prometheus" + } + + depends_on = [ null_resource.mkdir ] +} + +locals { + path = "/etc/docker-service/prometheus" +} + +resource "null_resource" "mkdir" { + triggers = { + path = local.path + } + + provisioner "local-exec" { + command = "ssh conflatorio.vpn.trygvis.io sudo mkdir -p ${local.path}" + } +} diff --git a/terraform/conflatorio-docker/terragrunt.hcl b/terraform/conflatorio-prometheus/terragrunt.hcl index e147285..e147285 100644 --- a/terraform/conflatorio-docker/terragrunt.hcl +++ b/terraform/conflatorio-prometheus/terragrunt.hcl diff --git a/terraform/conflatorio-docker/backend.tf b/terraform/dns/backend.tf index d2de289..4f05aaf 100644 --- a/terraform/conflatorio-docker/backend.tf +++ b/terraform/dns/backend.tf @@ -1,12 +1,16 @@ # Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa terraform { + required_version = "~> 1.9.5" + backend "s3" { bucket = "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05" - key = "conflatorio-docker/terraform.tfstate" + key = "dns/terraform.tfstate" skip_region_validation = true skip_credentials_validation = true skip_metadata_api_check = true + skip_requesting_account_id = true + skip_s3_checksum = true region = "eu-central-1" - endpoint = "eu-central-1.linodeobjects.com" + endpoints = { s3 : "https://eu-central-1.linodeobjects.com" } } } diff --git a/terraform/dns/dn42.tf b/terraform/dns/dn42.tf new file mode 100644 index 0000000..35bc26e --- /dev/null +++ b/terraform/dns/dn42.tf @@ -0,0 +1,71 @@ +# Generated from ansible data + +resource "linode_domain_record" "dn42-conflatorio" { + domain_id = linode_domain.root.id + name = "conflatorio.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2008:8042:32ff:fe0c:7161" +} + +resource "linode_domain_record" "dn42-coregonus" { + domain_id = linode_domain.root.id + name = "coregonus.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2005::ffff" +} + +resource "linode_domain_record" "dn42-danneri" { + domain_id = linode_domain.root.id + name = "danneri.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2008:9422:d355:95b7:f170" +} + +resource "linode_domain_record" "dn42-hash" { + domain_id = linode_domain.root.id + name = "hash.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2007::ffff" +} + +resource "linode_domain_record" "dn42-knot" { + domain_id = linode_domain.root.id + name = "knot.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2004::ffff" +} + +resource "linode_domain_record" "dn42-kv24ix" { + domain_id = linode_domain.root.id + name = "kv24ix.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2006::ffff" +} + +resource "linode_domain_record" "dn42-lhn2pi" { + domain_id = linode_domain.root.id + name = "lhn2pi.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2008::ffff" +} + +resource "linode_domain_record" "dn42-node1" { + domain_id = linode_domain.root.id + name = "node1.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2002::ffff" +} + +resource "linode_domain_record" "dn42-node2" { + domain_id = linode_domain.root.id + name = "node2.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2003::ffff" +} + +resource "linode_domain_record" "dn42-unifi" { + domain_id = linode_domain.root.id + name = "unifi.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2008:5054:ff:fe4d:96c" +} diff --git a/terraform/dns/main.tf b/terraform/dns/main.tf index c67944e..812f3b2 100644 --- a/terraform/dns/main.tf +++ b/terraform/dns/main.tf @@ -1,20 +1,8 @@ terraform { - required_version = "~> 1.3.6" - - backend "s3" { - bucket = "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05" - key = "dns/terraform.tfstate" - region = "eu-central-1" - skip_region_validation = true - skip_credentials_validation = true - skip_metadata_api_check = true - endpoint = "eu-central-1.linodeobjects.com" - } - required_providers { linode = { version = "2.7.1" - source = "linode/linode" + source = "linode/linode" } } } diff --git a/terraform/dns/terraform.tfstate b/terraform/dns/terraform.tfstate new file mode 100644 index 0000000..891db4d --- /dev/null +++ b/terraform/dns/terraform.tfstate @@ -0,0 +1,52 @@ +{ + "version": 3, + "serial": 1, + "lineage": "8244bd55-1992-3e9a-1072-28df4fb0d2f2", + "backend": { + "type": "s3", + "config": { + "access_key": null, + "acl": null, + "assume_role_duration_seconds": null, + "assume_role_policy": null, + "assume_role_policy_arns": null, + "assume_role_tags": null, + "assume_role_transitive_tag_keys": null, + "bucket": "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05", + "dynamodb_endpoint": null, + "dynamodb_table": null, + "encrypt": null, + "endpoint": "eu-central-1.linodeobjects.com", + "external_id": null, + "force_path_style": null, + "iam_endpoint": null, + "key": "dns/terraform.tfstate", + "kms_key_id": null, + "max_retries": null, + "profile": null, + "region": "eu-central-1", + "role_arn": null, + "secret_key": null, + "session_name": null, + "shared_credentials_file": null, + "skip_credentials_validation": true, + "skip_metadata_api_check": true, + "skip_region_validation": true, + "sse_customer_key": null, + "sts_endpoint": null, + "token": null, + "workspace_key_prefix": null + }, + "hash": 1226279900 + }, + "modules": [ + { + "path": [ + "root" + ], + "outputs": {}, + "resources": {}, + "depends_on": [] + } + ] +} diff --git a/terraform/grafana/terragrunt.hcl b/terraform/dns/terragrunt.hcl index e147285..e147285 100644 --- a/terraform/grafana/terragrunt.hcl +++ b/terraform/dns/terragrunt.hcl diff --git a/terraform/dns/trygvis.tf b/terraform/dns/trygvis.tf index ebc9da4..4dcec85 100644 --- a/terraform/dns/trygvis.tf +++ b/terraform/dns/trygvis.tf @@ -17,6 +17,22 @@ resource "linode_domain_record" "root-a" { target = "176.58.112.84" } +resource "linode_domain_record" "root-mx" { + domain_id = linode_domain.root.id + name = "" + record_type = "MX" + target = "in1-smtp.messagingengine.com" + priority = 10 +} + +resource "linode_domain_record" "root-mx2" { + domain_id = linode_domain.root.id + name = "" + record_type = "MX" + target = "in2-smtp.messagingengine.com" + priority = 20 +} + resource "linode_domain_record" "root-txt-google" { domain_id = linode_domain.root.id name = "" @@ -39,6 +55,52 @@ resource "linode_domain_record" "root-txt-keybase" { target = "keybase-site-verification=gcoO7zav4G2IK5KQdrWOgz_PD9wpZhz-0afIb1Kodrk" } +resource "linode_domain_record" "root-txt-fastmail-dkim" { + count = 3 + domain_id = linode_domain.root.id + name = format("fm%d._domainkey", count.index + 1) + record_type = "CNAME" + target = format("fm%d.trygvis.io.dkim.fmhosted.com", count.index + 1) +} + +resource "linode_domain_record" "root-txt-fastmail-spf" { + domain_id = linode_domain.root.id + name = "" + record_type = "TXT" + target = "v=spf1 include:spf.messagingengine.com ?all" +} + +resource "linode_domain_record" "root-txt-fastmail-dmark" { + domain_id = linode_domain.root.id + name = "_dmarc" + record_type = "TXT" + target = "v=DMARC1; p=none;" +} + +resource "linode_domain_record" "root-txt-fastmail-srv" { + domain_id = linode_domain.root.id + record_type = "SRV" + service = each.key + priority = each.value.priority + weight = each.value.weight + port = each.value.port + target = each.value.target + + for_each = tomap({ + submission = { priority = 0, weight = 0, port = 0, target = "." }, + imap = { priority = 0, weight = 0, port = 0, target = "." }, + submissions = { priority = 0, weight = 1, port = 465, target = "smtp.fastmail.com" }, + imaps = { priority = 0, weight = 1, port = 993, target = "imap.fastmail.com" }, + jmap = { priority = 0, weight = 1, port = 443, target = "api.fastmail.com" }, + autodiscover = { priority = 0, weight = 1, port = 443, target = "autodiscover.fastmail.com" }, + autodiscover = { priority = 0, weight = 1, port = 443, target = "autodiscover.fastmail.com" }, + carddav = { priority = 0, weight = 0, port = 0, target = "." }, + carddavs = { priority = 0, weight = 1, port = 443, target = "carddav.fastmail.com" }, + caldav = { priority = 0, weight = 0, port = 0, target = "." }, + caldavs = { priority = 0, weight = 1, port = 443, target = "caldav.fastmail.com" }, + }) +} + resource "linode_domain_record" "root-cname-ses-1" { domain_id = linode_domain.root.id name = "k5o5gjadej2kkfncu36i3ef5gt473sxy._domainkey" @@ -53,13 +115,6 @@ resource "linode_domain_record" "root-cname-ses-2" { target = "imtuzw2lnfktlc7uongw433qbwjxxatg.dkim.amazonses.com" } -resource "linode_domain_record" "dlock" { - domain_id = linode_domain.root.id - name = "dlock" - record_type = "A" - target = "35.205.192.14" -} - resource "linode_domain_record" "hash" { domain_id = linode_domain.root.id name = "hash" @@ -115,7 +170,7 @@ resource "linode_domain_record" "grafana" { domain_id = linode_domain.root.id name = "grafana" record_type = "CNAME" - target = "vs.trygvis.io" + target = "hash.trygvis.io" } resource "linode_domain_record" "owncloud" { diff --git a/terraform/dns/vpn-cname.tf b/terraform/dns/vpn-cname.tf index bbd411a..c03b2bb 100644 --- a/terraform/dns/vpn-cname.tf +++ b/terraform/dns/vpn-cname.tf @@ -1,22 +1,22 @@ -resource "linode_domain_record" "vpn-conflatorio" { +#resource "linode_domain_record" "vpn-conflatorio" { +# domain_id = linode_domain.root.id +# name = "conflatorio.vpn" +# record_type = "AAAA" +# target = "fdf3:aad9:a885:77dd::2" +#} + +resource "linode_domain_record" "net-conflatorio" { domain_id = linode_domain.root.id - name = "conflatorio.vpn" + name = "conflatorio.net" record_type = "AAAA" - target = "fdf3:aad9:a885:77dd::2" + target = "fdb1:4242:3538:2001::ffff" } resource "linode_domain_record" "vpn-unifi" { domain_id = linode_domain.root.id name = "unifi.vpn" record_type = "CNAME" - target = "${linode_domain_record.vpn-conflatorio.name}.trygvis.io" -} - -resource "linode_domain_record" "vpn-grafana" { - domain_id = linode_domain.root.id - name = "grafana.vpn" - record_type = "CNAME" - target = "${linode_domain_record.vpn-conflatorio.name}.trygvis.io" + target = "${linode_domain_record.net-conflatorio.name}.trygvis.io" } resource "linode_domain_record" "vpn-influxdb" { diff --git a/terraform/dns/vpn.tf b/terraform/dns/vpn.tf index d73d01e..58efa5c 100644 --- a/terraform/dns/vpn.tf +++ b/terraform/dns/vpn.tf @@ -5,11 +5,11 @@ resource "linode_domain_record" "vpn-knot" { record_type = "AAAA" target = "fdf3:aad9:a885:0b3a::1" } -resource "linode_domain_record" "vpn-birgitte" { +resource "linode_domain_record" "vpn-conflatorio" { domain_id = linode_domain.root.id - name = "birgitte.vpn" + name = "conflatorio.vpn" record_type = "AAAA" - target = "fdf3:aad9:a885:0b3a::2" + target = "fdf3:aad9:a885:0b3a::3" } resource "linode_domain_record" "vpn-arius" { domain_id = linode_domain.root.id @@ -23,36 +23,18 @@ resource "linode_domain_record" "vpn-akili" { record_type = "AAAA" target = "fdf3:aad9:a885:0b3a::7" } -resource "linode_domain_record" "vpn-malabaricus" { - domain_id = linode_domain.root.id - name = "malabaricus.vpn" - record_type = "AAAA" - target = "fdf3:aad9:a885:0b3a::8" -} resource "linode_domain_record" "vpn-sweetzpot-mobile" { domain_id = linode_domain.root.id name = "sweetzpot-mobile.vpn" record_type = "AAAA" target = "fdf3:aad9:a885:0b3a::9" } -resource "linode_domain_record" "vpn-astyanax" { - domain_id = linode_domain.root.id - name = "astyanax.vpn" - record_type = "AAAA" - target = "fdf3:aad9:a885:0b3a::10" -} resource "linode_domain_record" "vpn-sweetzpot-macos" { domain_id = linode_domain.root.id name = "sweetzpot-macos.vpn" record_type = "AAAA" target = "fdf3:aad9:a885:0b3a::11" } -resource "linode_domain_record" "vpn-android-trygvis" { - domain_id = linode_domain.root.id - name = "android-trygvis.vpn" - record_type = "AAAA" - target = "fdf3:aad9:a885:0b3a::12" -} resource "linode_domain_record" "vpn-hash" { domain_id = linode_domain.root.id name = "hash.vpn" @@ -71,9 +53,21 @@ resource "linode_domain_record" "vpn-lhn2ix" { record_type = "AAAA" target = "fdf3:aad9:a885:0b3a::15" } +resource "linode_domain_record" "vpn-kv24ix" { + domain_id = linode_domain.root.id + name = "kv24ix.vpn" + record_type = "AAAA" + target = "fdf3:aad9:a885:0b3a::16" +} resource "linode_domain_record" "vpn-biwia" { domain_id = linode_domain.root.id name = "biwia.vpn" record_type = "AAAA" target = "fdf3:aad9:a885:0b3a::17" } +resource "linode_domain_record" "vpn-coregonus" { + domain_id = linode_domain.root.id + name = "coregonus.vpn" + record_type = "AAAA" + target = "fdf3:aad9:a885:0b3a::18" +} diff --git a/terraform/conflatorio-docker/.terraform.lock.hcl b/terraform/hash-docker/.terraform.lock.hcl index aa0f1fb..e35130a 100644 --- a/terraform/conflatorio-docker/.terraform.lock.hcl +++ b/terraform/hash-docker/.terraform.lock.hcl @@ -2,21 +2,21 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/null" { - version = "3.2.1" + version = "3.2.3" hashes = [ - "h1:FbGfc+muBsC17Ohy5g806iuI1hQc4SIexpYCrQHQd8w=", - "zh:58ed64389620cc7b82f01332e27723856422820cfd302e304b5f6c3436fb9840", - "zh:62a5cc82c3b2ddef7ef3a6f2fedb7b9b3deff4ab7b414938b08e51d6e8be87cb", - "zh:63cff4de03af983175a7e37e52d4bd89d990be256b16b5c7f919aff5ad485aa5", - "zh:74cb22c6700e48486b7cabefa10b33b801dfcab56f1a6ac9b6624531f3d36ea3", + "h1:+AnORRgFbRO6qqcfaQyeX80W0eX3VmjadjnUFUJTiXo=", + "zh:22d062e5278d872fe7aed834f5577ba0a5afe34a3bdac2b81f828d8d3e6706d2", + "zh:23dead00493ad863729495dc212fd6c29b8293e707b055ce5ba21ee453ce552d", + "zh:28299accf21763ca1ca144d8f660688d7c2ad0b105b7202554ca60b02a3856d3", + "zh:55c9e8a9ac25a7652df8c51a8a9a422bd67d784061b1de2dc9fe6c3cb4e77f2f", + "zh:756586535d11698a216291c06b9ed8a5cc6a4ec43eee1ee09ecd5c6a9e297ac1", "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", - "zh:79e553aff77f1cfa9012a2218b8238dd672ea5e1b2924775ac9ac24d2a75c238", - "zh:a1e06ddda0b5ac48f7e7c7d59e1ab5a4073bbcf876c73c0299e4610ed53859dc", - "zh:c37a97090f1a82222925d45d84483b2aa702ef7ab66532af6cbcfb567818b970", - "zh:e4453fbebf90c53ca3323a92e7ca0f9961427d2f0ce0d2b65523cc04d5d999c2", - "zh:e80a746921946d8b6761e77305b752ad188da60688cfd2059322875d363be5f5", - "zh:fbdb892d9822ed0e4cb60f2fedbdbb556e4da0d88d3b942ae963ed6ff091e48f", - "zh:fca01a623d90d0cad0843102f9b8b9fe0d3ff8244593bd817f126582b52dd694", + "zh:9d5eea62fdb587eeb96a8c4d782459f4e6b73baeece4d04b4a40e44faaee9301", + "zh:a6355f596a3fb8fc85c2fb054ab14e722991533f87f928e7169a486462c74670", + "zh:b5a65a789cff4ada58a5baffc76cb9767dc26ec6b45c00d2ec8b1b027f6db4ed", + "zh:db5ab669cf11d0e9f81dc380a6fdfcac437aea3d69109c7aef1a5426639d2d65", + "zh:de655d251c470197bcbb5ac45d289595295acb8f829f6c781d4a75c8c8b7c7dd", + "zh:f5c68199f2e6076bce92a12230434782bf768103a427e9bb9abee99b116af7b5", ] } diff --git a/terraform/hash-docker/backend.tf b/terraform/hash-docker/backend.tf new file mode 100644 index 0000000..d793773 --- /dev/null +++ b/terraform/hash-docker/backend.tf @@ -0,0 +1,16 @@ +# Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa +terraform { + required_version = "~> 1.9.5" + + backend "s3" { + bucket = "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05" + key = "hash-docker/terraform.tfstate" + skip_region_validation = true + skip_credentials_validation = true + skip_metadata_api_check = true + skip_requesting_account_id = true + skip_s3_checksum = true + region = "eu-central-1" + endpoints = { s3 : "https://eu-central-1.linodeobjects.com" } + } +} diff --git a/terraform/conflatorio-docker/main.tf b/terraform/hash-docker/main.tf index 8a01be6..ba2c79f 100644 --- a/terraform/conflatorio-docker/main.tf +++ b/terraform/hash-docker/main.tf @@ -1,6 +1,4 @@ terraform { - required_version = "~> 1.3.5" - required_providers { docker = { source = "kreuzwerker/docker" @@ -13,8 +11,17 @@ terraform { } } +locals { + host = "hash.trygvis.io" + public_ip = "138.201.33.16" + + hs = module.ipam6.hosts + ns = module.ipam6.networks + dn42_range = local.ns.hash_docker_dn42.range +} + provider "docker" { - host = "ssh://conflatorio.vpn.trygvis.io" + host = "ssh://${local.host}" } data "sops_file_entry" "linode_token" { @@ -22,6 +29,6 @@ data "sops_file_entry" "linode_token" { data_key = "linode_token" } -output "foo" { - value = "foo!" +module "ipam6" { + source = "../ipam6" } diff --git a/terraform/hash-docker/network.tf b/terraform/hash-docker/network.tf new file mode 100644 index 0000000..94ddeef --- /dev/null +++ b/terraform/hash-docker/network.tf @@ -0,0 +1,14 @@ +resource "docker_network" "dn42" { + name = "dn42" + + ipv6 = true + + ipam_config { + gateway = "172.20.0.1" + subnet = "172.20.0.0/16" + } + + ipam_config { + subnet = local.dn42_range + } +} diff --git a/terraform/hash-docker/terragrunt.hcl b/terraform/hash-docker/terragrunt.hcl new file mode 100644 index 0000000..e147285 --- /dev/null +++ b/terraform/hash-docker/terragrunt.hcl @@ -0,0 +1,3 @@ +include "root" { + path = find_in_parent_folders() +} diff --git a/terraform/hash-docker/traefik.tf b/terraform/hash-docker/traefik.tf new file mode 100644 index 0000000..3708024 --- /dev/null +++ b/terraform/hash-docker/traefik.tf @@ -0,0 +1,105 @@ +resource "docker_network" "traefik" { + name = "traefik" +} + +resource "docker_image" "traefik" { + name = "traefik:2.9.8" +} + +resource "docker_container" "traefik" { + image = docker_image.traefik.image_id + name = "traefik" + privileged = false + must_run = false + + network_mode = "bridge" + + networks_advanced { + name = docker_network.traefik.name + } + + ports { + internal = 80 + external = 80 + ip = local.public_ip + } + + ports { + internal = 443 + external = 443 + ip = local.public_ip + } + + command = [ + "--log.level=DEBUG", + "--api=true", + "--api.dashboard=true", + "--api.debug=true", + # "--api.insecure=true", + "--providers.docker=true", + "--providers.docker.exposedbydefault=false", + "--entrypoints.websecure.address=:443", + "--entrypoints.web.address=:80", + "--entrypoints.web.http.redirections.entrypoint.to=websecure", + "--entrypoints.web.http.redirections.entrypoint.scheme=https", + "--certificatesresolvers.linode.acme.dnschallenge.provider=linode", + "--certificatesresolvers.linode.acme.dnschallenge.resolvers=1.1.1.1:53,8.8.8.8:53", + "--certificatesresolvers.linode.acme.email=root@trygvis.io", + "--certificatesresolvers.linode.acme.storage=/letsencrypt/acme.json", + + # There doesn't seem to be a way to define a specific + # serversTransport through the CLI or lables, to here backend + # certificate checks are globally disabled. + "--serverstransport.insecureskipverify", + ] + + dynamic "labels" { + for_each = [ + { label = "traefik.enable", value = "true" }, + { label = "traefik.http.routers.traefik.service", value = "api@internal" }, + { label = "traefik.http.routers.traefik.rule", value = "Host(`${local.host}`)" }, + { label = "traefik.http.routers.traefik.entrypoints", value = "websecure" }, + { label = "traefik.http.routers.traefik.tls.certresolver", value = "linode" }, + ] + content { + label = labels.value["label"] + value = labels.value["value"] + } + } + + env = [ + "LINODE_TOKEN=${data.sops_file_entry.linode_token.data}" + ] + + mounts { + source = "/etc/docker-service/traefik/letsencrypt" + target = "/letsencrypt" + type = "bind" + read_only = false + } + + mounts { + source = "/var/run/docker.sock" + target = "/var/run/docker.sock" + type = "bind" + read_only = true + } + + depends_on = [ + resource.null_resource.letsencrypt, + ] +} + +locals { + path = "/etc/docker-service/traefik/letsencrypt" +} + +resource "null_resource" "letsencrypt" { + triggers = { + path = local.path + } + + provisioner "local-exec" { + command = "ssh ${local.host} sudo mkdir -p ${local.path}" + } +} diff --git a/terraform/hash-grafana/.terraform.lock.hcl b/terraform/hash-grafana/.terraform.lock.hcl new file mode 100644 index 0000000..3242795 --- /dev/null +++ b/terraform/hash-grafana/.terraform.lock.hcl @@ -0,0 +1,84 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/cyrilgdn/postgresql" { + version = "1.21.0" + constraints = "1.21.0" + hashes = [ + "h1:v7X6z6j8Uo07+QJPuO3EVM8N1uy6t2k+1GiRGioOPGc=", + "zh:17e3d204dabc116276c763bb0cd159aa315789d3b0bcd3b8aede935509960ab6", + "zh:1a7e5ac1921afdb3b12a49714c5f446a7604bfa1eb7bd9c123d607f8cbda45e4", + "zh:24a880623e30928ee866c84016b1db4e0458764c7a547b808e2d398e90456d42", + "zh:255c6162d35ace6a313a50c4ceb5452bd5582d7bb097a44e75ac4901e635ca13", + "zh:281ab48b69d0852b5138fe5ea2301ff7fdff30748f1f7878ac837c71622d3f7b", + "zh:3d4e0ae2809e743272e5d2640b64354c48140e225c2ba6f1a211700ea70e0754", + "zh:4f4df290e3ff626d8b274c624852d21d194a397a7f580ebe0cbf0ff64dd8fa31", + "zh:5997ce8f7cbcd7ff5a443d037b83857b17b64be928e9d9338dd494466733df60", + "zh:a05f0b65b0abf4488cdaf7b239206940940be77fd51f458f2a0986c6a17436aa", + "zh:aeb6c6da639abb6126f38be90a7bc428f925461bf599388ff092e059e0bb1a94", + "zh:d30bb053b6000c32cc8d03da231c30eaecddd926200adf2e9ad9c0186c2ad1ad", + "zh:d978827683b324c75141fa80ebc28dcaf181acd0be0a47b1e5f9579a72a08151", + "zh:f51fae9206361cbe865e30b06d106270d6acf7ece0550953b0d6b55afe6be9ba", + "zh:fa49a2702c529865c20f57185d6dd41072fdd9a13ac1a49e30eb88605c31af7a", + ] +} + +provider "registry.terraform.io/hashicorp/random" { + version = "3.5.1" + hashes = [ + "h1:VSnd9ZIPyfKHOObuQCaKfnjIHRtR7qTw19Rz8tJxm+k=", + "zh:04e3fbd610cb52c1017d282531364b9c53ef72b6bc533acb2a90671957324a64", + "zh:119197103301ebaf7efb91df8f0b6e0dd31e6ff943d231af35ee1831c599188d", + "zh:4d2b219d09abf3b1bb4df93d399ed156cadd61f44ad3baf5cf2954df2fba0831", + "zh:6130bdde527587bbe2dcaa7150363e96dbc5250ea20154176d82bc69df5d4ce3", + "zh:6cc326cd4000f724d3086ee05587e7710f032f94fc9af35e96a386a1c6f2214f", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:b6d88e1d28cf2dfa24e9fdcc3efc77adcdc1c3c3b5c7ce503a423efbdd6de57b", + "zh:ba74c592622ecbcef9dc2a4d81ed321c4e44cddf7da799faa324da9bf52a22b2", + "zh:c7c5cde98fe4ef1143bd1b3ec5dc04baf0d4cc3ca2c5c7d40d17c0e9b2076865", + "zh:dac4bad52c940cd0dfc27893507c1e92393846b024c5a9db159a93c534a3da03", + "zh:de8febe2a2acd9ac454b844a4106ed295ae9520ef54dc8ed2faf29f12716b602", + "zh:eab0d0495e7e711cca367f7d4df6e322e6c562fc52151ec931176115b83ed014", + ] +} + +provider "registry.terraform.io/kreuzwerker/docker" { + version = "3.0.2" + constraints = "3.0.2" + hashes = [ + "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", + "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", + "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", + "zh:38081b3fe317c7e9555b2aaad325ad3fa516a886d2dfa8605ae6a809c1072138", + "zh:4a9c5065b178082f79ad8160243369c185214d874ff5048556d48d3edd03c4da", + "zh:5438ef6afe057945f28bce43d76c4401254073de01a774760169ac1058830ac2", + "zh:60b7fadc287166e5c9873dfe53a7976d98244979e0ab66428ea0dea1ebf33e06", + "zh:61c5ec1cb94e4c4a4fb1e4a24576d5f39a955f09afb17dab982de62b70a9bdd1", + "zh:a38fe9016ace5f911ab00c88e64b156ebbbbfb72a51a44da3c13d442cd214710", + "zh:c2c4d2b1fd9ebb291c57f524b3bf9d0994ff3e815c0cd9c9bcb87166dc687005", + "zh:d567bb8ce483ab2cf0602e07eae57027a1a53994aba470fa76095912a505533d", + "zh:e83bf05ab6a19dd8c43547ce9a8a511f8c331a124d11ac64687c764ab9d5a792", + "zh:e90c934b5cd65516fbcc454c89a150bfa726e7cf1fe749790c7480bbeb19d387", + "zh:f05f167d2eaf913045d8e7b88c13757e3cf595dd5cd333057fdafc7c4b7fed62", + "zh:fcc9c1cea5ce85e8bcb593862e699a881bd36dffd29e2e367f82d15368659c3d", + ] +} + +provider "registry.terraform.io/lokkersp/sops" { + version = "0.6.10" + constraints = "0.6.10" + hashes = [ + "h1:atU8NIBxpNTWY+qBubvEOfjOn4K1aCDoq1iUFocgIHQ=", + "zh:0f053a26392a581b1f1ce6316cb7ed8ec4cc75e7f5f1cf7cfd45050b6b3c87ea", + "zh:207bb96c4471fce9aeb1b3c217d772692c3d865d294cf4d2501dad41de36a15e", + "zh:28506e8f1f3b9eaa95d99043440328044ee6340143535e5751538328a529d001", + "zh:3cae3bcea9e35fdc5b3f2af1b4580cd625c996448ad0c676c772260e46b25289", + "zh:3e44daaf82986c2b0028aeb17b867f3c68ed5dd8ac8625ba0406cf2a5fd3d92e", + "zh:457fb8ca2e677af24f9a4bdd8b613b1d7b604ad7133541657e5757c19268da71", + "zh:473d727c228f021a3df8cc8dcc6231ad7f90ed63f9e47c36b597d591e76228da", + "zh:48c4c1df39fd76ec8bd5fe9ac70cdc0927ac8be95582dbe46458b3442ce0fcd9", + "zh:728b19cb5c07e5e9d8b78fd94cc57d4c13582ecd24b7eb7c4cc2bf73b12fe4d1", + "zh:c51ed9af591779bb0910b82addeebb10f53428b994f8db653dd1dedcec60916c", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + ] +} diff --git a/terraform/hash-grafana/backend.tf b/terraform/hash-grafana/backend.tf new file mode 100644 index 0000000..b06355d --- /dev/null +++ b/terraform/hash-grafana/backend.tf @@ -0,0 +1,16 @@ +# Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa +terraform { + required_version = "~> 1.9.5" + + backend "s3" { + bucket = "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05" + key = "hash-grafana/terraform.tfstate" + skip_region_validation = true + skip_credentials_validation = true + skip_metadata_api_check = true + skip_requesting_account_id = true + skip_s3_checksum = true + region = "eu-central-1" + endpoints = { s3 : "https://eu-central-1.linodeobjects.com" } + } +} diff --git a/terraform/grafana/grafana.tf b/terraform/hash-grafana/grafana.tf index 6d75da3..b425e72 100644 --- a/terraform/grafana/grafana.tf +++ b/terraform/hash-grafana/grafana.tf @@ -1,5 +1,5 @@ resource "docker_image" "grafana" { - name = "grafana/grafana-oss:10.1.5" + name = "grafana/grafana-oss:11.2.2" } resource "docker_volume" "grafana" { @@ -12,19 +12,21 @@ resource "docker_container" "grafana" { privileged = false must_run = true + network_mode = "bridge" + networks_advanced { name = data.docker_network.traefik.name } networks_advanced { - name = data.docker_network.public.name + name = data.docker_network.dn42.name } dynamic "labels" { for_each = [ { label = "traefik.enable", value = "true" }, { label = "traefik.docker.network", value = data.docker_network.traefik.name }, - { label = "traefik.http.routers.grafana.rule", value = "Host(`grafana.vpn.trygvis.io`)" }, + { label = "traefik.http.routers.grafana.rule", value = "Host(`grafana.trygvis.io`)" }, { label = "traefik.http.routers.grafana.entrypoints", value = "websecure" }, { label = "traefik.http.routers.grafana.tls.certresolver", value = "linode" }, ] @@ -36,7 +38,7 @@ resource "docker_container" "grafana" { env = [ "GF_DATABASE_TYPE=postgres", - "GF_DATABASE_HOST=[fdf3:aad9:a885:b3a::1]", + "GF_DATABASE_HOST=knot.dn42.trygvis.io", "GF_DATABASE_DATABASE=${postgresql_database.grafana.name}", "GF_DATABASE_USER=${postgresql_role.grafana.name}", "GF_DATABASE_PASSWORD=${postgresql_role.grafana.password}", @@ -45,5 +47,6 @@ resource "docker_container" "grafana" { volumes { volume_name = docker_volume.grafana.name container_path = "/var/lib/grafana" + read_only = false } } diff --git a/terraform/grafana/main.tf b/terraform/hash-grafana/main.tf index fa225ab..043b778 100644 --- a/terraform/grafana/main.tf +++ b/terraform/hash-grafana/main.tf @@ -1,10 +1,8 @@ terraform { - required_version = "~> 1.3.5" - required_providers { docker = { source = "kreuzwerker/docker" - version = "2.24.0" + version = "3.0.2" } postgresql = { source = "cyrilgdn/postgresql" @@ -21,8 +19,12 @@ terraform { } } +locals { + host = "hash.trygvis.io" +} + provider "docker" { - host = "ssh://conflatorio.vpn.trygvis.io" + host = "ssh://${local.host}" } data "sops_file_entry" "knot_pdb_terraform_password" { @@ -42,6 +44,6 @@ data "docker_network" "traefik" { name = "traefik" } -data "docker_network" "public" { - name = "public" +data "docker_network" "dn42" { + name = "dn42" } diff --git a/terraform/grafana/pdb.tf b/terraform/hash-grafana/pdb.tf index e2a59cd..e2a59cd 100644 --- a/terraform/grafana/pdb.tf +++ b/terraform/hash-grafana/pdb.tf diff --git a/terraform/hash-grafana/terragrunt.hcl b/terraform/hash-grafana/terragrunt.hcl new file mode 100644 index 0000000..e147285 --- /dev/null +++ b/terraform/hash-grafana/terragrunt.hcl @@ -0,0 +1,3 @@ +include "root" { + path = find_in_parent_folders() +} diff --git a/terraform/hash-prometheus/.terraform.lock.hcl b/terraform/hash-prometheus/.terraform.lock.hcl new file mode 100644 index 0000000..52de25e --- /dev/null +++ b/terraform/hash-prometheus/.terraform.lock.hcl @@ -0,0 +1,123 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/cyrilgdn/postgresql" { + version = "1.21.0" + constraints = "1.21.0" + hashes = [ + "h1:v7X6z6j8Uo07+QJPuO3EVM8N1uy6t2k+1GiRGioOPGc=", + "zh:17e3d204dabc116276c763bb0cd159aa315789d3b0bcd3b8aede935509960ab6", + "zh:1a7e5ac1921afdb3b12a49714c5f446a7604bfa1eb7bd9c123d607f8cbda45e4", + "zh:24a880623e30928ee866c84016b1db4e0458764c7a547b808e2d398e90456d42", + "zh:255c6162d35ace6a313a50c4ceb5452bd5582d7bb097a44e75ac4901e635ca13", + "zh:281ab48b69d0852b5138fe5ea2301ff7fdff30748f1f7878ac837c71622d3f7b", + "zh:3d4e0ae2809e743272e5d2640b64354c48140e225c2ba6f1a211700ea70e0754", + "zh:4f4df290e3ff626d8b274c624852d21d194a397a7f580ebe0cbf0ff64dd8fa31", + "zh:5997ce8f7cbcd7ff5a443d037b83857b17b64be928e9d9338dd494466733df60", + "zh:a05f0b65b0abf4488cdaf7b239206940940be77fd51f458f2a0986c6a17436aa", + "zh:aeb6c6da639abb6126f38be90a7bc428f925461bf599388ff092e059e0bb1a94", + "zh:d30bb053b6000c32cc8d03da231c30eaecddd926200adf2e9ad9c0186c2ad1ad", + "zh:d978827683b324c75141fa80ebc28dcaf181acd0be0a47b1e5f9579a72a08151", + "zh:f51fae9206361cbe865e30b06d106270d6acf7ece0550953b0d6b55afe6be9ba", + "zh:fa49a2702c529865c20f57185d6dd41072fdd9a13ac1a49e30eb88605c31af7a", + ] +} + +provider "registry.terraform.io/hashicorp/local" { + version = "2.5.2" + hashes = [ + "h1:JlMZD6nYqJ8sSrFfEAH0Vk/SL8WLZRmFaMUF9PJK5wM=", + "zh:136299545178ce281c56f36965bf91c35407c11897f7082b3b983d86cb79b511", + "zh:3b4486858aa9cb8163378722b642c57c529b6c64bfbfc9461d940a84cd66ebea", + "zh:4855ee628ead847741aa4f4fc9bed50cfdbf197f2912775dd9fe7bc43fa077c0", + "zh:4b8cd2583d1edcac4011caafe8afb7a95e8110a607a1d5fb87d921178074a69b", + "zh:52084ddaff8c8cd3f9e7bcb7ce4dc1eab00602912c96da43c29b4762dc376038", + "zh:71562d330d3f92d79b2952ffdda0dad167e952e46200c767dd30c6af8d7c0ed3", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:805f81ade06ff68fa8b908d31892eaed5c180ae031c77ad35f82cb7a74b97cf4", + "zh:8b6b3ebeaaa8e38dd04e56996abe80db9be6f4c1df75ac3cccc77642899bd464", + "zh:ad07750576b99248037b897de71113cc19b1a8d0bc235eb99173cc83d0de3b1b", + "zh:b9f1c3bfadb74068f5c205292badb0661e17ac05eb23bfe8bd809691e4583d0e", + "zh:cc4cbcd67414fefb111c1bf7ab0bc4beb8c0b553d01719ad17de9a047adff4d1", + ] +} + +provider "registry.terraform.io/hashicorp/null" { + version = "3.2.3" + hashes = [ + "h1:+AnORRgFbRO6qqcfaQyeX80W0eX3VmjadjnUFUJTiXo=", + "zh:22d062e5278d872fe7aed834f5577ba0a5afe34a3bdac2b81f828d8d3e6706d2", + "zh:23dead00493ad863729495dc212fd6c29b8293e707b055ce5ba21ee453ce552d", + "zh:28299accf21763ca1ca144d8f660688d7c2ad0b105b7202554ca60b02a3856d3", + "zh:55c9e8a9ac25a7652df8c51a8a9a422bd67d784061b1de2dc9fe6c3cb4e77f2f", + "zh:756586535d11698a216291c06b9ed8a5cc6a4ec43eee1ee09ecd5c6a9e297ac1", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:9d5eea62fdb587eeb96a8c4d782459f4e6b73baeece4d04b4a40e44faaee9301", + "zh:a6355f596a3fb8fc85c2fb054ab14e722991533f87f928e7169a486462c74670", + "zh:b5a65a789cff4ada58a5baffc76cb9767dc26ec6b45c00d2ec8b1b027f6db4ed", + "zh:db5ab669cf11d0e9f81dc380a6fdfcac437aea3d69109c7aef1a5426639d2d65", + "zh:de655d251c470197bcbb5ac45d289595295acb8f829f6c781d4a75c8c8b7c7dd", + "zh:f5c68199f2e6076bce92a12230434782bf768103a427e9bb9abee99b116af7b5", + ] +} + +provider "registry.terraform.io/hashicorp/random" { + version = "3.5.1" + constraints = "3.5.1" + hashes = [ + "h1:VSnd9ZIPyfKHOObuQCaKfnjIHRtR7qTw19Rz8tJxm+k=", + "zh:04e3fbd610cb52c1017d282531364b9c53ef72b6bc533acb2a90671957324a64", + "zh:119197103301ebaf7efb91df8f0b6e0dd31e6ff943d231af35ee1831c599188d", + "zh:4d2b219d09abf3b1bb4df93d399ed156cadd61f44ad3baf5cf2954df2fba0831", + "zh:6130bdde527587bbe2dcaa7150363e96dbc5250ea20154176d82bc69df5d4ce3", + "zh:6cc326cd4000f724d3086ee05587e7710f032f94fc9af35e96a386a1c6f2214f", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:b6d88e1d28cf2dfa24e9fdcc3efc77adcdc1c3c3b5c7ce503a423efbdd6de57b", + "zh:ba74c592622ecbcef9dc2a4d81ed321c4e44cddf7da799faa324da9bf52a22b2", + "zh:c7c5cde98fe4ef1143bd1b3ec5dc04baf0d4cc3ca2c5c7d40d17c0e9b2076865", + "zh:dac4bad52c940cd0dfc27893507c1e92393846b024c5a9db159a93c534a3da03", + "zh:de8febe2a2acd9ac454b844a4106ed295ae9520ef54dc8ed2faf29f12716b602", + "zh:eab0d0495e7e711cca367f7d4df6e322e6c562fc52151ec931176115b83ed014", + ] +} + +provider "registry.terraform.io/kreuzwerker/docker" { + version = "3.0.2" + constraints = "3.0.2" + hashes = [ + "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", + "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", + "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", + "zh:38081b3fe317c7e9555b2aaad325ad3fa516a886d2dfa8605ae6a809c1072138", + "zh:4a9c5065b178082f79ad8160243369c185214d874ff5048556d48d3edd03c4da", + "zh:5438ef6afe057945f28bce43d76c4401254073de01a774760169ac1058830ac2", + "zh:60b7fadc287166e5c9873dfe53a7976d98244979e0ab66428ea0dea1ebf33e06", + "zh:61c5ec1cb94e4c4a4fb1e4a24576d5f39a955f09afb17dab982de62b70a9bdd1", + "zh:a38fe9016ace5f911ab00c88e64b156ebbbbfb72a51a44da3c13d442cd214710", + "zh:c2c4d2b1fd9ebb291c57f524b3bf9d0994ff3e815c0cd9c9bcb87166dc687005", + "zh:d567bb8ce483ab2cf0602e07eae57027a1a53994aba470fa76095912a505533d", + "zh:e83bf05ab6a19dd8c43547ce9a8a511f8c331a124d11ac64687c764ab9d5a792", + "zh:e90c934b5cd65516fbcc454c89a150bfa726e7cf1fe749790c7480bbeb19d387", + "zh:f05f167d2eaf913045d8e7b88c13757e3cf595dd5cd333057fdafc7c4b7fed62", + "zh:fcc9c1cea5ce85e8bcb593862e699a881bd36dffd29e2e367f82d15368659c3d", + ] +} + +provider "registry.terraform.io/lokkersp/sops" { + version = "0.6.10" + constraints = "0.6.10" + hashes = [ + "h1:atU8NIBxpNTWY+qBubvEOfjOn4K1aCDoq1iUFocgIHQ=", + "zh:0f053a26392a581b1f1ce6316cb7ed8ec4cc75e7f5f1cf7cfd45050b6b3c87ea", + "zh:207bb96c4471fce9aeb1b3c217d772692c3d865d294cf4d2501dad41de36a15e", + "zh:28506e8f1f3b9eaa95d99043440328044ee6340143535e5751538328a529d001", + "zh:3cae3bcea9e35fdc5b3f2af1b4580cd625c996448ad0c676c772260e46b25289", + "zh:3e44daaf82986c2b0028aeb17b867f3c68ed5dd8ac8625ba0406cf2a5fd3d92e", + "zh:457fb8ca2e677af24f9a4bdd8b613b1d7b604ad7133541657e5757c19268da71", + "zh:473d727c228f021a3df8cc8dcc6231ad7f90ed63f9e47c36b597d591e76228da", + "zh:48c4c1df39fd76ec8bd5fe9ac70cdc0927ac8be95582dbe46458b3442ce0fcd9", + "zh:728b19cb5c07e5e9d8b78fd94cc57d4c13582ecd24b7eb7c4cc2bf73b12fe4d1", + "zh:c51ed9af591779bb0910b82addeebb10f53428b994f8db653dd1dedcec60916c", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + ] +} diff --git a/terraform/hash-prometheus/backend.tf b/terraform/hash-prometheus/backend.tf new file mode 100644 index 0000000..d531b8d --- /dev/null +++ b/terraform/hash-prometheus/backend.tf @@ -0,0 +1,16 @@ +# Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa +terraform { + required_version = "~> 1.9.5" + + backend "s3" { + bucket = "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05" + key = "hash-prometheus/terraform.tfstate" + skip_region_validation = true + skip_credentials_validation = true + skip_metadata_api_check = true + skip_requesting_account_id = true + skip_s3_checksum = true + region = "eu-central-1" + endpoints = { s3 : "https://eu-central-1.linodeobjects.com" } + } +} diff --git a/terraform/hash-prometheus/main.tf b/terraform/hash-prometheus/main.tf new file mode 100644 index 0000000..cbf843e --- /dev/null +++ b/terraform/hash-prometheus/main.tf @@ -0,0 +1,36 @@ +terraform { + required_providers { + docker = { + source = "kreuzwerker/docker" + version = "3.0.2" + } + postgresql = { + source = "cyrilgdn/postgresql" + version = "1.21.0" + } + random = { + source = "hashicorp/random" + version = "3.5.1" + } + sops = { + source = "lokkersp/sops" + version = "0.6.10" + } + } +} + +locals { + host = "hash.trygvis.io" +} + +provider "docker" { + host = "ssh://${local.host}" +} + +data "docker_network" "traefik" { + name = "traefik" +} + +data "docker_network" "dn42" { + name = "dn42" +} diff --git a/terraform/hash-prometheus/play-config.yml b/terraform/hash-prometheus/play-config.yml new file mode 100644 index 0000000..92ec3e6 --- /dev/null +++ b/terraform/hash-prometheus/play-config.yml @@ -0,0 +1,17 @@ +- hosts: hash + tasks: + - become: yes + name: mkdir /etc/docker-service/prometheus + file: + path: /etc/docker-service/prometheus + state: directory + + - become: yes + name: cp /etc/docker-service/prometheus/prometheus.yml + register: config + copy: + src: prometheus.yml + dest: /etc/docker-service/prometheus/prometheus.yml + + - shell: docker kill --signal HUP prometheus + when: config.changed diff --git a/terraform/hash-prometheus/prometheus.tf b/terraform/hash-prometheus/prometheus.tf new file mode 100644 index 0000000..4c77ce8 --- /dev/null +++ b/terraform/hash-prometheus/prometheus.tf @@ -0,0 +1,60 @@ +data "docker_registry_image" "prometheus" { + name = "prom/prometheus:v2.53.2" +} + +resource "docker_image" "prometheus" { + name = data.docker_registry_image.prometheus.name + pull_triggers = [data.docker_registry_image.prometheus.sha256_digest] +} + +resource "docker_volume" "prometheus" { + name = "prometheus" +} + +resource "docker_container" "prometheus" { + image = docker_image.prometheus.image_id + name = "prometheus" + must_run = true + + env = [ + ] + + networks_advanced { + name = data.docker_network.dn42.name + } + + # networks_advanced { + # name = data.docker_network.traefik.name + # } + + # dynamic "labels" { + # for_each = [ + # { label = "traefik.enable", value = "true" }, + # { label = "traefik.docker.network", value = data.docker_network.traefik.name }, + # { label = "traefik.http.routers.prometheus.rule", value = "Host(`prometheus.trygvis.io`)" }, + # { label = "traefik.http.routers.prometheus.entrypoints", value = "websecure" }, + # { label = "traefik.http.routers.prometheus.tls.certresolver", value = "linode" }, + # ] + # content { + # label = labels.value["label"] + # value = labels.value["value"] + # } + # } + + mounts { + source = local.path + target = "/etc/prometheus" + type = "bind" + } + + volumes { + volume_name = docker_volume.prometheus.name + read_only = false + container_path = "/prometheus" + } + +} + +locals { + path = "/etc/docker-service/prometheus" +} diff --git a/terraform/hash-prometheus/prometheus.yml b/terraform/hash-prometheus/prometheus.yml new file mode 100644 index 0000000..b9e6e5a --- /dev/null +++ b/terraform/hash-prometheus/prometheus.yml @@ -0,0 +1,29 @@ +global: + scrape_interval: 60s + +scrape_configs: + - job_name: node + scrape_interval: 30s + static_configs: + - targets: + - "conflatorio.dn42.trygvis.io:9100" + - "coregonus.dn42.trygvis.io:9100" + - "hash.dn42.trygvis.io:9100" + - "knot.dn42.trygvis.io:9100" + - "lhn2pi.dn42.trygvis.io:9100" + + - job_name: bird + scrape_interval: 30s + static_configs: + - targets: + - "coregonus.dn42.trygvis.io:9324" + - "hash.dn42.trygvis.io:9324" + - "knot.dn42.trygvis.io:9324" + - "lhn2pi.dn42.trygvis.io:9324" + + - job_name: libvirt + scrape_interval: 30s + static_configs: + - targets: + - "conflatorio.dn42.trygvis.io:9177" + - "hash.dn42.trygvis.io:9177" diff --git a/terraform/hash-prometheus/terragrunt.hcl b/terraform/hash-prometheus/terragrunt.hcl new file mode 100644 index 0000000..e147285 --- /dev/null +++ b/terraform/hash-prometheus/terragrunt.hcl @@ -0,0 +1,3 @@ +include "root" { + path = find_in_parent_folders() +} diff --git a/terraform/ipam6/ipam6.tf b/terraform/ipam6/ipam6.tf new file mode 100644 index 0000000..0cdd754 --- /dev/null +++ b/terraform/ipam6/ipam6.tf @@ -0,0 +1,208 @@ +output "networks" { + value = { + bitraf_dn42 = { + range = "fdb1:4242:3538::/48" + address = "fdb1:4242:3538::" + prefix = "48" + hosts = { + } + } + tnet_dn42 = { + range = "fdb1:4242:3538:2000::/52" + address = "fdb1:4242:3538:2000::" + prefix = "52" + hosts = { + } + } + unused_2001 = { + range = "fdb1:4242:3538:2001::/64" + address = "fdb1:4242:3538:2001::" + prefix = "64" + hosts = { + } + } + node1_dn42 = { + range = "fdb1:4242:3538:2002::/64" + address = "fdb1:4242:3538:2002::" + prefix = "64" + hosts = { + node1 = { + address : "fdb1:4242:3538:2002::ffff" + prefix : "128" + } + } + } + node2_dn42 = { + range = "fdb1:4242:3538:2003::/64" + address = "fdb1:4242:3538:2003::" + prefix = "64" + hosts = { + node2 = { + address : "fdb1:4242:3538:2003::ffff" + prefix : "128" + } + } + } + knot_dn42 = { + range = "fdb1:4242:3538:2004::/64" + address = "fdb1:4242:3538:2004::" + prefix = "64" + hosts = { + knot = { + address : "fdb1:4242:3538:2004::ffff" + prefix : "128" + } + } + } + coregonus_dn42 = { + range = "fdb1:4242:3538:2005::/64" + address = "fdb1:4242:3538:2005::" + prefix = "64" + hosts = { + coregonus = { + address : "fdb1:4242:3538:2005::ffff" + prefix : "128" + } + } + } + coregonus_docker = { + range = "fdb1:4242:3538:2005:df01:676a:ec28:0a00/120" + address = "fdb1:4242:3538:2005:df01:676a:ec28:a00" + prefix = "120" + hosts = { + } + } + kv24_dn42 = { + range = "fdb1:4242:3538:2006::/64" + address = "fdb1:4242:3538:2006::" + prefix = "64" + hosts = { + kv24ix = { + address : "fdb1:4242:3538:2006::ffff" + prefix : "128" + } + } + } + hash_dn42 = { + range = "fdb1:4242:3538:2007::/64" + address = "fdb1:4242:3538:2007::" + prefix = "64" + hosts = { + hash = { + address : "fdb1:4242:3538:2007::ffff" + prefix : "128" + } + } + } + hash_docker_dn42 = { + range = "fdb1:4242:3538:2007:1001::/112" + address = "fdb1:4242:3538:2007:1001::" + prefix = "112" + hosts = { + } + } + lhn2_dn42 = { + range = "fdb1:4242:3538:2008::/64" + address = "fdb1:4242:3538:2008::" + prefix = "64" + hosts = { + lhn2pi = { + address : "fdb1:4242:3538:2008::ffff" + prefix : "128" + } + conflatorio = { + address : "fdb1:4242:3538:2008:8042:32ff:fe0c:7161" + prefix : "128" + } + danneri = { + address : "fdb1:4242:3538:2008:9422:d355:95b7:f170" + prefix : "128" + } + unifi = { + address : "fdb1:4242:3538:2008:5054:ff:fe4d:96c" + prefix : "128" + } + } + } + danneri_cluster = { + range = "fdb1:4242:3538:3009::/112" + address = "fdb1:4242:3538:3009::" + prefix = "112" + hosts = { + } + } + danneri_service = { + range = "fdb1:4242:3538:300a::/100" + address = "fdb1:4242:3538:300a::" + prefix = "100" + hosts = { + } + } + k8s = { + range = "fdb1:4242:3538:3000::/52" + address = "fdb1:4242:3538:3000::" + prefix = "52" + hosts = { + } + } + danneri_service2 = { + range = "fdb1:4242:3538:300a::/112" + address = "fdb1:4242:3538:300a::" + prefix = "112" + hosts = { + } + } + dn42 = { + range = "fd00::/8" + address = "fd00::" + prefix = "8" + hosts = { + } + } + } +} + +output "hosts" { + value = { + node1 = { + address : "fdb1:4242:3538:2002::ffff" + prefix : "128" + } + node2 = { + address : "fdb1:4242:3538:2003::ffff" + prefix : "128" + } + knot = { + address : "fdb1:4242:3538:2004::ffff" + prefix : "128" + } + coregonus = { + address : "fdb1:4242:3538:2005::ffff" + prefix : "128" + } + kv24ix = { + address : "fdb1:4242:3538:2006::ffff" + prefix : "128" + } + hash = { + address : "fdb1:4242:3538:2007::ffff" + prefix : "128" + } + lhn2pi = { + address : "fdb1:4242:3538:2008::ffff" + prefix : "128" + } + conflatorio = { + address : "fdb1:4242:3538:2008:8042:32ff:fe0c:7161" + prefix : "128" + } + danneri = { + address : "fdb1:4242:3538:2008:9422:d355:95b7:f170" + prefix : "128" + } + unifi = { + address : "fdb1:4242:3538:2008:5054:ff:fe4d:96c" + prefix : "128" + } + } +} diff --git a/terraform/telegraf/conflatorio/vault.yml b/terraform/telegraf/conflatorio/vault.yml index 90061a8..e380599 100644 --- a/terraform/telegraf/conflatorio/vault.yml +++ b/terraform/telegraf/conflatorio/vault.yml @@ -1,5 +1,4 @@ influx_token: ENC[AES256_GCM,data:48AbbP7v1QRvK7h73J6RYb1BBXsKdF+8YREXqtvPlEk3DFHoncmPIVWCH0G8it21BJtBsAupnJCPoa9IR7nJMWZMy/2NotmjeJuBD7LYY05BFEs4K5y+yw==,iv:RbWI8JWTg1LHqNUAEsx42rFp7IIntkz7PR6l/kCl7z8=,tag:lCpcfh7xQR+29RhWEkG1lA==,type:str] -config_url: ENC[AES256_GCM,data:tlhn8wfyD7EETkWGeeLEVOVQ3OS+PXnfWL6zXbuKYxz2I4EftRTAG9QAGCw2nb2VpTkBG4AE3kkLKLTiNWFBQsQ=,iv:V1pSBlTeE3zFBI29DtrzgAySHxhTS5jp8kuc7HtCKiI=,tag:Yo8vqUr9gohQYvuwqFkdFw==,type:str] sops: kms: [] gcp_kms: [] @@ -15,8 +14,8 @@ sops: Snd2V1FCL0hXUHA0R0FyUHBEUmNoeTAKK3uEAXKZetmJmn9vwleVzpfvIqyDMbuv FEYrJ4oBr+NykSfWqZSLB+y4DPTNyE2jhZ1vOK1u/CcxisaVa3o7+A== -----END AGE ENCRYPTED FILE----- - lastmodified: "2023-10-26T17:50:27Z" - mac: ENC[AES256_GCM,data:eFMCwmDaAvVaF1a45UQo/Z0lahAPVw5Mi7MH0m/UcVmvczad31gbPNuSZDAHyF+CWz4RmVCuqR0ukRBBXF5y18mVaTWC0zXhBaMsYIV3LR4CrdJ3wgmD5uY91X4un1aPJ/iR6T7w0wPfEaSnTR00n+f7tVhmyVfl6+9IwuUlcUo=,iv:Kme2RcQXWpYKPXfbzmK0JxbNyJqK1PEvLO6K4smWMLM=,tag:11nLZIVh7AYqhcO+1E6HmA==,type:str] + lastmodified: "2023-10-31T14:31:13Z" + mac: ENC[AES256_GCM,data:0KMb/2PdJybWd47RFIDn5bLaQzjKLATPDSgjmT7O79ErKvRu5gqt/or04kPcla1ToofNza1b1tH2nvJONTrIx8I/GCvy1nNa1sFfFa8cbb12em1SWwVIrqG8O2zEiQ9Wh2FW4x2wFRTinOEzwhAnum5OPD2K58fPWm6jFsG9fxY=,iv:SeCYnl/dngeAGOtTL3/qblrMXvRPPTfnhjoVSmbNGZA=,tag:t8grQyCkM0SWWFYWUomIJg==,type:str] pgp: [] unencrypted_suffix: _unencrypted version: 3.7.3 diff --git a/terraform/terragrunt.hcl b/terraform/terragrunt.hcl index e7e5f6a..8af2aca 100644 --- a/terraform/terragrunt.hcl +++ b/terraform/terragrunt.hcl @@ -1,16 +1,20 @@ generate "backend" { path = "backend.tf" if_exists = "overwrite_terragrunt" - contents = <<EOF + contents = <<EOF terraform { + required_version = "~> 1.9.5" + backend "s3" { bucket = "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05" key = "${path_relative_to_include()}/terraform.tfstate" skip_region_validation = true skip_credentials_validation = true skip_metadata_api_check = true + skip_requesting_account_id = true + skip_s3_checksum = true region = "eu-central-1" - endpoint = "eu-central-1.linodeobjects.com" + endpoints = { s3 : "https://eu-central-1.linodeobjects.com" } } } EOF diff --git a/terraform/unifi-controller/.terraform.lock.hcl b/terraform/unifi-controller/.terraform.lock.hcl index 9fa446f..e61b376 100644 --- a/terraform/unifi-controller/.terraform.lock.hcl +++ b/terraform/unifi-controller/.terraform.lock.hcl @@ -24,24 +24,24 @@ provider "registry.terraform.io/cyrilgdn/postgresql" { } provider "registry.terraform.io/kreuzwerker/docker" { - version = "3.0.1" - constraints = "3.0.1" + version = "3.0.2" + constraints = "3.0.2" hashes = [ - "h1:X2wZHQoG54NmtojeFcX0PSJPelaIejQRqyyI2h+LjWg=", - "zh:02f60126ca16b344092df3c315296bf1a216c3b2a68eddb3c89fdfa5ea826118", - "zh:0d2ee9624a54dbc10538b0c4e296348641b9bfba1354b3f872e43f7ec69a75f2", - "zh:473d7427da8c9efc231266abc7fdc27fca5f9ee0bdfcdb9914f0a2886e3e23b8", - "zh:5f0189bcd0c944c001098cb17a23efa79df8f0eec8644a64fe0e4200983ba5b7", - "zh:6200319c41d6baad3f46701a4028412f8ae2496e29fc4fef9584cc71da5fbbe6", - "zh:650be621f2216b1240f148eae8fcf80ec57c35925e2b212db7c23a70b9e67e06", - "zh:72fcfa6207251105066a34f0ec6d27ecc658b565e84fa946da376dd1afadd265", - "zh:92fc352a2090d3d380c7c8e8bbdf6f99d93a0182701056bb1d2dbfd5049e8ca6", - "zh:a7e2ef666c2a7eb5661b06cfbd7635cb9543524e7bf6a3851dcf6eacc9950cc4", - "zh:a8604595e61e8919c51a8656800c8c64557f9a2bc00309315895b380f2e9be19", - "zh:caf65603a84b749d8f3af2ee47b66f7e21d481f981e2e1d1d59838751c5e3be4", - "zh:dad40c4e57da284e7f57b5c0cc9dfac3cb27b01d2f2436fbe3464f0a2111b262", - "zh:dc1b173dbcba9d74879b16f36f6d9e97ef62fbd6fca8db79ec4fe4ec69c0e2f3", - "zh:e506d04677383b6d62bd69d42dc9005e27a45ccc2efc6e0de607e1f8445981d2", + "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", + "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", + "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", + "zh:38081b3fe317c7e9555b2aaad325ad3fa516a886d2dfa8605ae6a809c1072138", + "zh:4a9c5065b178082f79ad8160243369c185214d874ff5048556d48d3edd03c4da", + "zh:5438ef6afe057945f28bce43d76c4401254073de01a774760169ac1058830ac2", + "zh:60b7fadc287166e5c9873dfe53a7976d98244979e0ab66428ea0dea1ebf33e06", + "zh:61c5ec1cb94e4c4a4fb1e4a24576d5f39a955f09afb17dab982de62b70a9bdd1", + "zh:a38fe9016ace5f911ab00c88e64b156ebbbbfb72a51a44da3c13d442cd214710", + "zh:c2c4d2b1fd9ebb291c57f524b3bf9d0994ff3e815c0cd9c9bcb87166dc687005", + "zh:d567bb8ce483ab2cf0602e07eae57027a1a53994aba470fa76095912a505533d", + "zh:e83bf05ab6a19dd8c43547ce9a8a511f8c331a124d11ac64687c764ab9d5a792", + "zh:e90c934b5cd65516fbcc454c89a150bfa726e7cf1fe749790c7480bbeb19d387", + "zh:f05f167d2eaf913045d8e7b88c13757e3cf595dd5cd333057fdafc7c4b7fed62", + "zh:fcc9c1cea5ce85e8bcb593862e699a881bd36dffd29e2e367f82d15368659c3d", ] } diff --git a/terraform/unifi-controller/backend.tf b/terraform/unifi-controller/backend.tf index 5f2d6d0..bebc5a5 100644 --- a/terraform/unifi-controller/backend.tf +++ b/terraform/unifi-controller/backend.tf @@ -1,12 +1,16 @@ # Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa terraform { + required_version = "~> 1.9.5" + backend "s3" { bucket = "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05" key = "unifi-controller/terraform.tfstate" skip_region_validation = true skip_credentials_validation = true skip_metadata_api_check = true + skip_requesting_account_id = true + skip_s3_checksum = true region = "eu-central-1" - endpoint = "eu-central-1.linodeobjects.com" + endpoints = { s3 : "https://eu-central-1.linodeobjects.com" } } } diff --git a/terraform/unifi-controller/main.tf b/terraform/unifi-controller/main.tf index f5f7b0a..f93bc78 100644 --- a/terraform/unifi-controller/main.tf +++ b/terraform/unifi-controller/main.tf @@ -1,10 +1,8 @@ terraform { - required_version = "~> 1.3.5" - required_providers { docker = { source = "kreuzwerker/docker" - version = "3.0.1" + version = "3.0.2" } linode = { source = "linode/linode" @@ -22,14 +20,17 @@ terraform { } provider "docker" { - host = "ssh://conflatorio.vpn.trygvis.io" + host = "ssh://unifi.dn42.trygvis.io" } locals { domain_name = "unifi.vpn.trygvis.io" - docker_image_controller = "lscr.io/linuxserver/unifi-controller:8.0.24-mongoless" - docker_image_mongo = "mongo:7.0" + public_ip = module.ipam.hosts.unifi.address + +# docker_image_controller = "lscr.io/linuxserver/unifi-controller:8.0.24-mongoless" + docker_image_controller = "lscr.io/linuxserver/unifi-network-application:8.5.6-ls68" + docker_image_mongo = "mongo:7.0" mongo_database = "unifi" mongo_username = "unifi" @@ -40,3 +41,7 @@ data "sops_file_entry" "mongo_password" { source_file = "sops.yml" data_key = "mongo_password" } + +module "ipam" { + source = "../ipam6" +} diff --git a/terraform/unifi-controller/mongo.tf b/terraform/unifi-controller/mongo.tf index 98b4e36..f7c1950 100644 --- a/terraform/unifi-controller/mongo.tf +++ b/terraform/unifi-controller/mongo.tf @@ -1,6 +1,6 @@ -resource "docker_network" "unifi" { - name = "unifi" -} +# resource "docker_network" "unifi" { +# name = "unifi" +# } data "docker_registry_image" "mongo" { name = local.docker_image_mongo @@ -20,19 +20,22 @@ resource "docker_container" "unifi-mongo" { name = "unifi-mongo" hostname = "unifi-mongo" - networks_advanced { - name = docker_network.unifi.name - } +# networks_advanced { +# name = docker_network.unifi.name +# } + + network_mode = "host" volumes { volume_name = docker_volume.unifi-mongo.name + read_only = false container_path = "/data/db" } } output "mongo_init_js" { sensitive = true - value = <<-EOF + value = <<-EOF db.getSiblingDB("${local.mongo_database}"). createUser({ user: "${local.mongo_database}", diff --git a/terraform/unifi-controller/terragrunt.hcl b/terraform/unifi-controller/terragrunt.hcl index 5236c23..f378bf5 100644 --- a/terraform/unifi-controller/terragrunt.hcl +++ b/terraform/unifi-controller/terragrunt.hcl @@ -2,10 +2,6 @@ include "root" { path = find_in_parent_folders() } -dependency "docker" { - config_path = "../conflatorio-docker" -} - -# inputs = { -# vpc_id = dependency.docker.outputs.foo -# } +#dependency "ipam6" { +# config_path = "../ipam6" +#} 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}", ] |