- name: install postfix apt: pkg: - postfix - name: Install and setup utilities for LDAP when: postfix.ldap.enable block: - name: install utility packages for LDAP auth & config apt: pkg: - postfix-ldap - sasl2-bin - name: Configure saslauthd template: src: saslauthd.conf.j2 dest: /etc/saslauthd.conf notify: - restart saslauthd - name: Copy saslauthd defaults copy: src: saslauthd-defaults dest: /etc/default/saslauthd notify: - restart saslauthd - name: Copy smtpd.conf copy: src: smtpd.conf dest: /etc/postfix/sasl/smtpd.conf notify: - restart postfix - name: Add postfix to sasl group user: name: postfix append: yes groups: sasl notify: - restart postfix - name: remove exim4 package apt: name: exim4 state: absent # We need to configure postfix's virtual UID and GID map. Those are set to the vmail users UID and GID as vmail holds all mail # Used in templates/main.cf.j2 - name: "get vmail user data" user: name: vmail register: vmail_user - name: copy postfix config template: src: "{{ item.src }}" dest: "{{ item.dest }}" with_items: - { src: "main.cf.j2", dest: "/etc/postfix/main.cf" } - { src: "master.cf.j2", dest: "/etc/postfix/master.cf" } - { src: "virtual-aliases.cf.j2", dest: "/etc/postfix/virtual-aliases.cf" } - { src: "virtual-mailboxes.cf.j2", dest: "/etc/postfix/virtual-mailboxes.cf" } notify: - restart postfix - name: copy postfix maps template: src: maps.j2 dest: "{{ item }}" with_items: "{{ postfixmaps }}" notify: - restart postfix