Hi everyone,
I am trying to create consul-template which spawns consul-template process, I am doing that because I have 100+ dns zone files, and I want to use 1 DNS zone template and dynamically create destination zone files with it.
consul {
address = "127.0.0.1:8500"
retry {
enabled = true
attempts = 12
backoff = "250ms"
}
}
{{ define "zone_template" }}
@ SOA ns1 hostmaster (
5001 ; serial
7200 ; refresh
1800 ; retry
604800 ; expire
900 ; ncache
)
@ NS ns1
@ NS ns2
@ 7200 MX 10 mail
MX 10 mail
bla CNAME www
{{ $content_endpoint := ("/zones/[domain_name]" | replaceAll "[domain_name]" .) }}
{{with $domain_zones := key $content_endpoint | parseJSON}}
{{range $domain_zones}}
{{ .domain_prefix }} {{ .record_type }} {{ .address }}
{{end}}
{{end}}
{{ end }}
{{ with $main_domains := key "/main_domains" | parseJSON }}
{{ range $main_domains }}
{{ $destination_path := ("/config_service_orchestrator/template_tests//zones/[domain_name]" | replaceAll "[domain_name]" .domain_name) }}
{{ $content_endpoint := ("/zones/[domain_name]" | replaceAll "[domain_name]" .domain_name) }}
{{ $domain_name := .domain_name }}
template {
destination = "{{ $destination_path }}"
contents = "{{ executeTemplate "zone_template" $domain_name }}"
perms = 0600
command = "./consul-template -config \"{{ $destination_path }}\""
}
{{ end }}
{{ end }}
I have template file and I am processing this template file from another template, at the end I successfully filled the template file, but I cannot trigger command line, is there any way or suggestion to passing value into template files ? Its kinda useless if cannot create multiple output file from single template file.