๐Ÿ“— 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/dovecot/templates/dovecot.j2

94 lines
2.6 KiB

{% macro dovecot_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 | type_debug == 'list' -%}
{{ option.key }} = {{ option.value | join(' ') }}
{% elif option.value is mapping -%}
{{ option.key }} {
{% for suboption in (option.value | d({}) | dict2items) -%}
{{- dovecot_option(suboption, padding + 1) }}
{% endfor -%}
}
{% else -%}
{{ option.key }} = {{ option.value if option.value != None else '' }}
{% endif -%}
{% endmacro -%}
{% for option in (dovecot_cfg | d({}) | dict2items) -%}
{{ dovecot_option(option) }}
{%- endfor %}
first_valid_uid = {{ dovecot_dovemail_uid }}
last_valid_uid = {{ dovecot_dovemail_uid }}
{% for proto in (dovecot_protocols | d({}) | dict2items) -%}
protocol {{ proto.key }} {
{% for option in (proto.value | d({}) | dict2items) -%}
{{ dovecot_option(option, 1) }}
{%- endfor -%}
}
{% endfor %}
{% for namespace in (dovecot_namespaces | d([])) -%}
namespace {{ namespace.name }} {
{% for option in (namespace.opts | d({}) | dict2items) -%}
{{ dovecot_option(option, 1) }}
{%- endfor -%}
{% for mailbox in (namespace.mailboxes | d([])) -%}
{{- ' ' -}}mailbox {{ mailbox.name }} {
{% for mailbox_option in (mailbox.opts | d({}) | dict2items) -%}
{{ dovecot_option(mailbox_option, 2) }}
{%- endfor -%}
{{- ' ' -}}}
{% endfor -%}
}
{% endfor %}
{% if dovecot_dicts is mapping -%}
dict {
{% for option in (dovecot_dicts | d({}) | dict2items) -%}
{{ dovecot_option(option, 1) }}
{%- endfor -%}
}
{% endif %}
{% if dovecot_plugin_config is mapping -%}
plugin {
{% for option in (dovecot_plugin_config | d({}) | dict2items) -%}
{{ dovecot_option(option, 1) }}
{%- endfor -%}
}
{% endif %}
{% for db in (dovecot_user_pass_db | d([])) -%}
{{ db.type }} {
{% for option in (db.opts | d({}) | dict2items) -%}
{{ dovecot_option(option, 1) }}
{%- endfor -%}
}
{% endfor %}
{% for service in (dovecot_services | d({}) | dict2items) -%}
service {{ service.key }} {
{% for option in (service.value.opts | d({}) | dict2items) -%}
{{ dovecot_option(option, 1) }}
{%- endfor %}
{% for listener in (service.value.listeners | d([])) -%}
{{- ' ' -}}{{ listener.type }} {{ listener.name | d('') }} {
{% for listener_option in (listener.opts | d({}) | dict2items) -%}
{{ dovecot_option(listener_option, 2) }}
{%- endfor -%}
{{- ' ' -}}}
{% endfor -%}
}
{% endfor %}