- name: Install Postfix and related packages apt: pkg=$item state=installed with_items: - postfix - mysql-server - postfix-mysql - python-mysqldb - libsasl2-modules - sasl2-bin - postgrey - name: Create database user for mail server mysql_user: user={{ mail_mysql_username }} password={{ mail_mysql_password }} state=present priv="mailserver.*:ALL" - name: Create database for mail server mysql_db: name={{ mail_mysql_database }} state=present - name: copy over mailserver sql template: src=mailserver.sql.j2 dest=/etc/postfix/import.sql owner=root group=root mode=0600 tags: import_mysql_postfix - name: import mysql postfix mysql_db: name={{ mail_mysql_database }} state=import target=/etc/postfix/import.sql tags: import_mysql_postfix - name: Copy Postfix config files into place template: src=etc_postfix_main.cf.j2 dest=/etc/postfix/main.cf owner=root group=root notify: restart postfix - name: Copy master.cf copy: src=etc_postfix_master.cf dest=/etc/postfix/master.cf owner=root group=root notify: restart postfix - name: Copy additional postfix configuration files template: src=etc_postfix_${item}.j2 dest=/etc/postfix/${item} owner=root group=root with_items: - mysql-virtual-mailbox-domains.cf - mysql-virtual-mailbox-maps.cf - mysql-virtual-alias-maps.cf notify: restart postfix