smtp.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. - name: 'Install postfix packages'
  2. apt:
  3. pkg: '{{ item }}'
  4. install_recommends: 'no'
  5. state: 'installed'
  6. with_items:
  7. - 'postfix'
  8. - 'ca-certificates'
  9. - 'procmail'
  10. - 'libsasl2-modules'
  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_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. - 'Reload 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. - 'Reload postfix'
  42. when: 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. - 'Reload postfix'
  53. when: with_postfix_slowsmtp
  54. - name: 'Install postfix sasl credentials map'
  55. template:
  56. src: 'postfix/sasl_credentials.j2'
  57. dest: '/etc/postfix/sasl/credentials'
  58. owner: 'root'
  59. group: 'root'
  60. mode: '0600'
  61. notify:
  62. - 'Rehash sasl credentials map'
  63. - 'Reload postfix'
  64. when: with_postfix_external_smtp
  65. - name: 'Install postfix sasl sender rewrite map'
  66. template:
  67. src: 'postfix/sasl_sender_rewrite.j2'
  68. dest: '/etc/postfix/sasl/sender_rewrite'
  69. owner: 'root'
  70. group: 'root'
  71. mode: '0600'
  72. notify:
  73. - 'Reload postfix'
  74. when: with_postfix_external_smtp