No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

postfix.yml 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. - name: Install Postfix 9.1 and related packages for distributions other than Ubuntu Trusty
  2. apt: pkg={{ item }} state=installed
  3. with_items:
  4. - libsasl2-modules
  5. - postfix
  6. - postfix-pcre
  7. - postfix-pgsql
  8. - postgresql-9.1
  9. - postgrey
  10. - python-psycopg2
  11. - sasl2-bin
  12. when: ansible_distribution_release != 'trusty'
  13. - name: Install Postfix 9.3 and related packages for Ubuntu Trusty
  14. apt: pkg={{ item }} state=installed
  15. with_items:
  16. - libsasl2-modules
  17. - postfix
  18. - postfix-pcre
  19. - postfix-pgsql
  20. - postgresql-9.3
  21. - postgrey
  22. - python-psycopg2
  23. - sasl2-bin
  24. when: ansible_distribution_release == 'trusty'
  25. - name: Set postgres password
  26. command: sudo -u {{ db_admin_username }} psql -d {{ db_admin_username }} -c "ALTER USER postgres with password '{{ db_admin_password }}';"
  27. notify: import sql postfix
  28. - name: Create database user for mail server
  29. 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
  30. notify: import sql postfix
  31. - name: Create database for mail server
  32. 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 }}
  33. notify: import sql postfix
  34. - name: Copy import.sql
  35. template: src=mailserver.sql.j2 dest=/etc/postfix/import.sql owner=root group=root mode=0600
  36. notify: import sql postfix
  37. - name: Create postfix maps directory
  38. file: path=/etc/postfix/maps state=directory owner=root group=root
  39. when: mail_header_privacy == 1
  40. - name: Copy smtp_header_checks.pcre
  41. copy: src=etc_postfix_maps_smtp_header_checks.pcre dest=/etc/postfix/maps/smtp_header_checks.pcre owner=root group=root
  42. when: mail_header_privacy == 1
  43. - name: Copy main.cf
  44. template: src=etc_postfix_main.cf.j2 dest=/etc/postfix/main.cf owner=root group=root
  45. notify: restart postfix
  46. - name: Copy master.cf
  47. copy: src=etc_postfix_master.cf dest=/etc/postfix/master.cf owner=root group=root
  48. notify: restart postfix
  49. - name: Copy additional postfix configuration files
  50. template: src=etc_postfix_{{ item }}.j2 dest=/etc/postfix/{{ item }} owner=root group=root
  51. with_items:
  52. - pgsql-virtual-alias-maps.cf
  53. - pgsql-virtual-mailbox-domains.cf
  54. - pgsql-virtual-mailbox-maps.cf
  55. notify: restart postfix
  56. - name: Set firewall rules for postfix
  57. ufw: rule=allow port={{ item }} proto=tcp
  58. with_items:
  59. - smtp
  60. - ssmtp