Add Postfix-SES role for easy integration
This commit is contained in:
parent
8fc419e273
commit
2183d5778e
8
roles/postfix-ses/handlers/main.yml
Normal file
8
roles/postfix-ses/handlers/main.yml
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/ansible-playbook
|
||||
# vim:ft=ansible:
|
||||
---
|
||||
- name: restart postfix
|
||||
systemd:
|
||||
name: postfix
|
||||
state: restarted
|
||||
become: yes
|
2
roles/postfix-ses/meta/main.yml
Normal file
2
roles/postfix-ses/meta/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
allow_duplicates: no
|
47
roles/postfix-ses/tasks/main.yml
Normal file
47
roles/postfix-ses/tasks/main.yml
Normal file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/ansible-playbook
|
||||
# vim:ft=ansible:
|
||||
---
|
||||
- name: Install Postfix for SES
|
||||
block:
|
||||
- name: Install Postfix
|
||||
apt:
|
||||
name:
|
||||
- postfix
|
||||
- name: Template out configuration
|
||||
template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode }}"
|
||||
loop:
|
||||
- { src: "main.cf", dest: "/etc/postfix/main.cf", mode: "0644" }
|
||||
notify: restart postfix
|
||||
- name: Template out password
|
||||
template:
|
||||
src: sasl_passwd
|
||||
dest: /etc/postfix/sasl_passwd
|
||||
mode: "0640"
|
||||
owner: root
|
||||
group: postfix
|
||||
notify: restart postfix
|
||||
register: p
|
||||
- name: Look for password database
|
||||
stat:
|
||||
path: /etc/postfix/sasl_passwd.db
|
||||
register: s
|
||||
- name: Regenerate password database
|
||||
command:
|
||||
cmd: postmap /etc/postfix/sasl_passwd
|
||||
notify: restart postfix
|
||||
when: p is changed or not s.stat.exists
|
||||
- name: Tighten permissions on sasl_passwd.db
|
||||
file:
|
||||
path: /etc/postfix/sasl_passwd.db
|
||||
mode: "0640"
|
||||
owner: root
|
||||
group: postfix
|
||||
- name: Enable service
|
||||
systemd:
|
||||
name: postfix
|
||||
enabled: yes
|
||||
state: started
|
||||
become: yes
|
52
roles/postfix-ses/templates/main.cf
Normal file
52
roles/postfix-ses/templates/main.cf
Normal file
@ -0,0 +1,52 @@
|
||||
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
|
||||
|
||||
|
||||
# Debian specific: Specifying a file name will cause the first
|
||||
# line of that file to be used as the name. The Debian default
|
||||
# is /etc/mailname.
|
||||
#myorigin = /etc/mailname
|
||||
|
||||
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
|
||||
biff = no
|
||||
|
||||
# appending .domain is the MUA's job.
|
||||
append_dot_mydomain = no
|
||||
|
||||
# Uncomment the next line to generate "delayed mail" warnings
|
||||
#delay_warning_time = 4h
|
||||
|
||||
readme_directory = no
|
||||
|
||||
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
|
||||
# fresh installs.
|
||||
compatibility_level = 2
|
||||
|
||||
# TLS parameters
|
||||
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
|
||||
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
|
||||
smtpd_use_tls=yes
|
||||
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
|
||||
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
|
||||
# This section and the relayhost are set up for SES
|
||||
smtp_sasl_auth_enable=yes
|
||||
smtp_sasl_security_options = noanonymous
|
||||
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
|
||||
smtp_use_tls = yes
|
||||
smtp_tls_security_level = encrypt
|
||||
smtp_tls_note_starttls_offer = yes
|
||||
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
|
||||
# information on enabling SSL in the smtp client.
|
||||
|
||||
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
|
||||
myhostname = web2.us-east-2.compute.internal
|
||||
alias_maps = hash:/etc/aliases
|
||||
alias_database = hash:/etc/aliases
|
||||
mydestination = $myhostname, web2, localhost.localdomain, , localhost
|
||||
relayhost = [email-smtp.us-east-1.amazonaws.com]:587
|
||||
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
|
||||
mailbox_size_limit = 0
|
||||
recipient_delimiter = +
|
||||
inet_interfaces = all
|
||||
inet_protocols = all
|
1
roles/postfix-ses/templates/sasl_passwd
Normal file
1
roles/postfix-ses/templates/sasl_passwd
Normal file
@ -0,0 +1 @@
|
||||
[email-smtp.us-east-1.amazonaws.com]:587 {{ aws_ses_user }}:{{ aws_ses_pass }}
|
Loading…
Reference in New Issue
Block a user