refactor common role
This commit is contained in:
@@ -1 +0,0 @@
|
||||
default: {{ smtp_default_contact }}
|
||||
@@ -1,19 +0,0 @@
|
||||
defaults
|
||||
auth on
|
||||
tls on
|
||||
tls_trust_file /etc/ssl/certs/ca-certificates.crt
|
||||
logfile /var/log/msmtp.log
|
||||
|
||||
{% for account in smtp_accounts %}
|
||||
account {{ account.name }}
|
||||
host {{ account.host }}
|
||||
port 587
|
||||
from {{ account.from }}
|
||||
user {{ account.user | default(account.from) }}
|
||||
password {{ account.password }}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
account default : {{ smtp_default_account }}
|
||||
|
||||
aliases /etc/aliases
|
||||
3
roles/common/templates/opensmtpd/smtpd-secret.j2
Normal file
3
roles/common/templates/opensmtpd/smtpd-secret.j2
Normal file
@@ -0,0 +1,3 @@
|
||||
{% for account in smtp_accounts %}
|
||||
{{ account.name }} {{ account.username | default(account.from) }}:{{ account.password }}
|
||||
{% endfor %}
|
||||
11
roles/common/templates/opensmtpd/smtpd.conf.j2
Normal file
11
roles/common/templates/opensmtpd/smtpd.conf.j2
Normal file
@@ -0,0 +1,11 @@
|
||||
listen on localhost
|
||||
|
||||
table aliases file:/etc/aliases
|
||||
table secrets file:/etc/smtpd-secret
|
||||
|
||||
action "local" mbox alias <aliases>
|
||||
{% for account in smtp_accounts %}
|
||||
action "{{ account.name }}_relay" relay host "smtps://{{ account.name }}@{{ account.host }}" auth <secrets> mail-from "{{ account.from }}"
|
||||
{% endfor %}
|
||||
match for local action "local"
|
||||
match for any action "{{ smtp_default_account }}_relay"
|
||||
2
roles/common/templates/postfix/aliases.j2
Normal file
2
roles/common/templates/postfix/aliases.j2
Normal file
@@ -0,0 +1,2 @@
|
||||
root: {{ smtp_default_recipient }}
|
||||
postmaster: {{ smtp_default_recipient }}
|
||||
40
roles/common/templates/postfix/main.cf.j2
Normal file
40
roles/common/templates/postfix/main.cf.j2
Normal file
@@ -0,0 +1,40 @@
|
||||
{{ ansible_managed | comment }}
|
||||
|
||||
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
|
||||
|
||||
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
|
||||
# fresh installs.
|
||||
compatibility_level = 2
|
||||
|
||||
biff = no
|
||||
recipient_delimiter = +
|
||||
readme_directory = no
|
||||
# appending .domain is the MUA's job.
|
||||
append_dot_mydomain = no
|
||||
|
||||
# rewrite sender address
|
||||
sender_canonical_maps = hash:{{ postfix_senders_map_path }}
|
||||
|
||||
alias_maps = hash:{{ smtp_aliases_path }}
|
||||
alias_database = hash:{{ smtp_aliases_path }}
|
||||
|
||||
myhostname = {{ ansible_hostname }}
|
||||
myorigin = $myhostname
|
||||
mydestination = $myhostname, localhost.localdomain, localhost
|
||||
mynetworks_style = host
|
||||
|
||||
inet_interfaces = all
|
||||
inet_protocols = all
|
||||
|
||||
relayhost = [{{ smtp_accounts[smtp_default_account].host }}]
|
||||
relay_domains =
|
||||
# enable SASL authentication
|
||||
smtp_sasl_auth_enable = yes
|
||||
# disallow methods that allow anonymous authentication.
|
||||
smtp_sasl_security_options = noanonymous
|
||||
# where to find sasl_passwd
|
||||
smtp_sasl_password_maps = hash:{{ postfix_sasl_secrets_path }}
|
||||
# Enable STARTTLS encryption
|
||||
smtp_use_tls = yes
|
||||
# where to find CA certificates
|
||||
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
|
||||
3
roles/common/templates/postfix/sasl_secrets.j2
Normal file
3
roles/common/templates/postfix/sasl_secrets.j2
Normal file
@@ -0,0 +1,3 @@
|
||||
{% for account in smtp_accounts.values() %}
|
||||
[{{ account.host }}] {{ account.username }}:{{ account.password }}
|
||||
{% endfor %}
|
||||
3
roles/common/templates/postfix/senders.j2
Normal file
3
roles/common/templates/postfix/senders.j2
Normal file
@@ -0,0 +1,3 @@
|
||||
{% if smtp_accounts[smtp_default_account].from is defined %}
|
||||
@{{ ansible_hostname }} {{ smtp_accounts[smtp_default_account].from }}
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user