diff options
author | Armaël Guéneau <armael.gueneau@ens-lyon.org> | 2024-11-20 13:04:41 +0100 |
---|---|---|
committer | Armaël Guéneau <armael.gueneau@ens-lyon.org> | 2024-11-20 13:04:41 +0100 |
commit | e0385b0456cbd5f64e5464d0b6a36171ba770ba6 (patch) | |
tree | e27ea8432dd89559f7a3bd16e62e2760f62bb292 /cluster/prod | |
parent | c66bff55f41bc132592c87b819756417201d3bf0 (diff) | |
download | nixcfg-postfix-rate-limit-exceptions.tar.gz nixcfg-postfix-rate-limit-exceptions.zip |
make the list of IPs sorted and without duplicates for robustnesspostfix-rate-limit-exceptions
Diffstat (limited to 'cluster/prod')
-rw-r--r-- | cluster/prod/app/email/deploy/email.hcl | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/cluster/prod/app/email/deploy/email.hcl b/cluster/prod/app/email/deploy/email.hcl index 7eea2ea..287cff3 100644 --- a/cluster/prod/app/email/deploy/email.hcl +++ b/cluster/prod/app/email/deploy/email.hcl @@ -383,15 +383,24 @@ job "email" { } template { + # Collect machine IPs from the cluster. + # We use intermediate maps to ensure we get a sorted list with no duplicates, + # so that it is robust wrt. changes in the order of the output of ls or + # addition of new machines in an existing site. + # (scratch.MapValues returns the list of *values* in the map, sorted by *key*) data = <<EOH {{- range ls "diplonat/autodiscovery/ipv4" }} - {{- with $a := .Value | parseJSON }} {{ $a.address }} + {{- with $a := .Value | parseJSON }} + {{- scratch.MapSet "ipv4" $a.address $a.address }} {{- end }} - {{- end }} + {{- end -}} {{- range ls "diplonat/autodiscovery/ipv6" }} - {{- with $a := .Value | parseJSON }} [{{ $a.address }}] + {{- with $a := .Value | parseJSON }} + {{- scratch.MapSet "ipv6" $a.address $a.address }} {{- end }} - {{- end }} + {{- end -}} + {{- range scratch.MapValues "ipv4" }}{{ . }} {{ end }} + {{- range scratch.MapValues "ipv6" }}[{{ . }}] {{ end }} EOH destination = "secrets/postfix/rate-limit-exceptions" } |