make the list of IPs sorted and without duplicates for robustness
This commit is contained in:
parent
c66bff55f4
commit
e0385b0456
1 changed files with 13 additions and 4 deletions
|
@ -383,15 +383,24 @@ job "email" {
|
||||||
}
|
}
|
||||||
|
|
||||||
template {
|
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
|
data = <<EOH
|
||||||
{{- range ls "diplonat/autodiscovery/ipv4" }}
|
{{- 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 }}
|
{{- end -}}
|
||||||
{{- range ls "diplonat/autodiscovery/ipv6" }}
|
{{- 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 }}
|
{{- end -}}
|
||||||
|
{{- range scratch.MapValues "ipv4" }}{{ . }} {{ end }}
|
||||||
|
{{- range scratch.MapValues "ipv6" }}[{{ . }}] {{ end }}
|
||||||
EOH
|
EOH
|
||||||
destination = "secrets/postfix/rate-limit-exceptions"
|
destination = "secrets/postfix/rate-limit-exceptions"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue