Bez popisu
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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ---
  2. # Installs and configures the Postfix SMTP server.
  3. - name: Install Postfix and related packages
  4. apt:
  5. name: "{{ packages }}"
  6. state: present
  7. vars:
  8. packages:
  9. - libsasl2-modules
  10. - postfix
  11. - postfix-pcre
  12. - postfix-pgsql
  13. - postgrey
  14. - sasl2-bin
  15. tags:
  16. - dependencies
  17. - name: Create database user for mail server
  18. postgresql_user:
  19. login_host=localhost
  20. login_user={{ db_admin_username }}
  21. login_password="{{ db_admin_password }}"
  22. name={{ mail_db_username }}
  23. password="{{ mail_db_password }}"
  24. encrypted=yes
  25. state=present
  26. notify: import sql postfix
  27. - name: Create database for mail server
  28. postgresql_db:
  29. login_host=localhost
  30. login_user={{ db_admin_username }}
  31. login_password="{{ db_admin_password }}"
  32. name={{ mail_db_database }}
  33. state=present
  34. owner={{ mail_db_username }}
  35. notify: import sql postfix
  36. - name: Copy import.sql
  37. template:
  38. src=mailserver.sql.j2
  39. dest=/etc/postfix/import.sql
  40. owner=root
  41. group=root
  42. mode=0600
  43. notify: import sql postfix
  44. - name: Create postfix maps directory
  45. file:
  46. path=/etc/postfix/maps
  47. state=directory
  48. owner=root
  49. group=root
  50. when: mail_header_privacy == 1
  51. - name: Copy smtp_header_checks.pcre
  52. copy:
  53. src=etc_postfix_maps_smtp_header_checks.pcre
  54. dest=/etc/postfix/maps/smtp_header_checks.pcre
  55. owner=root
  56. group=root
  57. when: mail_header_privacy == 1
  58. - name: Copy main.cf
  59. template:
  60. src=etc_postfix_main.cf.j2
  61. dest=/etc/postfix/main.cf
  62. owner=root
  63. group=root
  64. notify: restart postfix
  65. - name: Copy master.cf
  66. copy:
  67. src=etc_postfix_master.cf
  68. dest=/etc/postfix/master.cf
  69. owner=root
  70. group=root
  71. notify: restart postfix
  72. - name: Copy additional postfix configuration files
  73. template:
  74. src=etc_postfix_{{ item }}.j2
  75. dest=/etc/postfix/{{ item }}
  76. owner=root
  77. group=root
  78. with_items:
  79. - pgsql-virtual-alias-maps.cf
  80. - pgsql-virtual-mailbox-domains.cf
  81. - pgsql-virtual-mailbox-maps.cf
  82. - pgsql-recipient-access.cf
  83. - pgsql-sender-login-maps.cf
  84. notify: restart postfix
  85. - name: Set firewall rules for postfix
  86. ufw: rule=allow port={{ item }} proto=tcp
  87. with_items:
  88. - smtp
  89. - ssmtp
  90. - submission
  91. tags: ufw