smtp.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. - 'libsasl2-modules'
  12. when: with_postfix
  13. - name: 'Install mail aliases file'
  14. template:
  15. src: 'aliases.j2'
  16. dest: '/etc/aliases'
  17. owner: 'root'
  18. group: 'root'
  19. mode: '0644'
  20. notify:
  21. - 'Regenerate aliases cache'
  22. when: with_postfix or with_mail_aliases
  23. - name: 'Install postfix main configuration'
  24. template:
  25. src: 'postfix/main.cf.j2'
  26. dest: '/etc/postfix/main.cf'
  27. owner: 'root'
  28. group: 'root'
  29. mode: '0644'
  30. notify:
  31. - 'Reload postfix'
  32. when: with_postfix
  33. - name: 'Update postfix master config for slowsmtp transport'
  34. blockinfile:
  35. dest: '/etc/postfix/master.cf'
  36. marker: '# ======= {mark} slowsmtp transport (managed by ansible) ======'
  37. content: |
  38. slowsmtp unix - - n - 5 smtp
  39. -o smtp_destination_concurrency_limit=3
  40. -o slowsmtp_destination_rate_delay=1
  41. notify:
  42. - 'Reload 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. - 'Reload postfix'
  54. when: with_postfix and with_postfix_slowsmtp
  55. - name: 'Install postfix sasl credentials map'
  56. template:
  57. src: 'postfix/sasl_credentials.j2'
  58. dest: '/etc/postfix/sasl/credentials'
  59. owner: 'root'
  60. group: 'root'
  61. mode: '0600'
  62. notify:
  63. - 'Rehash sasl credentials map'
  64. - 'Reload postfix'
  65. when: with_postfix and with_postfix_external_smtp
  66. - name: 'Install postfix sasl sender rewrite map'
  67. template:
  68. src: 'postfix/sasl_sender_rewrite.j2'
  69. dest: '/etc/postfix/sasl/sender_rewrite'
  70. owner: 'root'
  71. group: 'root'
  72. mode: '0600'
  73. notify:
  74. - 'Reload postfix'
  75. when: with_postfix and with_postfix_external_smtp