Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some more config fixes #3

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
cc22405
Put restrictions in place when mta is listening
leonnnn Oct 12, 2015
4009cca
Fix error when Make mta_tls_{cert,key} not specified
leonnnn Oct 12, 2015
01a89f1
Set tls_ssl_options = NO_COMPRESSION
leonnnn Oct 12, 2015
6c5a095
Add mailman settings
leonnnn Oct 17, 2015
7bf22bc
Restart postfix instead of just reloading after config changes
leonnnn Oct 18, 2015
d45a320
Add include aliases feature
leonnnn Oct 18, 2015
685bde0
Support ansible version 1.7.2
lightning1 Oct 21, 2015
ec650df
Make sure /etc/postfix/aliases can be generated
leonnnn Oct 24, 2015
1573a0d
Merge branch 'master' of github.com:agdsn/ansible-mta
leonnnn Oct 24, 2015
a47a6c0
Add message_size_limit setting
leonnnn Nov 23, 2015
1ffd5dd
Fix error on empty mta_virtual_maps
leonnnn Dec 3, 2015
6354683
Fix multiply-documented setting
leonnnn Dec 3, 2015
45403a9
Add mta_pipe_transports
leonnnn Jan 27, 2016
64c23d0
Add mta_unverified_recipient_reject_code
leonnnn Jun 8, 2016
3b19d2f
Set default for mta_unverified_recipient_reject_code
leonnnn Jun 14, 2016
23927f0
Add mailbox_command if we’re destination
leonnnn Jun 14, 2016
526df34
Replace deprecatedly given `with_items` with correct syntax
lukasjuhrich Dec 29, 2016
ed74462
Fix typo in main.cf
Mar 26, 2017
3a48115
Merge pull request #1 from fgrsnau/master
mmarx Mar 27, 2017
ddb70d2
Put restrictions together
sebschrader Aug 2, 2017
145e611
Add missing restrictions
sebschrader Aug 2, 2017
3d823c1
Fix typo
sebschrader Aug 9, 2017
d4d24b1
Fix for loop block end
sebschrader Aug 9, 2017
ee8cc44
Move mailbox_command into separate block
sebschrader Aug 9, 2017
552191d
Add default values for all restrictions
sebschrader Aug 9, 2017
4e090bd
Don't always include /etc/postfix/aliases
sebschrader Aug 9, 2017
e98d0f6
Replace for-loop with map-join
sebschrader Aug 9, 2017
42618f9
Remove check for alias_maps
sebschrader Aug 9, 2017
67a0711
Allow separate definition of alias_database
sebschrader Aug 9, 2017
cb0f156
Fix use of Jinja in when-condition
sebschrader Aug 9, 2017
fa632a3
Add origin comment
sebschrader Sep 3, 2017
6555acd
Generate and update access databases
sebschrader Sep 3, 2017
7f4fb71
Add support for restriction classes
sebschrader Sep 3, 2017
25533d3
Replace deprecated include module
sebschrader Feb 26, 2018
9a15b91
Remove postfix tag
sebschrader Feb 26, 2018
3c19be0
Fix missing default value
lukasjuhrich Mar 10, 2018
83a3f0e
Add support for additional config files
georgeto Jul 16, 2018
af13f11
Add support for virtual mailbox domains
georgeto Jul 16, 2018
f4089fc
Add support for sender login maps
georgeto Jul 16, 2018
7176c0e
Fix default value of mta_config_files
georgeto Aug 7, 2018
03a4d5b
Add support for additional services
georgeto Aug 7, 2018
a44d17f
Add support for upstream proxy protocol
georgeto Aug 8, 2018
cedb13d
Make options of mail submission service configurable
georgeto Aug 8, 2018
c81cb25
Replace usages of tests as filters with new syntax
georgeto Aug 8, 2018
22b8358
Extend mta_services logic
fgrsnau Nov 11, 2018
835eb11
Take care of deprecation warnings
georgeto Feb 26, 2020
ba39fa7
Add support for smtpd milters
georgeto Mar 4, 2020
a9fdea1
Ensure config values don not contain newlines
georgeto Mar 9, 2020
24afbfa
Remove duplicate default values
georgeto Mar 10, 2020
792e06d
Sort dictionaries during templating for predictable output
georgeto Mar 10, 2020
1cf8081
Use list instead of dict to specify service command attributes
georgeto Mar 11, 2020
6d209dd
Add recipient_delimiter parameter
georgeto Mar 27, 2020
44d6b6c
Allow the specification of additional parameters
georgeto Mar 28, 2020
2b1e461
Fix default value of mta_parameters
georgeto Apr 7, 2020
93e9065
Improve management of additional config files
georgeto Apr 7, 2020
ad7ba3c
Add support for canonical mappings and header checks
georgeto Apr 7, 2020
63b60a1
Increase compatibility level
georgeto Apr 9, 2020
9e4133e
Use proper permissions for policy and access database directories
georgeto Apr 23, 2020
7aeaf16
Rework local canonical mappings
georgeto Apr 23, 2020
230960d
Improve formatting of service options
georgeto Apr 25, 2020
6f0a769
Fix typo in smtp_sasl_mechanism_filter
georgeto May 5, 2020
3ae57ad
Make smtp client tls security configurable
georgeto May 5, 2020
c4431fe
Improve management of additional parameters
georgeto Jul 14, 2020
478658a
Refactor virtual_alias_maps template
georgeto Mar 12, 2021
56b20ec
Simplify configuration of SASL authenticated relay host
georgeto Mar 12, 2021
4ab8c08
Remove duplicated message_size_limit option
georgeto Apr 2, 2021
08d9276
Provide default configuration values
georgeto Apr 9, 2022
2d6bcb4
Add Github Action for Linting
Paktosan Aug 15, 2022
4ca28e5
Fix easy lint issues
Paktosan Aug 15, 2022
5a7e89a
Add ansible-lint pre-commit hook
Paktosan Sep 11, 2022
ad06fa8
Use CA path instead of file
Paktosan Sep 11, 2022
d9f6a73
allow setting access controls for database files
mabezi Jan 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
on: [push, pull_request]

jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run ansible-lint
uses: ansible-community/ansible-lint-action@main
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/ansible-community/ansible-lint
rev: v6.5.2
hooks:
- id: ansible-lint
51 changes: 41 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Accepting mail
accept mail. This is independent from ``mta_is_destination`` -- domains may be
purely for forwarding purposes.

* ``mta_message_size_limit`` (integer): Maximum size for a message in bytes to
be accepted for delivery (on either service, smtpd or submission)
* ``mta_message_size_limit`` (integer, default 10240000): Maximum size of emails
that postfix will accept in bytes (on either service, smtpd or submission).

* ``mta_postscreen`` (thing or false): If not false, the ``postscreen`` service
will be enabled.
Expand Down Expand Up @@ -108,16 +108,16 @@ Accepting mail
directly; it will typically be used for MTAs that only need to send cron mails
etc.

* ``mta_relayhost_auth`` (mapping): This is only meaningful if
``mta_relayhost`` is set. In that case, this mapping allows to set up
authentication with the relay host using SASL:
* ``mta_relayhost_auth_username`` (string): This is only meaningful
if ``mta_relayhost`` is set. In that case this set the SASL user name to use
to set up authentication with the relay host using SASL.

* ``mta_relayhost_auth.username`` (string): the SASL user name to use
* ``mta_relayhost_auth.mapfile`` (path): A path where a config file
containing the credentials will be written to.
* ``mta_relayhost_auth_password`` (string): The password to use for relayhost SASL
authentication. Required if ``mta_relayhost_auth_username`` is used.

* ``mta_relayhost_auth_mapfile`` (path): A path where a config file containing
the SASL authentication credentials will be written to.

* ``mta_relayhost_password`` (string): The password to use for relayhost SASL
authentication. Required if ``mta_relayhost_auth`` is used.

* ``mta_transport_map`` (mapping): A lookup table, mapping destination
address patterns to their respective nexthop. Refer to the `postfix
Expand Down Expand Up @@ -239,3 +239,34 @@ Safety nets and misc

* ``mta_override_hostname`` (string, optional): If set, this is used as value
for myhostname instead of the value of ``inventory_hostname``.

If you’d like to add further files from another role, install them to
``/etc/postfix/aliases.d/`` using file names ending in ``.aliases``, and notify
the ``update include alias file`` handler. These files will automatically be
concatenated and installed to ``/etc/postfix/aliases``.

Running additional services
---------------------------

* ``mta_services`` (list of dictionaries). Each dictionary describes a service
* that should be added to the ``master.cf``.

Example::

mta_services:
- port: 5870
type: inet
command: smtpd
options:
smtpd_tls_security_level: encrypt
smtpd_relay_restrictions:
- permit_sasl_authenticated
- defer_unauth_destination

Mailman
-------
* ``mta_use_mailman`` (bool, default false): Set this to enable the mailman
transport.

* ``mta_mailman_script_location`` (string, default ``/usr/lib/mailman/bin/postfix-to-mailman.py``):
Location of the ``postfix-to-mailman.py`` program.
91 changes: 70 additions & 21 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,89 @@
---
mta_alias_maps: []
mta_relayhost: False
mta_relayhost_auth: False
mta_listen: True
mta_access_databases: {}
mta_alias_database: []
mta_alias_maps:
- "$alias_database"
- hash:/etc/postfix/aliases
mta_local_canonical_myorigin: ""
mta_local_sender_canonical_maps: []
mta_local_recipient_canonical_maps: []
mta_local_canonical_header_checks: []
mta_relayhost: false
mta_relayhost_auth_username: null
mta_relayhost_auth_mapfile: /etc/postfix/password_map
mta_smtp_tls_wrappermode: false
mta_smtp_tls_security_level: "may"
mta_smtp_tls_ca_path: /etc/ssl/certs/
mta_listen: true
mta_smtpd_upstream_proxy_protocol: ""
mta_smtpd_restriction_classes: {}
mta_smtpd_client_restrictions: []
mta_smtpd_sender_login_maps: []
mta_smtpd_sender_restrictions: []
mta_smtpd_relay_restrictions:
- reject_unauth_destination
- reject_unauth_destination
mta_smtpd_recipient_restrictions: []
mta_smtpd_helo_restrictions: []
mta_smtpd_data_restrictions: []
mta_smtpd_end_of_data_restrictions: []
mta_smtpd_etrn_restrictions: []
mta_smtpd_milters: []
mta_domains: []
mta_postscreen: False
mta_delay_warning: False
mta_virtual_mailbox_domains: []
mta_virtual_transport: []
mta_postscreen: false
mta_delay_warning: false
mta_transport_map: {}
mta_tls_security_level: "may"
mta_tls_log: False
mta_tls_log: false
mta_mynetworks: []
mta_smtpd_helo_required: False
mta_strict_rfc821_envelopes: False
mta_domains: []
mta_message_size_limit: False
mta_smtpd_helo_required: false
mta_strict_rfc821_envelopes: false
mta_listen_interfaces:
- all
mta_soft_bounce: False
- all
mta_soft_bounce: false
mta_relay_domains: []
mta_virtual_maps: []
mta_mailbox_command: null

# Mail Submission Agent settings
mta_msa: False
mta_msa: false
mta_msa_smtpd_client_restrictions: []
mta_msa_sasl_type: False
mta_msa_sasl_path: False
mta_msa_dkim: False
mta_msa_sasl_type: false
mta_msa_sasl_path: false
mta_msa_dkim: false
mta_msa_options:
smtpd_tls_security_level: "encrypt"
smtpd_client_restrictions: []
smtpd_recipient_restrictions: []
smtpd_helo_restrictions: []
smtpd_sender_restrictions: []
smtpd_relay_restrictions:
- permit_sasl_authenticated
- defer_unauth_destination

# OpenDKIM settings
mta_dkim: False
mta_dkim_sign: False
mta_dkim_verify: True
mta_dkim: false
mta_dkim_sign: false
mta_dkim_verify: true
mta_dkim_selector: "deployment"
mta_dkim_domains: []

# Mailman settings
mta_use_mailman: false
mta_mailman_script_location: /etc/mailman/postfix-to-mailman.py

# other
mta_recipient_delimiter: ""
mta_message_size_limit: 10240000
mta_pipe_transports: []
mta_unverified_recipient_reject_code: 450
mta_config_files_all: []
mta_config_files: []

# Additional parameters
mta_parameters_all: {}
mta_parameters: {}

# Additional services
mta_services: []
22 changes: 20 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
---
- name: reload postfix
service: name=postfix state=reloaded
ansible.builtin.service: name=postfix state=reloaded

- name: restart postfix
ansible.builtin.service: name=postfix state=restarted

- name: update include alias file
ansible.builtin.command: find /etc/postfix/aliases.d -type f -name '*.aliases'
register: alias_files
notify:
- really update include alias file

- name: really update include alias file
ansible.builtin.shell: cat {{ alias_files.stdout_lines | join(' ') }} > /etc/postfix/aliases
when: '" ".join(alias_files.stdout_lines)'
notify:
- compile include alias file

- name: compile include alias file
ansible.builtin.command: postalias /etc/postfix/aliases

- name: restart opendkim
service: name=opendkim state=restarted
ansible.builtin.service: name=opendkim state=restarted
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
- include: postfix.yml
- include: opendkim.yml
- import_tasks: postfix.yml
- import_tasks: opendkim.yml
when: mta_dkim | default(False)
15 changes: 4 additions & 11 deletions tasks/opendkim.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
---
- name: install packages
yum: name={{ item }} state=latest
ansible.builtin.yum: name={{ item }} state=present
with_items:
- opendkim
tags:
- opendkim
- yum

- name: instanciate config
template: src=opendkim/opendkim.conf dest=/etc/opendkim.conf
tags:
- opendkim
ansible.builtin.template: src=opendkim/opendkim.conf dest=/etc/opendkim.conf
notify:
- restart opendkim

- name: instanciate tables
template: src=opendkim/{{ item }} dest=/etc/opendkim/
ansible.builtin.template: src=opendkim/{{ item }} dest=/etc/opendkim/
with_items:
- SigningTable
- KeyTable
tags:
- opendkim
notify:
- restart opendkim

- name: enable and start opendkim
service: name=opendkim enabled=yes state=started
tags:
- opendkim
ansible.builtin.service: name=opendkim enabled=yes state=started
Loading