null-client.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. - hosts: [localhost]
  2. become: true
  3. tasks:
  4. - docker_network:
  5. name: mail
  6. - docker_volume:
  7. volume_name: postfix_config
  8. register: config_volume
  9. - name: copy trusted CA certs
  10. copy:
  11. src: ../smtp-tls-trusted-ca.pem
  12. dest: '{{ config_volume.ansible_facts.docker_volume.Mountpoint }}/smtp-tls-trusted-ca.pem'
  13. register: smtp_trusted_ca_certs
  14. - name: create config
  15. copy:
  16. content: |
  17. # $myhostname prefix is a RFC requirement
  18. smtpd_banner = $myhostname ESMTP $mail_name quid agis?
  19. # RCPT TO matches $relay_domains => !reject_unauth_destination
  20. # http://www.postfix.org/postconf.5.html#smtpd_relay_restrictions
  21. smtpd_relay_restrictions = reject_non_fqdn_recipient, reject_unauth_destination
  22. mydestination =
  23. relay_domains = example.com
  24. # include TLS protocol & cipher in 'Received' header
  25. smtpd_tls_received_header = yes
  26. # + sasl username
  27. smtpd_sasl_authenticated_header = yes
  28. relayhost = relay.example.com:submission
  29. smtp_tls_security_level = secure
  30. smtp_tls_secure_cert_match = nexthop
  31. smtp_tls_CAfile = /etc/postfix/smtp-tls-trusted-ca.pem
  32. # docs recommend against whitelist
  33. smtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
  34. smtp_tls_session_cache_database = btree:${data_directory}/smtp-tls-session-cache
  35. # http://www.postfix.org/MAILLOG_README.html
  36. maillog_file = /dev/stdout
  37. # http://www.postfix.org/COMPATIBILITY_README.html
  38. compatibility_level = 2
  39. dest: '{{ config_volume.ansible_facts.docker_volume.Mountpoint }}/main.cf'
  40. mode: a=r
  41. register: config
  42. - docker_container:
  43. name: postfix
  44. # 1.0.0-postfix3.4.5r0-amd64
  45. image: fphammerle/postfix@sha256:33c2dfc8d292b8399f7c61b206922b81c870ce5ae2c7e233fd1a38d420417154
  46. hostname: postfix-test
  47. volumes:
  48. - '{{ config_volume.ansible_facts.docker_volume.Mountpoint }}/main.cf:/etc/postfix/main.cf:ro'
  49. - '{{ config_volume.ansible_facts.docker_volume.Mountpoint }}/smtp-tls-trusted-ca.pem:/etc/postfix/smtp-tls-trusted-ca.pem:ro'
  50. networks: [name: mail]
  51. purge_networks: yes
  52. published_ports: ['localhost:25:25']
  53. restart_policy: unless-stopped
  54. restart: '{{ config.changed or smtp_trusted_ca_certs.changed }}'