๐Ÿ“— 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.
 
 

55 lines
1.9 KiB

{% macro rspamd_array_option(value, padding = 0) -%}
{%- if value is boolean -%}
{{- 'true' if value else 'false' -}}
{%- elif (value is string) and not (value | regex_search('^\d')) -%}
"{{- value -}}"
{%- elif value is mapping -%}
{
{% for suboption in (value | d({}) | dict2items) -%}
{{ rspamd_option(suboption, padding + 1) }}
{% endfor -%}
}
{%- elif value | type_debug == 'list' -%}
[
{% for suboption in (value | d([])) -%}
{{- ' ' * 4 * (padding + 1) -}}
{{- rspamd_array_option(suboption, padding + 1) -}}{%- if not loop.last -%}{{ ', ' }}{%- else -%}{{ "\n" }}{%- endif -%}
{% endfor -%}
]
{%- else -%}
{{- value if value != None else '' -}}
{%- endif -%}
{%- endmacro -%}
{% macro rspamd_option(option, padding = 0) -%}
{{- '' if (padding == 0) else (' ' * 4 * padding) -}}
{% if option.value is boolean -%}
{{ option.key }} = {{ 'true' if option.value else 'false' }};
{% elif (option.value is string) and not (option.value | regex_search('^\d')) -%}
{{ option.key }} = "{{ option.value }}";
{% elif option.value is mapping -%}
{{ option.key if (option.key != '__tld__') else tld }} = {
{% for suboption in (option.value | d({}) | dict2items) -%}
{{ rspamd_option(suboption, padding + 1) }}
{%- endfor -%}
{{- '' if (padding == 0) else (' ' * 4 * padding) -}} };
{% elif option.value | type_debug == 'list' -%}
{{ option.key }} = [
{% for suboption in (option.value | d([])) -%}
{{- ' ' * 4 * (padding + 1) -}}
{{- rspamd_array_option(suboption, padding + 1) -}}{%- if not loop.last -%}{{ ', ' }}{%- else -%}{{ "\n" }}{%- endif -%}
{% endfor %}
];
{% else -%}
{{ option.key }} = {{ option.value if option.value != None else '' }};
{% endif -%}
{% endmacro -%}
{% for option in (rspamd_cfg[rspamd_config_item] | d({}) | dict2items) -%}
{{ rspamd_option(option) }}
{%- endfor %}