From 38597a7eda994ecf97fb624ea88b780f9a1f543c Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Thu, 19 May 2022 16:53:56 -0700 Subject: [PATCH] Dynamically add dns routes to traefik instances to blocky --- nomad/blocky/blocky.tf | 3 --- nomad/blocky/config.yml | 9 ++++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/nomad/blocky/blocky.tf b/nomad/blocky/blocky.tf index 9d1246f..9765d7e 100644 --- a/nomad/blocky/blocky.tf +++ b/nomad/blocky/blocky.tf @@ -9,9 +9,6 @@ locals { "${path.module}/config.yml", { "base_hostname" = "${var.base_hostname}", - # Could get this from consul_service.traefik - # but not sure what happens if it doens't exist yet - "ingress_address" = "192.168.2.106", } ) } diff --git a/nomad/blocky/config.yml b/nomad/blocky/config.yml index 6ad87e9..98af1c3 100644 --- a/nomad/blocky/config.yml +++ b/nomad/blocky/config.yml @@ -25,7 +25,14 @@ blocking: customDNS: customTTL: 1h mapping: - ${base_hostname}: ${ingress_address} + {{ with service "traefik" -}} + {{- $last := len . | subtract 1 -}} + {{- $services := . -}} + ${base_hostname}: {{ range $i := loop $last -}} + {{- with index $services $i }}{{ .Address }},{{ end -}} + {{- end -}} + {{- with index . $last }}{{ .Address }}{{ end -}} + {{- end }} prometheus: enable: true