diff options
33 files changed, 923 insertions, 7 deletions
diff --git a/ansible/group_vars/all/ipam.yml b/ansible/group_vars/all/ipam.yml index e025551..0d49b1b 100644 --- a/ansible/group_vars/all/ipam.yml +++ b/ansible/group_vars/all/ipam.yml @@ -39,6 +39,7 @@ ipam6: range: "fdb1:4242:3538:2006::/64" hosts: kv24ix: "fdb1:4242:3538:2006::ffff" + garasjepi: "fdb1:4242:3538:2005:37df:fafe:392:f991" hash_dn42: range: "fdb1:4242:3538:2007::/64" hosts: @@ -49,6 +50,8 @@ ipam6: range: "fdb1:4242:3538:2008::/64" hosts: lhn2pi: "fdb1:4242:3538:2008::ffff" + lhn2-z2m: "fdb1:4242:3538:2008:9aed:e460:1711:07dd" + ha-lhn2: "fdb1:4242:3538:2008:9c59:926f:1dc9:89db" conflatorio: "fdb1:4242:3538:2008:8042:32ff:fe0c:7161" danneri: "fdb1:4242:3538:2008:9422:d355:95b7:f170" unifi: "fdb1:4242:3538:2008:5054:ff:fe4d:96c" diff --git a/ansible/inventory b/ansible/inventory index 91e463e..1684d93 100644 --- a/ansible/inventory +++ b/ansible/inventory @@ -48,6 +48,8 @@ all: ansible_host: danneri.dn42.trygvis.io unifi: ansible_host: unifi.dn42.trygvis.io + garasjepi: + ansible_host: garasjepi.dn42.trygvis.io node1: ansible_host: 9859f51e-1e3e-4c05-a826-b7fbe18d91be.pub.instances.scw.cloud @@ -199,4 +201,9 @@ all: node1: node2: + zigbee2mqtt: + hosts: + garasjepi: + lhn2pi: + # vim: set filetype=yaml: diff --git a/ansible/plays/files/zigbee2mqtt/garasjepi/configuration.yaml b/ansible/plays/files/zigbee2mqtt/garasjepi/configuration.yaml new file mode 100644 index 0000000..b0b8f5a --- /dev/null +++ b/ansible/plays/files/zigbee2mqtt/garasjepi/configuration.yaml @@ -0,0 +1,43 @@ +homeassistant: + enabled: false +frontend: + enabled: true +mqtt: + base_topic: zigbee2mqtt + #server: mqtt://ha-kv24.dn42.trygvis.io + server: mqtt://192.168.10.159 + user: z2m + password: zigbee2mqtt + version: 5 +serial: + port: /dev/ttyACM0 + adapter: deconz +advanced: + network_key: + - 107 + - 142 + - 62 + - 67 + - 150 + - 226 + - 182 + - 69 + - 47 + - 194 + - 244 + - 95 + - 73 + - 125 + - 135 + - 61 + pan_id: 43701 + ext_pan_id: + - 181 + - 224 + - 197 + - 29 + - 98 + - 176 + - 205 + - 241 +version: 4
\ No newline at end of file diff --git a/ansible/plays/host-garasjepi.yml b/ansible/plays/host-garasjepi.yml new file mode 100644 index 0000000..62b0b3d --- /dev/null +++ b/ansible/plays/host-garasjepi.yml @@ -0,0 +1,28 @@ +- hosts: + - garasjepi + tasks: + # These first + - become: yes + apt: + name: + - etckeeper + - git + + - become: yes + apt: + name: + - tmux + - aptitude + +# - import_role: +# name: timezone +# +# - import_role: +# name: systemd-networkd + + - become: yes + apt: + name: + - docker.io + - tmux + - aptitude diff --git a/ansible/plays/otelcol-contrib.yml b/ansible/plays/otelcol-contrib.yml new file mode 100644 index 0000000..f667337 --- /dev/null +++ b/ansible/plays/otelcol-contrib.yml @@ -0,0 +1,29 @@ +- hosts: + - coregonus + - hash + - knot + tasks: + + # otelcol-contrib.deb needs to be installed first + # adduser otelcol-contrib systemd-journal + + - name: /etc/otelcol-contrib/config.yaml + become: yes + template: + src: otelcol-contrib/config.yaml + dest: /etc/otelcol-contrib/config.yaml + notify: systemctl restart otelcol-contrib + + - name: mkdir /var/lib/otelcol/file_storage + become: yes + file: + path: /var/lib/otelcol/file_storage + owner: otelcol-contrib + notify: systemctl restart otelcol-contrib + + handlers: + - name: systemctl restart otelcol-contrib + become: yes + systemd: + service: otelcol-contrib + state: restarted diff --git a/ansible/plays/templates/otelcol-contrib/config.yaml b/ansible/plays/templates/otelcol-contrib/config.yaml new file mode 100644 index 0000000..671dbaa --- /dev/null +++ b/ansible/plays/templates/otelcol-contrib/config.yaml @@ -0,0 +1,65 @@ +receivers: + journald: + priority: debug + +exporters: + debug: + verbosity: detailed + + nop: + + otlphttp/hash: + endpoint: https://loki.trygvis.io/otlp + +extensions: + file_storage/journald: + +processors: + batch: {} + + transform/severity_parse: + log_statements: + - context: log + statements: + - set(resource.attributes["service.namespace"], "systemd") + - set(resource.attributes["service.name"], body["_SYSTEMD_UNIT"]) + - set(resource.attributes["systemd_unit"], body["_SYSTEMD_UNIT"]) + - set(resource.attributes["systemd_slice"], body["_SYSTEMD_SLICE"]) + - set(resource.attributes["node"], body["_HOSTNAME"]) + + - set(severity_number, SEVERITY_NUMBER_TRACE) where body["PRIORITY"] == "7" + - set(severity_text, "debug") where body["PRIORITY"] == "7" + - set(severity_number, SEVERITY_NUMBER_DEBUG) where body["PRIORITY"] == "6" + - set(severity_text, "info") where body["PRIORITY"] == "6" + - set(severity_number, SEVERITY_NUMBER_INFO) where body["PRIORITY"] == "5" + - set(severity_text, "notice") where body["PRIORITY"] == "5" + - set(severity_number, SEVERITY_NUMBER_WARN) where body["PRIORITY"] == "4" + - set(severity_text, "warning") where body["PRIORITY"] == "4" + - set(severity_number, SEVERITY_NUMBER_ERROR) where body["PRIORITY"] == "3" + - set(severity_text, "err") where body["PRIORITY"] == "3" + - set(severity_number, SEVERITY_NUMBER_FATAL) where body["PRIORITY"] == "2" + - set(severity_text, "crit") where body["PRIORITY"] == "2" + - set(severity_number, SEVERITY_NUMBER_FATAL) where body["PRIORITY"] == "1" + - set(severity_text, "alert") where body["PRIORITY"] == "1" + - set(severity_number, SEVERITY_NUMBER_FATAL) where body["PRIORITY"] == "0" + - set(severity_text, "emerg") where body["PRIORITY"] == "0" + + - set(body, body["MESSAGE"]) + +service: +# telemetry: +# logs: +# level: debug + extensions: + - file_storage/journald + pipelines: + logs: + receivers: + - journald + processors: + - transform/severity_parse + - batch + exporters: +# - debug +# - nop + - otlphttp/hash diff --git a/ansible/plays/zigbee2mqtt-backup.yml b/ansible/plays/zigbee2mqtt-backup.yml new file mode 100644 index 0000000..331045b --- /dev/null +++ b/ansible/plays/zigbee2mqtt-backup.yml @@ -0,0 +1,13 @@ +- hosts: + - zigbee2mqtt + tasks: + - become: yes + register: config + shell: + cmd: | + mp=$(docker volume inspect zigbee2mqtt --format '{{"{{.Mountpoint}}"}}') + cat $mp/configuration.yaml + - copy: + content: "{{ config.stdout }}" + dest: files/zigbee2mqtt/{{ ansible_hostname }}/configuration.yaml + delegate_to: localhost diff --git a/ansible/zigbee2mqtt.yml b/ansible/zigbee2mqtt.yml new file mode 100644 index 0000000..3e8e55c --- /dev/null +++ b/ansible/zigbee2mqtt.yml @@ -0,0 +1,7 @@ +- hosts: + - zigbee2mqtt + roles: + - role: docker + tags: docker + become: yes + diff --git a/docs/new-vm.md b/docs/new-vm.md index 6b76c0f..76e4eea 100644 --- a/docs/new-vm.md +++ b/docs/new-vm.md @@ -3,8 +3,9 @@ Download generic cloud image: cd /data3/libvirt/images/pool/ export TS=20240717-1811 wget https://cloud.debian.org/images/cloud/bookworm/$TS/debian-12-genericcloud-amd64-$TS.qcow2 - cp debian-$TS.qcow2 $VM.qcow2 + cp debian-*-$TS.qcow2 $VM.qcow2 qemu-img resize $VM.qcow2 20G + # This requires guestfs-tools virt-resize --expand /dev/sda1 debian-*$TS.qcow2 $VM.qcow2 Inject SSH key for root user: @@ -1,5 +1,7 @@ #ENC[AES256_GCM,data:VXrX0NUIHcFjmxHLuYzz9ekkR7N2IW/CF6a9U0dk/cvgtwoNLA==,iv:NIpefl6uO7c7ESxgCHXe3Y2x4cf9nLPjwDJo28xt5SY=,tag:U59KOg8Ny+O33Lf63Zjo1w==,type:comment] -linode_token: ENC[AES256_GCM,data:PeLIxcZ5mQMnp1LZy4saSUWIpCxrGm+3/6PssmIE9yO81x2HcGrgxO0CNl1feOtPrI1PVcAfFnFlpSetELLZlg==,iv:ETBKZgmFdIHoUROHVUzhxRoLS2uIuGR0SXZ96C9FhDk=,tag:pzuS8RLQf1A5ctmrOanVgA==,type:str] +#ENC[AES256_GCM,data:tGaEE5lsc+NutVre1el9hBL2U7CZ8LNFQZ5Q/AOZp5I=,iv:aF3gXP20Q74Y8shSNP9l17AgtVX83rEL1BvPXpAg+54=,tag:h87MkG5nokS2HLId+QFRQQ==,type:comment] +#ENC[AES256_GCM,data:/jkbA/Kv2BydOycNYyW13yncVDIEJ62bWQZuY6cjrXFt0ywZOQ01BvyyoiHF75VjSZrZPr3IFTuG21Q+g8yMPRopTpvSvtw0v7Tb6O6P,iv:cFeKYcDoyAsimh19yFa6AL0yX4NqUpq4ehTOYnW65iI=,tag:DV0gZdImGG4cOWVR3WnZzA==,type:comment] +linode_token: ENC[AES256_GCM,data:a9Uzjh+DzY1TRLaJ9r7tNYPY2rw+FMj2ldSsL3Dl0SbUCO3HOXN2lvgDHfG/0gqRqrqBd8ZCq60B//3SVqhA8w==,iv:klS15g5pRHImsd1bM2Tc/DjiqaQQVQ/xF5msrqsABU4=,tag:l6Y3u+xhIcm2WEtalka2cQ==,type:str] knot_pdb_terraform_password: ENC[AES256_GCM,data:cu5aUZAVrmtzgBB2hGfBkd+TU4vB0cWnBNluTHptyV0YvZuq,iv:HT4Cmr9huuylVt2vwFcrWUlBmDE6V3n0bXq/telJNBM=,tag:2RSvWnAAM5seHv12HyDprA==,type:str] sops: kms: [] @@ -34,8 +36,8 @@ sops: a1E2c3VEaWR0K3U4dnpqdm5RU0VCZUkKiOtFMhim7qAe4kDU2gijcCChesM0qAGk Z2xNVfBy4HH58cgWrtCQ6PRvULwAQ6Bgq59iZ7H/C2IFVqVfliajmw== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-08-21T18:05:07Z" - mac: ENC[AES256_GCM,data:Kxa9SCKy0pLCgqGd7f+xFbQz3Cpf9EfDYP1fwPiIweHhw8iFEeaI7WZCb9zXjsky1tuQ0nbJMHfVQaPSqLC+ACyrBioXIBjgITAfEg3xtpRYiSQRFVBtGA7HpEAKWeFquzTvBR/EAoDuEvFTkrup3JSE8sM3bWKVb2dy1uRyBIc=,iv:O5LO1TFJLlFdCOGWWk5xJlQtVF1+sZTCH2DUKQdvQGo=,tag:0USQg2+EYUVG3+FsjilssQ==,type:str] + lastmodified: "2025-03-30T18:19:37Z" + mac: ENC[AES256_GCM,data:Oyv/4fPW3+u7xsAPCM/JIZEFggmJfUMvk0ofLBjvH0steVJZ53KVzhQrb9D9JIOk4YE9xhhGxH2bHVnx6bm7oX4DtiaGf919NawepoBi0mu8pnbYsvEeFUY4nN5ZA++cGEQYMQDObGeXz6fwncIU6ZPzpcBKGf3hSPdswXNRC8M=,iv:AFT0+ibBnejgbDzZ96Rjz/ngDkC0UTqbkRia+WD4JcU=,tag:VFoXXi7WRRLvULs3EFojIA==,type:str] pgp: [] unencrypted_suffix: _unencrypted - version: 3.7.3 + version: 3.9.1 diff --git a/terraform/dns/dn42.tf b/terraform/dns/dn42.tf index 9f70413..45fb19d 100644 --- a/terraform/dns/dn42.tf +++ b/terraform/dns/dn42.tf @@ -21,6 +21,13 @@ resource "linode_domain_record" "dn42-danneri" { target = "fdb1:4242:3538:2008:9422:d355:95b7:f170" } +resource "linode_domain_record" "dn42-garasjepi" { + domain_id = linode_domain.root.id + name = "garasjepi.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2005:37df:fafe:392:f991" +} + resource "linode_domain_record" "dn42-ha-kv24" { domain_id = linode_domain.root.id name = "ha-kv24.dn42" @@ -28,6 +35,13 @@ resource "linode_domain_record" "dn42-ha-kv24" { target = "fdb1:4242:3538:2005:c534:9d54:8212:1ced" } +resource "linode_domain_record" "dn42-ha-lhn2" { + domain_id = linode_domain.root.id + name = "ha-lhn2.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2008:9c59:926f:1dc9:89db" +} + resource "linode_domain_record" "dn42-hash" { domain_id = linode_domain.root.id name = "hash.dn42" @@ -49,6 +63,13 @@ resource "linode_domain_record" "dn42-kv24ix" { target = "fdb1:4242:3538:2006::ffff" } +resource "linode_domain_record" "dn42-lhn2-z2m" { + domain_id = linode_domain.root.id + name = "lhn2-z2m.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2008:9aed:e460:1711:7dd" +} + resource "linode_domain_record" "dn42-lhn2pi" { domain_id = linode_domain.root.id name = "lhn2pi.dn42" diff --git a/terraform/dns/trygvis.tf b/terraform/dns/trygvis.tf index c3ffce0..667ba83 100644 --- a/terraform/dns/trygvis.tf +++ b/terraform/dns/trygvis.tf @@ -165,6 +165,13 @@ resource "linode_domain_record" "kv24" { target = "trygvis.io" } +resource "linode_domain_record" "lhn2" { + domain_id = linode_domain.root.id + name = "lhn2" + record_type = "CNAME" + target = "trygvis.io" +} + # Aliases for vs.trygvis.io resource "linode_domain_record" "nextcloud" { domain_id = linode_domain.root.id @@ -180,6 +187,13 @@ resource "linode_domain_record" "grafana" { target = "hash.trygvis.io" } +resource "linode_domain_record" "loki" { + domain_id = linode_domain.root.id + name = "loki" + record_type = "CNAME" + target = "hash.trygvis.io" +} + resource "linode_domain_record" "owncloud" { domain_id = linode_domain.root.id name = "owncloud" diff --git a/terraform/garasjepi-zigbee2mqtt/.terraform.lock.hcl b/terraform/garasjepi-zigbee2mqtt/.terraform.lock.hcl new file mode 100644 index 0000000..57bc928 --- /dev/null +++ b/terraform/garasjepi-zigbee2mqtt/.terraform.lock.hcl @@ -0,0 +1,24 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +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", + ] +} diff --git a/terraform/garasjepi-zigbee2mqtt/backend.tf b/terraform/garasjepi-zigbee2mqtt/backend.tf new file mode 100644 index 0000000..33340ba --- /dev/null +++ b/terraform/garasjepi-zigbee2mqtt/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 = "garasjepi-zigbee2mqtt/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/garasjepi-zigbee2mqtt/main.tf b/terraform/garasjepi-zigbee2mqtt/main.tf new file mode 100644 index 0000000..4d5bb25 --- /dev/null +++ b/terraform/garasjepi-zigbee2mqtt/main.tf @@ -0,0 +1,30 @@ +terraform { + required_providers { + docker = { + source = "kreuzwerker/docker" + version = "3.0.2" + } + } +} + +provider "docker" { + host = "ssh://${local.host}" +} + +locals { + host = "garasjepi.dn42.trygvis.io" + docker_image = "koenkk/zigbee2mqtt:1.42.0" + public_ip = module.ipam.hosts.garasjepi.address +} + +module "ipam" { + source = "../ipam6" +} + +module "zigbee2mqtt" { + source = "../modules/zigbee2mqtt" + + docker_version = "2.1" + public_ip = local.public_ip + serial_port = "/dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2698168-if00" +} diff --git a/terraform/garasjepi-zigbee2mqtt/terragrunt.hcl b/terraform/garasjepi-zigbee2mqtt/terragrunt.hcl new file mode 100644 index 0000000..e147285 --- /dev/null +++ b/terraform/garasjepi-zigbee2mqtt/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 index 3708024..96f50ec 100644 --- a/terraform/hash-docker/traefik.tf +++ b/terraform/hash-docker/traefik.tf @@ -3,7 +3,7 @@ resource "docker_network" "traefik" { } resource "docker_image" "traefik" { - name = "traefik:2.9.8" + name = "traefik:3.3.4" } resource "docker_container" "traefik" { @@ -31,7 +31,9 @@ resource "docker_container" "traefik" { } command = [ - "--log.level=DEBUG", + "--log.level=INFO", + "--log.format=common", + "--log.noColor=true", "--api=true", "--api.dashboard=true", "--api.debug=true", diff --git a/terraform/hash-loki/.terraform.lock.hcl b/terraform/hash-loki/.terraform.lock.hcl new file mode 100644 index 0000000..7020808 --- /dev/null +++ b/terraform/hash-loki/.terraform.lock.hcl @@ -0,0 +1,85 @@ +# 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" + 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-loki/backend.tf b/terraform/hash-loki/backend.tf new file mode 100644 index 0000000..699df68 --- /dev/null +++ b/terraform/hash-loki/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-loki/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-loki/loki-config.yaml b/terraform/hash-loki/loki-config.yaml new file mode 100644 index 0000000..72e68b0 --- /dev/null +++ b/terraform/hash-loki/loki-config.yaml @@ -0,0 +1,73 @@ +# Downloaded with wget https://raw.githubusercontent.com/grafana/loki/v3.0.0/cmd/loki/loki-local-config.yaml -O loki-config.yaml + +auth_enabled: false + +server: + http_listen_port: 3100 + grpc_listen_port: 9096 + +common: + instance_addr: 127.0.0.1 + path_prefix: /loki + storage: + filesystem: + chunks_directory: /loki/chunks + rules_directory: /loki/rules + replication_factor: 1 + ring: + kvstore: + store: inmemory + +query_range: + results_cache: + cache: + embedded_cache: + enabled: true + max_size_mb: 100 + +schema_config: + configs: + - from: 2020-10-24 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h + +ruler: + alertmanager_url: http://localhost:9093 + +# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration +# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/ +# +# Statistics help us better understand how Loki is used, and they show us performance +# levels for most users. This helps us prioritize features and documentation. +# For more information on what's sent, look at +# https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go +# Refer to the buildReport method to see what goes into a report. +# +# If you would like to disable reporting, uncomment the following lines: +analytics: + reporting_enabled: false + +distributor: + otlp_config: + default_resource_attributes_as_index_labels: + - cloud.availability_zone + - cloud.region + - container.name + - deployment.environment + - k8s.cluster.name + - k8s.container.name + - k8s.cronjob.name + - k8s.daemonset.name + - k8s.deployment.name + - k8s.job.name + - k8s.namespace.name + - k8s.pod.name + - k8s.replicaset.name + - k8s.statefulset.name + - service.instance.id + - service.name + - service.namespace diff --git a/terraform/hash-loki/loki.tf b/terraform/hash-loki/loki.tf new file mode 100644 index 0000000..1e09037 --- /dev/null +++ b/terraform/hash-loki/loki.tf @@ -0,0 +1,59 @@ +resource "docker_image" "loki" { + name = "grafana/loki:3.3.0" +} + +resource "docker_volume" "loki" { + name = "loki" +} + +resource "docker_container" "loki" { + image = docker_image.loki.image_id + name = "loki" + privileged = false + must_run = true + + command = [ + "-config.file=${local.container_config_dir}/loki-config.yaml" + ] + + network_mode = "bridge" + + networks_advanced { + name = data.docker_network.traefik.name + } + + networks_advanced { + 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.loki.rule", value = "Host(`loki.trygvis.io`)" }, + { label = "traefik.http.routers.loki.entrypoints", value = "websecure" }, + { label = "traefik.http.routers.loki.tls.certresolver", value = "linode" }, + ] + content { + label = labels.value["label"] + value = labels.value["value"] + } + } + + env = [ + ] + + mounts { + source = local.host_config_dir + target = local.container_config_dir + type = "bind" + read_only = false + } + + volumes { + volume_name = docker_volume.loki.name + container_path = "/loki" + read_only = false + } +} + diff --git a/terraform/hash-loki/main.tf b/terraform/hash-loki/main.tf new file mode 100644 index 0000000..7f00e45 --- /dev/null +++ b/terraform/hash-loki/main.tf @@ -0,0 +1,39 @@ +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" + host_config_dir = "/etc/docker-service/loki" + container_config_dir = "/config" +} + +provider "docker" { + host = "ssh://${local.host}" +} + +data "docker_network" "traefik" { + name = "traefik" +} + +data "docker_network" "dn42" { + name = "dn42" +} + diff --git a/terraform/hash-loki/play-config.yml b/terraform/hash-loki/play-config.yml new file mode 100644 index 0000000..955524f --- /dev/null +++ b/terraform/hash-loki/play-config.yml @@ -0,0 +1,17 @@ +- hosts: hash + tasks: + - become: yes + name: mkdir /etc/docker-service/loki + file: + path: /etc/docker-service/loki + state: directory + + - become: yes + name: cp /etc/docker-service/loki/loki-config.yaml + register: config + copy: + src: loki-config.yaml + dest: /etc/docker-service/loki/loki-config.yaml + +# - shell: docker kill --signal HUP loki +# when: config.changed diff --git a/terraform/hash-loki/terragrunt.hcl b/terraform/hash-loki/terragrunt.hcl new file mode 100644 index 0000000..e147285 --- /dev/null +++ b/terraform/hash-loki/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 index 4b7d494..79a350a 100644 --- a/terraform/ipam6/ipam6.tf +++ b/terraform/ipam6/ipam6.tf @@ -92,6 +92,10 @@ output "networks" { address : "fdb1:4242:3538:2006::ffff" prefix : "128" } + garasjepi = { + address : "fdb1:4242:3538:2005:37df:fafe:392:f991" + prefix : "128" + } } } hash_dn42 = { @@ -121,6 +125,14 @@ output "networks" { address : "fdb1:4242:3538:2008::ffff" prefix : "128" } + lhn2-z2m = { + address : "fdb1:4242:3538:2008:9aed:e460:1711:7dd" + prefix : "128" + } + ha-lhn2 = { + address : "fdb1:4242:3538:2008:9c59:926f:1dc9:89db" + prefix : "128" + } conflatorio = { address : "fdb1:4242:3538:2008:8042:32ff:fe0c:7161" prefix : "128" @@ -185,6 +197,10 @@ output "hosts" { address : "fdb1:4242:3538:2006::ffff" prefix : "128" } + garasjepi = { + address : "fdb1:4242:3538:2005:37df:fafe:392:f991" + prefix : "128" + } hash = { address : "fdb1:4242:3538:2007::ffff" prefix : "128" @@ -193,6 +209,14 @@ output "hosts" { address : "fdb1:4242:3538:2008::ffff" prefix : "128" } + lhn2-z2m = { + address : "fdb1:4242:3538:2008:9aed:e460:1711:7dd" + prefix : "128" + } + ha-lhn2 = { + address : "fdb1:4242:3538:2008:9c59:926f:1dc9:89db" + prefix : "128" + } conflatorio = { address : "fdb1:4242:3538:2008:8042:32ff:fe0c:7161" prefix : "128" diff --git a/terraform/lhn2pi-zigbee2mqtt/.terraform.lock.hcl b/terraform/lhn2pi-zigbee2mqtt/.terraform.lock.hcl new file mode 100644 index 0000000..e61b376 --- /dev/null +++ b/terraform/lhn2pi-zigbee2mqtt/.terraform.lock.hcl @@ -0,0 +1,87 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/cyrilgdn/postgresql" { + version = "1.18.0" + constraints = "1.18.0" + hashes = [ + "h1:Nf26liFILUZXPh1P2B8T3qtq2Tc7objtm0sBSt0lhh0=", + "zh:251b609167ce25e974607c0c7dd3f90cfc45980c9068364f896e26c31416d96c", + "zh:317980d14a6a171f118bb522ffd02046e508d98100073f97671aeb2adae30d79", + "zh:3622c6414e91f8ccceed94ddf12062a22c14de4fac73c6142b009ae791ca7cd4", + "zh:36be2b338c230b0ab0c7b4c55049dba9bd8d705973c2cceaf3e293d41f520db5", + "zh:4332e83b91f60c43679ff9660c8ef4ebe251e05926a4d20dc64db1bfbabc8670", + "zh:444835840c917aff17f49f9f7b4ae542d5bd9f2ec306b581d1931b00380213bd", + "zh:5174bd85ea94ed4a6cef6c02bc27498f47ac21841fcab7487ab19d8513c97e54", + "zh:61c6eb6b2bf18cdc0734c101854e25990ba24a16580c6bbc599a0b00f72be397", + "zh:b40bbc61a4e522b22ebd57f01a518370a97cd6945e4bdd2955e5f887c88ee3f6", + "zh:d7aeb158c884f6590d6033cd44d5e9438f648bcb5ca3bd54573847c287845b00", + "zh:da3bee1282f6b48572d15f7a693113931afb306b98e29c09c9a054bdc3d6df44", + "zh:ec864a068eeab48899d99405f5606379478df8e48c005844d63a5360c23d5e15", + "zh:fda709d1cabde236b79c98c9abb80f2c1591fdea751afadc546073056be6e6ba", + "zh:ff08607ab25d1c5b55c3794b67a4ee2c9ac5023962c196ce587df34f0e201ca6", + ] +} + +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/linode/linode" { + version = "1.30.0" + constraints = "1.30.0" + hashes = [ + "h1:rd4yQ7u3awn2kTqdKf5D67TTeo6rybYpDry/WwvolRA=", + "zh:197c61c5eb2252f65c18d2aa65cdc0511617b13e2388118f3fe063d7969dd7ad", + "zh:1a66470682acb13dc57308d5b1eaa19ff60c2404a3b15714e3072d02d569b1a5", + "zh:368cdcf17073a39687da830c02cf3ce50e0d8f03b7ec808b49561628be798abc", + "zh:42f2510a70afbb7fc8928df119d1e14ce1b61d2aded13b88072858ee5861feb2", + "zh:57734dd1e8255abd52a33ff79c20ef4efc3831850b22dd1a628e6301c3cf95c6", + "zh:61d614a7a4607bfc4ab6bfd0501007501957b973dbd028e0e513a3d4df07f12e", + "zh:79243f22fc0a9adfc1123abdd17c515f0ce4d8147302889033b6c44f6a48337e", + "zh:9f7cd46185bbe2c001dab1d0bd6c17a9740e7279d3fffe93755f2c964e267213", + "zh:9fdc9f8f47bde4140bc14cf082bbc2ceb63a3bebf0683df2fefd83c9e248274c", + "zh:aa1fd80a7ea245f8b852e40c68ccde2d8b6446e2138ebdec7425c67e82099881", + "zh:bb31f1ba5b0e001cf343d3a4cfafa70e6f3e30fd8a200d2cd7e077663efe0456", + "zh:da87881fa030287df2009028c49581e1fd0ff89baef0d8543b27ca506eff2971", + "zh:ed6afd7b1bc7237a9dff5c721ca3a5c7c505803cd5ea0b4ad0dfdf07ed6f9b0d", + "zh:ee653d5d08cb331ce2d8dc1010e68d363470ae87be62c0515e5d2418727cd02b", + ] +} + +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/lhn2pi-zigbee2mqtt/backend.tf b/terraform/lhn2pi-zigbee2mqtt/backend.tf new file mode 100644 index 0000000..7251725 --- /dev/null +++ b/terraform/lhn2pi-zigbee2mqtt/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 = "lhn2pi-zigbee2mqtt/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/lhn2pi-zigbee2mqtt/main.tf b/terraform/lhn2pi-zigbee2mqtt/main.tf new file mode 100644 index 0000000..2857b99 --- /dev/null +++ b/terraform/lhn2pi-zigbee2mqtt/main.tf @@ -0,0 +1,29 @@ +terraform { + required_providers { + docker = { + source = "kreuzwerker/docker" + version = "3.0.2" + } + } +} + +provider "docker" { + host = "ssh://${local.host}" +} + +locals { + host = "lhn2pi.dn42.trygvis.io" + docker_image = "koenkk/zigbee2mqtt:1.42.0" + public_ip = module.ipam.hosts.lhn2pi.address +} + +module "ipam" { + source = "../ipam6" +} + +module "zigbee2mqtt" { + source = "../modules/zigbee2mqtt" + + public_ip = local.public_ip + serial_port = "/dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2688076-if00" +} diff --git a/terraform/lhn2pi-zigbee2mqtt/terragrunt.hcl b/terraform/lhn2pi-zigbee2mqtt/terragrunt.hcl new file mode 100644 index 0000000..e147285 --- /dev/null +++ b/terraform/lhn2pi-zigbee2mqtt/terragrunt.hcl @@ -0,0 +1,3 @@ +include "root" { + path = find_in_parent_folders() +} diff --git a/terraform/modules/zigbee2mqtt/.terraform.lock.hcl b/terraform/modules/zigbee2mqtt/.terraform.lock.hcl new file mode 100644 index 0000000..e61b376 --- /dev/null +++ b/terraform/modules/zigbee2mqtt/.terraform.lock.hcl @@ -0,0 +1,87 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/cyrilgdn/postgresql" { + version = "1.18.0" + constraints = "1.18.0" + hashes = [ + "h1:Nf26liFILUZXPh1P2B8T3qtq2Tc7objtm0sBSt0lhh0=", + "zh:251b609167ce25e974607c0c7dd3f90cfc45980c9068364f896e26c31416d96c", + "zh:317980d14a6a171f118bb522ffd02046e508d98100073f97671aeb2adae30d79", + "zh:3622c6414e91f8ccceed94ddf12062a22c14de4fac73c6142b009ae791ca7cd4", + "zh:36be2b338c230b0ab0c7b4c55049dba9bd8d705973c2cceaf3e293d41f520db5", + "zh:4332e83b91f60c43679ff9660c8ef4ebe251e05926a4d20dc64db1bfbabc8670", + "zh:444835840c917aff17f49f9f7b4ae542d5bd9f2ec306b581d1931b00380213bd", + "zh:5174bd85ea94ed4a6cef6c02bc27498f47ac21841fcab7487ab19d8513c97e54", + "zh:61c6eb6b2bf18cdc0734c101854e25990ba24a16580c6bbc599a0b00f72be397", + "zh:b40bbc61a4e522b22ebd57f01a518370a97cd6945e4bdd2955e5f887c88ee3f6", + "zh:d7aeb158c884f6590d6033cd44d5e9438f648bcb5ca3bd54573847c287845b00", + "zh:da3bee1282f6b48572d15f7a693113931afb306b98e29c09c9a054bdc3d6df44", + "zh:ec864a068eeab48899d99405f5606379478df8e48c005844d63a5360c23d5e15", + "zh:fda709d1cabde236b79c98c9abb80f2c1591fdea751afadc546073056be6e6ba", + "zh:ff08607ab25d1c5b55c3794b67a4ee2c9ac5023962c196ce587df34f0e201ca6", + ] +} + +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/linode/linode" { + version = "1.30.0" + constraints = "1.30.0" + hashes = [ + "h1:rd4yQ7u3awn2kTqdKf5D67TTeo6rybYpDry/WwvolRA=", + "zh:197c61c5eb2252f65c18d2aa65cdc0511617b13e2388118f3fe063d7969dd7ad", + "zh:1a66470682acb13dc57308d5b1eaa19ff60c2404a3b15714e3072d02d569b1a5", + "zh:368cdcf17073a39687da830c02cf3ce50e0d8f03b7ec808b49561628be798abc", + "zh:42f2510a70afbb7fc8928df119d1e14ce1b61d2aded13b88072858ee5861feb2", + "zh:57734dd1e8255abd52a33ff79c20ef4efc3831850b22dd1a628e6301c3cf95c6", + "zh:61d614a7a4607bfc4ab6bfd0501007501957b973dbd028e0e513a3d4df07f12e", + "zh:79243f22fc0a9adfc1123abdd17c515f0ce4d8147302889033b6c44f6a48337e", + "zh:9f7cd46185bbe2c001dab1d0bd6c17a9740e7279d3fffe93755f2c964e267213", + "zh:9fdc9f8f47bde4140bc14cf082bbc2ceb63a3bebf0683df2fefd83c9e248274c", + "zh:aa1fd80a7ea245f8b852e40c68ccde2d8b6446e2138ebdec7425c67e82099881", + "zh:bb31f1ba5b0e001cf343d3a4cfafa70e6f3e30fd8a200d2cd7e077663efe0456", + "zh:da87881fa030287df2009028c49581e1fd0ff89baef0d8543b27ca506eff2971", + "zh:ed6afd7b1bc7237a9dff5c721ca3a5c7c505803cd5ea0b4ad0dfdf07ed6f9b0d", + "zh:ee653d5d08cb331ce2d8dc1010e68d363470ae87be62c0515e5d2418727cd02b", + ] +} + +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/modules/zigbee2mqtt/main.tf b/terraform/modules/zigbee2mqtt/main.tf new file mode 100644 index 0000000..a238e2d --- /dev/null +++ b/terraform/modules/zigbee2mqtt/main.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + docker = { + source = "kreuzwerker/docker" + version = "3.0.2" + } + } +} diff --git a/terraform/modules/zigbee2mqtt/vars.tf b/terraform/modules/zigbee2mqtt/vars.tf new file mode 100644 index 0000000..2dcf69c --- /dev/null +++ b/terraform/modules/zigbee2mqtt/vars.tf @@ -0,0 +1,17 @@ +variable "docker_image" { + type = string + default = "koenkk/zigbee2mqtt" +} + +variable "docker_version" { + type = string + default = "1.42.0" +} + +variable "public_ip" { + type = string +} + +variable "serial_port" { + type = string +} diff --git a/terraform/modules/zigbee2mqtt/zigbee2mqtt.tf b/terraform/modules/zigbee2mqtt/zigbee2mqtt.tf new file mode 100644 index 0000000..467c5e1 --- /dev/null +++ b/terraform/modules/zigbee2mqtt/zigbee2mqtt.tf @@ -0,0 +1,45 @@ +data "docker_registry_image" "zigbee2mqtt" { + name = "${var.docker_image}:${var.docker_version}" +} + +resource "docker_image" "zigbee2mqtt" { + name = data.docker_registry_image.zigbee2mqtt.name + pull_triggers = [data.docker_registry_image.zigbee2mqtt.sha256_digest] +} + +resource "docker_volume" "zigbee2mqtt" { + name = "zigbee2mqtt" +} + +resource "docker_container" "zigbee2mqtt" { + image = docker_image.zigbee2mqtt.image_id + name = "zigbee2mqtt" + hostname = "zigbee2mqtt" + # privileged = true + must_run = true + + network_mode = "host" + + ports { + internal = 8080 + external = 8080 + protocol = "tcp" + ip = var.public_ip + } + + volumes { + volume_name = docker_volume.zigbee2mqtt.name + read_only = false + container_path = "/app/data" + } + + env = [ + "TZ=Europe/Oslo", + ] + + devices { + host_path = var.serial_port + container_path = "/dev/ttyACM0" +# permissions = "rwm" + } +} |