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

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