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.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. - name: Install Postgres
  2. apt: pkg=postgresql state=present
  3. tags:
  4. - dependencies
  5. - name: Install Postfix and related packages
  6. apt: pkg={{ item }} state=installed
  7. with_items:
  8. - libsasl2-modules
  9. - postfix
  10. - postfix-pcre
  11. - postfix-pgsql
  12. - postgrey
  13. - python-psycopg2
  14. - sasl2-bin
  15. tags:
  16. - dependencies
  17. - name: Set password for PostgreSQL admin user
  18. become: true
  19. become_user: postgres
  20. postgresql_user: name={{ db_admin_username }} password={{ db_admin_password }} encrypted=yes
  21. notify: import sql postfix
  22. - name: Create database user for mail server
  23. postgresql_user: login_host=localhost login_user={{ db_admin_username }} login_password="{{ db_admin_password }}" name={{ mail_db_username }} password="{{ mail_db_password }}" encrypted=yes state=present
  24. notify: import sql postfix
  25. - name: Create database for mail server
  26. 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 }}
  27. notify: import sql postfix
  28. - name: Copy import.sql
  29. template: src=mailserver.sql.j2 dest=/etc/postfix/import.sql owner=root group=root mode=0600
  30. notify: import sql postfix
  31. - name: Create postfix maps directory
  32. file: path=/etc/postfix/maps state=directory owner=root group=root
  33. when: mail_header_privacy == 1
  34. - name: Copy smtp_header_checks.pcre
  35. copy: src=etc_postfix_maps_smtp_header_checks.pcre dest=/etc/postfix/maps/smtp_header_checks.pcre owner=root group=root
  36. when: mail_header_privacy == 1
  37. - name: Copy main.cf
  38. template: src=etc_postfix_main.cf.j2 dest=/etc/postfix/main.cf owner=root group=root
  39. notify: restart postfix
  40. - name: Copy master.cf
  41. copy: src=etc_postfix_master.cf dest=/etc/postfix/master.cf owner=root group=root
  42. notify: restart postfix
  43. - name: Copy additional postfix configuration files
  44. template: src=etc_postfix_{{ item }}.j2 dest=/etc/postfix/{{ item }} owner=root group=root
  45. with_items:
  46. - pgsql-virtual-alias-maps.cf
  47. - pgsql-virtual-mailbox-domains.cf
  48. - pgsql-virtual-mailbox-maps.cf
  49. notify: restart postfix
  50. - name: Set firewall rules for postfix
  51. ufw: rule=allow port={{ item }} proto=tcp
  52. with_items:
  53. - smtp
  54. - ssmtp
  55. - submission
  56. tags: ufw