--- - name: Template LDAP lookup tables template: src: ldap_table.cf.j2 dest: /etc/postfix/{{ domain }}_ldap_{{ item }}.cf" when: - postfix_domain_config[domain][item+'_lookup'].provider|default(postfix_lookup_provider) == 'ldap' loop: - user - alias - group notify: reload postfix - name: Template SQLite lookup tables template: src: sqlite_table.cf.j2 dest: /etc/postfix/{{ domain }}_sqlite_{{ item }}.cf when: - postfix_domain_config[domain][item+'_lookup'].provider|default(postfix_lookup_provider) == 'sqlite' loop: - user - alias notify: reload postfix - name: Template file user lookup table blockinfile: block: | {% for item in postfix_domain_config[domain]['users']|default([]) -%} {% if item is string %}{{ item }} /nomailbox/{{ item }} {% else %}{{ item.user }} {{ item.mailbox }} {% endif %}{% endfor %} dest: "{{ postfix_domain_config[domain].user_lookup.file|default(vmail_home+'/'+domain+'_users') }}" marker: "# {mark} ANSIBLE-MANAGED USERS" create: yes when: - postfix_domain_config[domain].user_lookup.provider|default(postfix_lookup_provider) == 'file' notify: postmap hash users - name: Template file alias lookup table blockinfile: block: | {% for key in postfix_domain_config[domain]['aliases']|default([]) -%} {{ key.alias }} {{ key.dest }} {% endfor %} dest: "{{ postfix_domain_config[domain].user_lookup.file|default(vmail_home+'/'+domain+'_aliases') }}" marker: "# {mark} ANSIBLE-MANAGED ALIASES" create: yes when: - postfix_domain_config[domain].alias_lookup.provider|default(postfix_lookup_provider) == 'file' notify: postmap hash aliases - name: Template no-reply aliases file copy: content: | {% for address in postfix_domain_config[domain].noreply_aliases|default(['noreply']) %} {{ address }}@domain _dev_null {% endfor %} dest: "{{ postfix_domain_config[domain].noreply_file|default(vmail_home+'/'+domain+'_noreply') }}" notify: postmap no reply aliases