From d428c8644b00837c9ebf0f5df4acaafa4c4fb232 Mon Sep 17 00:00:00 2001 From: Matthew Baggett <matthew@baggett.me> Date: Fri, 14 Feb 2025 20:51:43 +0100 Subject: [PATCH] Deopinionate for now --- products/ddclient/ddclient.conf.tpl | 13 +++++++++++ products/ddclient/ddclient.tf | 32 +++++++++++++++++++++++++ products/ddclient/inputs.tf | 36 +++++++++++++++++++++++++++++ products/ddclient/terraform.tf | 20 ++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 products/ddclient/ddclient.conf.tpl create mode 100644 products/ddclient/ddclient.tf create mode 100644 products/ddclient/inputs.tf create mode 100644 products/ddclient/terraform.tf diff --git a/products/ddclient/ddclient.conf.tpl b/products/ddclient/ddclient.conf.tpl new file mode 100644 index 0000000..d20a85b --- /dev/null +++ b/products/ddclient/ddclient.conf.tpl @@ -0,0 +1,13 @@ +# General +daemon=300 + +# Router +usev4=${router} + +# Dynamic DNS service +protocol=${protocol} +%{ if login != null }login=${login}%{ endif } +%{ if password != null }password=${password}%{ endif } +%{ if apikey != null }apikey=${apikey}%{ endif } +%{ if secretapikey != null }secretapikey=${secretapikey}%{ endif } +${domain} \ No newline at end of file diff --git a/products/ddclient/ddclient.tf b/products/ddclient/ddclient.tf new file mode 100644 index 0000000..646f0b8 --- /dev/null +++ b/products/ddclient/ddclient.tf @@ -0,0 +1,32 @@ +module "service" { + source = "../../docker/service" + image = "linuxserver/ddclient" + service_name = "ddclient" + stack_name = var.stack_name + placement_constraints = var.placement_constraints + #configs = { + # "/defaults/ddclient.conf" = templatefile("${path.module}/ddclient.conf.tpl", { + # protocol = var.protocol + # login = var.login + # password = var.password + # apikey = var.apikey + # secretapikey = var.secretapikey + # }) + #} + secrets = { + "/defaults/ddclient.conf" = templatefile("${path.module}/ddclient.conf.tpl", { + protocol = var.protocol + router = var.router + login = var.login + password = var.password + apikey = var.apikey + secretapikey = var.secretapikey + domain = var.domain + }) + } + environment_variables = { + PUID = 1000 + PGID = 1000 + } + converge_enable = false # @todo Add healthcheck and enable this. +} diff --git a/products/ddclient/inputs.tf b/products/ddclient/inputs.tf new file mode 100644 index 0000000..ab9eb6b --- /dev/null +++ b/products/ddclient/inputs.tf @@ -0,0 +1,36 @@ +variable "stack_name" { + default = "dns" + type = string + description = "The name of the stack to create." +} +variable "placement_constraints" { + default = [] + type = list(string) + description = "Docker Swarm placement constraints" +} +variable "protocol" { + type = string +} +variable "router" { + type = string + default = "webv4,webv4=ipify-ipv4" +} +variable "domain" { + type = string +} +variable "login" { + type = string + default = null +} +variable "password" { + type = string + default = null +} +variable "apikey" { + type = string + default = null +} +variable "secretapikey" { + type = string + default = null +} \ No newline at end of file diff --git a/products/ddclient/terraform.tf b/products/ddclient/terraform.tf new file mode 100644 index 0000000..bacc852 --- /dev/null +++ b/products/ddclient/terraform.tf @@ -0,0 +1,20 @@ +terraform { + required_version = "~> 1.6" + + required_providers { + docker = { + source = "kreuzwerker/docker" + version = "~> 3.0" + } + random = { + source = "hashicorp/random" + version = "~> 3.5" + } + htpasswd = { + source = "loafoe/htpasswd" + version = "~> 1.0" + } + } +} + +