๐Ÿ“— Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ansible-playbooks/roles/unbound/templates/unbound.j2

30 lines
1.1 KiB

{%- macro unbound_option(option, padding = 0) -%}
{{- '' if (padding == 0) else (' ' * 4 * padding) -}}
{% if option.value is boolean -%}
{{ option.key }}: {{ 'yes' if option.value else 'no' }}
{% elif option.value is string and ((option.value == '') or (option.key in unbound_string_parameters)) -%}
{{ option.key }}: "{{ option.value }}"
{% elif option.value | type_debug == 'list' -%}
{%- for suboption in option.value -%}
{%- if loop.first -%}
{{- unbound_option({ 'key': option.key, 'value': suboption}, 0) -}}
{%- else -%}
{{- unbound_option({ 'key': option.key, 'value': suboption}, padding) -}}
{%- endif -%}
{% endfor -%}
{% elif option.value is mapping -%}
{{ option.key }}:
{% for suboption in (option.value | dict2items) -%}
{{ unbound_option(suboption, padding + 1) -}}
{% endfor -%}
{% elif option.value != None -%}
{{ option.key }}: {{ option.value }}
{% endif -%}
{%- endmacro -%}
{% for option in (unbound_cfg | d({}) | dict2items) -%}
{{ unbound_option(option) -}}
{%- endfor -%}