1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- - name: Install Postfix 9.1 and related packages
- apt: pkg={{ item }} state=installed
- with_items:
- - postfix
- - libsasl2-modules
- - sasl2-bin
- - postgrey
- - postgresql-9.1
- - postfix-pgsql
- - python-psycopg2
- - postfix-pcre
- when: ansible_distribution_release != 'trusty'
-
- - name: Install Postfix 9.3 and related packages for Ubuntu Trusty
- apt: pkg={{ item }} state=installed
- with_items:
- - postfix
- - libsasl2-modules
- - sasl2-bin
- - postgrey
- - postgresql-9.3
- - postfix-pgsql
- - python-psycopg2
- - postfix-pcre
- when: ansible_distribution_release == 'trusty'
-
- - name: Set postgres password
- command: sudo -u {{ db_admin_username }} psql -d {{ db_admin_username }} -c "ALTER USER postgres with password '{{ db_admin_password }}';"
- notify: import sql postfix
-
- - name: Create database user for mail server
- postgresql_user: login_host=localhost login_user={{ db_admin_username }} login_password="{{ db_admin_password }}" name={{ mail_db_username }} password="{{ mail_db_password }}" state=present
- notify: import sql postfix
-
- - name: Create database for mail server
- postgresql_db: login_host=localhost login_user={{ db_admin_username }} login_password="{{ db_admin_password }}" name={{ mail_db_database }} state=present owner={{ mail_db_username }}
- notify: import sql postfix
-
- - name: Copy import.sql
- template: src=mailserver.sql.j2 dest=/etc/postfix/import.sql owner=root group=root mode=0600
- notify: import sql postfix
-
- - name: Create postfix maps directory
- file: path=/etc/postfix/maps state=directory owner=root group=root
- when: mail_header_privacy == 1
-
- - name: Copy smtp_header_checks.pcre
- copy: src=etc_postfix_maps_smtp_header_checks.pcre dest=/etc/postfix/maps/smtp_header_checks.pcre owner=root group=root
- when: mail_header_privacy == 1
-
- - name: Copy main.cf
- 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:
- - pgsql-virtual-mailbox-domains.cf
- - pgsql-virtual-mailbox-maps.cf
- - pgsql-virtual-alias-maps.cf
- notify: restart postfix
-
- - name: Set firewall rules for postfix
- ufw: rule=allow port={{ item }} proto=tcp
- with_items:
- - smtp
- - ssmtp
|