smtp.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. - name: 'Install postfix packages'
  2. apt:
  3. pkg: '{{ item }}'
  4. install_recommends: 'no'
  5. state: 'installed'
  6. update_cache: 'yes'
  7. with_items:
  8. - 'postfix'
  9. - 'ca-certificates'
  10. - 'procmail'
  11. when: with_postfix
  12. - name: 'Install mail aliases file'
  13. template:
  14. src: 'aliases.j2'
  15. dest: '/etc/aliases'
  16. owner: 'root'
  17. group: 'root'
  18. mode: '0644'
  19. notify:
  20. - 'Regenerate aliases cache'
  21. when: with_postfix or with_mail_aliases
  22. - name: 'Install postfix main configuration'
  23. template:
  24. src: 'postfix/main.cf.j2'
  25. dest: '/etc/postfix/main.cf'
  26. owner: 'root'
  27. group: 'root'
  28. mode: '0644'
  29. notify:
  30. - 'Restart postfix'
  31. when: with_postfix
  32. - name: 'Update postfix master config for slowsmtp transport'
  33. blockinfile:
  34. dest: '/etc/postfix/master.cf'
  35. marker: '# ======= {mark} slowsmtp transport (managed by ansible) ======'
  36. content: |
  37. slowsmtp unix - - n - 5 smtp
  38. -o smtp_destination_concurrency_limit=3
  39. -o slowsmtp_destination_rate_delay=1
  40. notify:
  41. - 'Restart postfix'
  42. when: with_postfix and with_postfix_slowsmtp
  43. - name: 'Install postfix slowsmtp transport map'
  44. template:
  45. src: 'postfix/transport_slowsmtp.j2'
  46. dest: '/etc/postfix/transport_slowsmtp'
  47. owner: 'root'
  48. group: 'root'
  49. mode: '0644'
  50. notify:
  51. - 'Rehash slowsmtp transport map'
  52. - 'Restart postfix'
  53. when: with_postfix and with_postfix_slowsmtp