From c8b4455cba7eac6d3879059d6fb5bf820db4cc00 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 29 Sep 2025 18:00:28 +0200 Subject: [PATCH] Update to 2025-09-29 18:00 --- roles/consul/defaults/main.yml | 5 +++++ roles/consul/templates/consul.hcl.j2 | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/roles/consul/defaults/main.yml b/roles/consul/defaults/main.yml index afd98a4..a209192 100644 --- a/roles/consul/defaults/main.yml +++ b/roles/consul/defaults/main.yml @@ -36,6 +36,11 @@ consul_base_conf: # An optional alternative domain # alt_domain: consul.example.org. + # dns_config: + # service_ttl: + # '*': 5s + # node_ttl: 5s + # Address that is advertised to the other nodes advertise_addr: "{{ ansible_default_ipv4.address }}" # You can also advertise the WAN addr diff --git a/roles/consul/templates/consul.hcl.j2 b/roles/consul/templates/consul.hcl.j2 index 3fd3db7..2c568e5 100644 --- a/roles/consul/templates/consul.hcl.j2 +++ b/roles/consul/templates/consul.hcl.j2 @@ -89,6 +89,33 @@ recursors = [ {% endfor %} ] +{% if consul_conf.dns_config is defined %} +dns_config { +{% if consul_conf.dns_config.service_ttl is defined %} + service_ttl { +{% for service in consul_conf.dns_config.service_ttl.keys() | list %} + "{{ service }}" = "{{ consul_conf.dns_config.service_ttl[service] }}" +{% endfor %} + } +{% endif %} +{% for key in ["allow_stale", "enable_truncate", "only_passing", "enable_additional_node_meta_txt", "use_cache"] %} +{% if consul_conf.dns_config[key] is defined %} + {{ key }} = {{ (consul_conf.dns_config[key]) | ternary('true', 'false') }} +{% endif %} +{% endfor %} +{% for key in ["a_record_limit"] %} +{% if consul_conf.dns_config[key] is defined %} + {{ key }} = {{ (consul_conf.dns_config[key]) }} +{% endif %} +{% endfor %} +{% for key in ["node_ttl", "max_stale", "recursor_strategy", "recursor_timeout", "cache_max_age"] %} +{% if consul_conf.dns_config[key] is defined %} + {{ key }} = "{{ consul_conf.dns_config[key] }}" +{% endif %} +{% endfor %} +} +{% endif %} + {% if consul_conf.domain is defined %} domain = "{{ consul_conf.domain }}" {% endif %}