- 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 - copy: src=etc_postfix_master.cf dest=/etc/postfix/master.cf owner=root group=root - template: src=etc_postfix_mysql-virtual-mailbox-domains.cf.j2 dest=/etc/postfix/mysql-virtual-mailbox-domains.cf owner=root group=root - template: src=etc_postfix_mysql-virtual-mailbox-maps.cf.j2 dest=/etc/postfix/mysql-virtual-mailbox-maps.cf owner=root group=root - template: src=etc_postfix_mysql-virtual-alias-maps.cf.j2 dest=/etc/postfix/mysql-virtual-alias-maps.cf owner=root group=root notify: restart postfix