Use template for postfix main.cf
This commit is contained in:
parent
9344a95d95
commit
0ed9279666
2 changed files with 54 additions and 18 deletions
|
@ -19,23 +19,12 @@
|
||||||
group: postfix
|
group: postfix
|
||||||
mode: "640"
|
mode: "640"
|
||||||
|
|
||||||
- name: Add configuration lines
|
- name: Copy main.cf
|
||||||
become: true
|
become: true
|
||||||
loop:
|
ansible.builtin.template:
|
||||||
- virtual_mailbox_domains = pgsql:/etc/postfix/sql-virtual-mailbox-domains.cf
|
src: main.cf.j2
|
||||||
- virtual_mailbox_maps = pgsql:/etc/postfix/sql-virtual-mailbox-maps.cf
|
dest: /etc/postfix/main.cf
|
||||||
- virtual_alias_maps = pgsql:/etc/postfix/sql-virtual-alias-maps.cf
|
owner: root
|
||||||
- virtual_transport = lmtp:unix:private/dovecot-lmtp
|
group: root
|
||||||
- smtpd_recipient_restrictions = reject_unauth_destination,check_policy_service unix:private/quota-status
|
mode: "644"
|
||||||
- smtpd_sasl_type = dovecot
|
|
||||||
- smtpd_sasl_path = private/auth
|
|
||||||
- smtpd_sasl_auth_enable = yes
|
|
||||||
- smtpd_tls_security_level = may
|
|
||||||
- smtpd_tls_auth_only = yes
|
|
||||||
- "smtpd_tls_cert_file = /etc/letsencrypt/live/{{ ansible_hostname }}.{{ virtual_domain }}/fullchain.pem"
|
|
||||||
- "smtpd_tls_key_file = /etc/letsencrypt/live/{{ ansible_hostname }}.{{ virtual_domain }}/privkey.pem"
|
|
||||||
- smtp_tls_security_level = may
|
|
||||||
ansible.builtin.lineinfile:
|
|
||||||
path: /etc/postfix/main.cf
|
|
||||||
line: "{{ item }}"
|
|
||||||
notify: Reload postfix service
|
notify: Reload postfix service
|
||||||
|
|
47
roles/mailserver_postfix/templates/main.cf.j2
Normal file
47
roles/mailserver_postfix/templates/main.cf.j2
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
#myorigin = /etc/mailname
|
||||||
|
|
||||||
|
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
|
||||||
|
biff = no
|
||||||
|
|
||||||
|
# appending .domain is the MUA's job.
|
||||||
|
append_dot_mydomain = no
|
||||||
|
|
||||||
|
readme_directory = no
|
||||||
|
|
||||||
|
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 3.6 on
|
||||||
|
# fresh installs.
|
||||||
|
compatibility_level = 3.6
|
||||||
|
|
||||||
|
myhostname = mailserver-test
|
||||||
|
alias_maps = hash:/etc/aliases
|
||||||
|
alias_database = hash:/etc/aliases
|
||||||
|
mydestination = $myhostname, mailserver-test, localhost.localdomain, , localhost
|
||||||
|
relayhost =
|
||||||
|
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
|
||||||
|
|
||||||
|
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
|
||||||
|
smtpd_recipient_restrictions=reject_unauth_destination,check_policy_service unix:private/quota-status
|
||||||
|
|
||||||
|
smtpd_sasl_type = dovecot
|
||||||
|
smtpd_sasl_path = private/auth
|
||||||
|
smtpd_sasl_auth_enable = yes
|
||||||
|
|
||||||
|
smtpd_tls_cert_file = /etc/letsencrypt/live/{{ ansible_hostname }}.{{ virtual_domain }}/fullchain.pem
|
||||||
|
smtpd_tls_key_file = /etc/letsencrypt/live/{{ ansible_hostname }}.{{ virtual_domain }}/privkey.pem
|
||||||
|
smtpd_tls_security_level = may
|
||||||
|
smtpd_tls_auth_only = yes
|
||||||
|
|
||||||
|
smtp_tls_CApath = /etc/ssl/certs
|
||||||
|
smtp_tls_security_level = may
|
||||||
|
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
|
||||||
|
|
||||||
|
virtual_mailbox_domains=pgsql:/etc/postfix/sql-virtual-mailbox-domains.cf
|
||||||
|
virtual_mailbox_maps=pgsql:/etc/postfix/sql-virtual-mailbox-maps.cf
|
||||||
|
virtual_alias_maps=pgsql:/etc/postfix/sql-virtual-alias-maps.cf
|
||||||
|
virtual_transport=lmtp:unix:private/dovecot-lmtp
|
Loading…
Reference in a new issue