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.

dovecot.yml 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. ---
  2. # Installs and configures the Dovecot IMAP/POP3 server.
  3. - name: Install Dovecot and related packages
  4. apt:
  5. name: "{{ packages }}"
  6. state: present
  7. vars:
  8. packages:
  9. - dovecot-core
  10. - dovecot-imapd
  11. - dovecot-lmtpd
  12. - dovecot-managesieved
  13. - dovecot-pgsql
  14. - dovecot-pop3d
  15. - dovecot-antispam
  16. tags:
  17. - dependencies
  18. - name: Create vmail group
  19. group:
  20. name=vmail
  21. state=present
  22. gid=5000
  23. - name: Create vmail user
  24. user:
  25. name=vmail
  26. group=vmail
  27. state=present
  28. uid=5000
  29. home=/data
  30. shell=/usr/sbin/nologin
  31. - name: Ensure mail domain directories are in place
  32. file:
  33. state=directory
  34. path=/data/{{ item.name }}
  35. owner=vmail
  36. group=dovecot
  37. mode=0770
  38. with_items: '{{ virtual_domains }}'
  39. - name: Ensure mail directories are in place
  40. file:
  41. state=directory
  42. path=/data/{{ item.domain }}/{{ item.account }}
  43. owner=vmail
  44. group=dovecot
  45. with_items: '{{ mail_virtual_users }}'
  46. - name: Copy dovecot.conf into place
  47. copy:
  48. src=etc_dovecot_dovecot.conf
  49. dest=/etc/dovecot/dovecot.conf
  50. - name: Create before.d sieve scripts directory
  51. file:
  52. path=/etc/dovecot/sieve/before.d
  53. state=directory
  54. owner=vmail
  55. group=dovecot
  56. recurse=yes
  57. mode=0770
  58. notify: restart dovecot
  59. - name: Configure sieve script moving spam into Junk folder
  60. copy:
  61. src=etc_dovecot_sieve_before.d_no-spam.sieve
  62. dest=/etc/dovecot/sieve/before.d/no-spam.sieve
  63. owner=vmail
  64. group=dovecot
  65. notify: restart dovecot
  66. - name: Copy additional Dovecot configuration files in place
  67. copy:
  68. src=etc_dovecot_conf.d_{{ item }}
  69. dest=/etc/dovecot/conf.d/{{ item }}
  70. with_items:
  71. - 10-auth.conf
  72. - 10-mail.conf
  73. - 10-master.conf
  74. - 90-antispam.conf
  75. - 90-plugin.conf
  76. - 90-sieve.conf
  77. - auth-sql.conf.ext
  78. notify: restart dovecot
  79. - name: Template additional Dovecot configuration files
  80. template:
  81. src=etc_dovecot_conf.d_{{ item }}.j2
  82. dest=/etc/dovecot/conf.d/{{ item }}
  83. with_items:
  84. - 10-ssl.conf
  85. - 15-lda.conf
  86. - 20-imap.conf
  87. notify: restart dovecot
  88. - name: Template dovecot-sql.conf.ext
  89. template:
  90. src=etc_dovecot_dovecot-sql.conf.ext.j2
  91. dest=/etc/dovecot/dovecot-sql.conf.ext
  92. notify: restart dovecot
  93. - name: Ensure correct permissions on Dovecot config directory
  94. file:
  95. state=directory
  96. path=/etc/dovecot
  97. group=dovecot
  98. owner=vmail
  99. mode=0770
  100. recurse=yes
  101. notify: restart dovecot
  102. - name: Set firewall rules for dovecot
  103. ufw: rule=allow port={{ item }} proto=tcp
  104. with_items:
  105. - imaps
  106. - pop3s
  107. tags: ufw
  108. - name: Update post-certificate-renewal task
  109. copy:
  110. content: "#!/bin/bash\n\nservice dovecot restart\n"
  111. dest: /etc/letsencrypt/postrenew/dovecot.sh
  112. mode: 0755
  113. owner: root
  114. group: root