# The "cfddns" job runs a periodic Cloudflare dynamic DNS updater. # It reads a Cloudflare API token and domain list from Nomad variables # and updates DNS records to point to the current public IP. # # For more information on cfddns, refer to: # # https://github.com/lhaig/cfddns variable "datacenters" { description = "List of datacenters to deploy to" type = list(string) default = ["dc1"] } variable "cfddns_version" { description = "cfddns Docker image tag" type = string default = "latest" } variable "cron" { description = "Cron expression for update schedule" type = string default = "0 6,18 * * *" } variable "nomad_var_path" { description = "Path to the Nomad variable containing api_token and domains" type = string default = "nomad/jobs/cfddns" } job "cfddns" { datacenters = var.datacenters type = "batch" periodic { crons = [var.cron] prohibit_overlap = true } group "dyndns" { task "update" { driver = "docker" config { image = "lhaig/cfddns:${var.cfddns_version}" args = [ "-api-token", "${CLOUDFLARE_API_TOKEN}", "-domain-file", "${NOMAD_SECRETS_DIR}/domains.json", ] } template { destination = "${NOMAD_SECRETS_DIR}/cfdns.env" env = true data = <