- name: 'Install postfix packages' apt: pkg: '{{ item }}' install_recommends: 'no' state: 'installed' with_items: - 'postfix' - 'ca-certificates' - 'procmail' - 'libsasl2-modules' when: with_postfix - name: 'Install mail aliases file' template: src: 'aliases.j2' dest: '/etc/aliases' owner: 'root' group: 'root' mode: '0644' notify: - 'Regenerate aliases cache' when: with_mail_aliases - name: 'Install postfix main configuration' template: src: 'postfix/main.cf.j2' dest: '/etc/postfix/main.cf' owner: 'root' group: 'root' mode: '0644' notify: - 'Reload postfix' when: with_postfix - name: 'Update postfix master config for slowsmtp transport' blockinfile: dest: '/etc/postfix/master.cf' marker: '# ======= {mark} slowsmtp transport (managed by ansible) ======' content: | slowsmtp unix - - n - 5 smtp -o smtp_destination_concurrency_limit=3 -o slowsmtp_destination_rate_delay=1 notify: - 'Reload postfix' when: with_postfix_slowsmtp - name: 'Install postfix slowsmtp transport map' template: src: 'postfix/transport_slowsmtp.j2' dest: '/etc/postfix/transport_slowsmtp' owner: 'root' group: 'root' mode: '0644' notify: - 'Rehash slowsmtp transport map' - 'Reload postfix' when: with_postfix_slowsmtp - name: 'Install postfix sasl credentials map' template: src: 'postfix/sasl_credentials.j2' dest: '/etc/postfix/sasl/credentials' owner: 'root' group: 'root' mode: '0600' notify: - 'Rehash sasl credentials map' - 'Reload postfix' when: with_postfix_external_smtp - name: 'Install postfix sasl sender rewrite map' template: src: 'postfix/sasl_sender_rewrite.j2' dest: '/etc/postfix/sasl/sender_rewrite' owner: 'root' group: 'root' mode: '0600' notify: - 'Reload postfix' when: with_postfix_external_smtp