Brak opisu
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.6KB

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