diff --git a/postfix/files/dynamicmaps.cf b/postfix/files/dynamicmaps.cf deleted file mode 100644 index b411db047df77be43e32e56b7a23cf55be018d47..0000000000000000000000000000000000000000 --- a/postfix/files/dynamicmaps.cf +++ /dev/null @@ -1,2 +0,0 @@ -sqlite postfix-sqlite.so dict_sqlite_open -pcre postfix-pcre.so dict_pcre_open diff --git a/postfix/handlers/main.yml b/postfix/handlers/main.yml index 4fa497884b0572bef60c21afc24e8c7352848d6d..e2fa640b4e628462e2a419e1d6b56bec466221b4 100644 --- a/postfix/handlers/main.yml +++ b/postfix/handlers/main.yml @@ -3,3 +3,9 @@ - name: restart postfix service: name=postfix state=restarted +- name: postmap system + command: postalias cdb:/etc/aliases + +- name: postmap virtual + command: postmap cdb:/etc/postfix/virtual + diff --git a/postfix/tasks/main.yml b/postfix/tasks/main.yml index c884334d14ad88ad1a5ddd10ee304a39aec0080a..fad51faae41af8e3fc035d6b98e7f8673ac30be2 100644 --- a/postfix/tasks/main.yml +++ b/postfix/tasks/main.yml @@ -5,6 +5,7 @@ with_items: - postfix - postfix-pcre + - postfix-cdb tags: - postfix - mail @@ -12,7 +13,6 @@ - name: ensure not templated config is present copy: src=files/{{ item }} dest=/etc/postfix/ with_items: - - dynamicmaps.cf - login_maps.pcre - master.cf - sender_login_map.hash @@ -32,6 +32,22 @@ tags: - postfix - mail + +- name: ensure system alias database is present + template: src=templates/aliases.j2 dest=/etc/aliases + notify: + - postmap system + tags: + - postfix + - mail + +- name: ensure virtual alias database is present + template: src=templates/v_aliases.j2 dest=/etc/postfix/virtual + notify: + - postmap virtual + tags: + - postfix + - mail - meta: flush_handlers diff --git a/postfix/templates/aliases.j2 b/postfix/templates/aliases.j2 new file mode 100644 index 0000000000000000000000000000000000000000..71ae0df53b516d4886074421bf76aafea6aea345 --- /dev/null +++ b/postfix/templates/aliases.j2 @@ -0,0 +1,4 @@ +{% for alias in system_aliases %} +{{ alias.src }}:{{ alias.dest }} +{% endfor %} + diff --git a/postfix/templates/main.cf.j2 b/postfix/templates/main.cf.j2 index ad580a7c1a5e5a574a8e3becfc80e3fa7a9b1a21..961d30fc3d713b2b1eff708fc974b387210c5476 100644 --- a/postfix/templates/main.cf.j2 +++ b/postfix/templates/main.cf.j2 @@ -39,8 +39,8 @@ smtpd_relay_restrictions = permit_sasl_authenticated defer_unauth_destination myhostname = {{ ansible_fqdn }} -alias_maps = hash:/etc/aliases -alias_database = hash:/etc/aliases +alias_maps = cdb:/etc/aliases +alias_database = cdb:/etc/aliases myorigin = /etc/mailname mydestination = $myhostname, localhost relayhost = @@ -50,16 +50,13 @@ recipient_delimiter = + inet_interfaces = all inet_protocols = all -virtual_mailbox_domains = $mydestination, wolfscloud.de +virtual_mailbox_domains = $mydestination, {{ virtual_domains | join(" ") }} virtual_mailbox_base = /var/vmail/ virtual_mailbox_limit = 512000000 virtual_minimum_uid = 5000 virtual_transport = lmtp:unix:private/dovecot-lmtp -#virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 -#local_transport = virtual -virtual_alias_maps = hash:/etc/postfix/virtual -#smtpd_sender_login_maps = hash:/etc/postfix/sender_login_map +virtual_alias_maps = cdb:/etc/postfix/virtual smtpd_sender_login_maps = proxy:pcre:/etc/postfix/login_maps.pcre ################################################################################ diff --git a/postfix/templates/v_aliases.j2 b/postfix/templates/v_aliases.j2 new file mode 100644 index 0000000000000000000000000000000000000000..c24df94c5b8622e0f53b9c1cbc301aaac51ec50e --- /dev/null +++ b/postfix/templates/v_aliases.j2 @@ -0,0 +1,10 @@ +{% for domain in virtual_domains %} +postmaster@{{ domain }} {{ adminaddr }} +hostmaster@{{ domain }} {{ adminaddr }} +abuse@{{ domain }} {{ adminaddr }} +{% endfor %} + +{% for alias in virtual_aliases %} +{{ alias.src }} {{ alias.dest }} +{% endfor %} +