diff --git a/templates/named.conf.functions.j2 b/templates/named.conf.functions.j2 index 0ba8399..06cc86a 100644 --- a/templates/named.conf.functions.j2 +++ b/templates/named.conf.functions.j2 @@ -110,4 +110,36 @@ {% else %} {{ name }} "{{ value }}"; {% endif %} +{% endmacro %} + +{% macro list_address_port_tls(dict, indent=bind9_config_indent) %} +{# This macro is for use for statements with grammar like #} +{# address port 00 tls str; address port 00 tls str; #} +{# it is usually called by a parent macro #} +{% filter indent(indent, true) %} +{% for item in dict %} +{% if item is not mapping %} +{{ item }}; +{% else %} +{{ item.address }} +{{- (' port ' + item.port | string) if item.port is defined and item.port -}} +{{- (' tls ' + item.tls | string) if item.tls is defined and item.tls -}}; +{% endif %} +{% endfor %} +{% endfilter %} +{% endmacro %} + +{% macro parent_address_port_tls(name, dict) %} +{# This macro is for use for statements with grammar like #} +{# statement port 00 tls str { address port 00 tls str; address port 00 tls str; } #} +{# the list inside the statement is handled by list_address_port_tls #} +{% if dict is not mapping and dict is iterable %} +{{ name }} { +{{ list_address_port_tls(dict) }}}; +{% else %} +{{ name }} +{{- (' port ' + dict.port | string) if dict.port is defined and dict.port -}} +{{- (' tls ' + dict.tls | string) if dict.tls is defined and dict.tls }} { +{{ list_address_port_tls(dict.addresses) }}}; +{% endif %} {% endmacro %} \ No newline at end of file