smtp.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. -o syslog_name=${multi_instance_name:postfix}${multi_instance_name?$multi_instance_name}/slow
  41. notify:
  42. - 'Restart postfix'
  43. when: with_postfix and with_postfix_slowsmtp
  44. - name: 'Install postfix slowsmtp transport map'
  45. template:
  46. src: 'postfix/transport_slowsmtp.j2'
  47. dest: '/etc/postfix/transport_slowsmtp'
  48. owner: 'root'
  49. group: 'root'
  50. mode: '0644'
  51. notify:
  52. - 'Rehash slowsmtp transport map'
  53. - 'Restart postfix'
  54. when: with_postfix and with_postfix_slowsmtp