Skip to content

Commit

Permalink
Merge pull request #66 from sblaisot/recipient_canonical_maps
Browse files Browse the repository at this point in the history
added possibility for recipient_canoncial_maps, identical to sender_canonical_maps
  • Loading branch information
tersmitten authored Apr 4, 2019
2 parents c3c7b06 + 75d2349 commit 87003b1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ None
* `postfix_aliases` [default: `[]`]: Aliases to ensure present in `/etc/aliases`
* `postfix_virtual_aliases` [default: `[]`]: Virtual aliases to ensure present in `/etc/postfix/virtual`
* `postfix_sender_canonical_maps` [default: `[]`]: Sender address rewriting in `/etc/postfix/sender_canonical_maps` ([see](http://www.postfix.org/postconf.5.html#sender_canonical_maps))
* `postfix_recipient_canonical_maps` [default: `[]`]: Recipient address rewriting in `/etc/postfix/recipient_canonical_maps` ([see](http://www.postfix.org/postconf.5.html#recipient_canonical_maps))
* `postfix_generic:` [default: `[]`]: Generic table address mapping in `/etc/postfix/generic` ([see](http://www.postfix.org/generic.5.html))
* `postfix_mydestination` [default: `["{{ postfix_hostname }}", 'localdomain', 'localhost', 'localhost.localdomain']`]: Specifies what domains this machine will deliver locally, instead of forwarding to another machine
* `postfix_mynetworks` [default: `['127.0.0.0/8', '[::ffff:127.0.0.0]/104', '[::1]/128']`]: The list of "trusted" remote SMTP clients that have more privileges than "strangers"
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ postfix_mailname: "{{ ansible_fqdn }}"
postfix_aliases: []
postfix_virtual_aliases: []
postfix_sender_canonical_maps: []
postfix_recipient_canonical_maps: []
postfix_generic: []
postfix_relayhost: false
postfix_relayhost_port: 587
Expand Down
3 changes: 3 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
- name: postmap sender_canonical_maps
command: postmap hash:/etc/postfix/sender_canonical_maps

- name: postmap recipient_canonical_maps
command: postmap hash:/etc/postfix/recipient_canonical_maps

- name: postmap generic
command: postmap hash:/etc/postfix/generic

Expand Down
19 changes: 19 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,25 @@
- postfix
- postfix-sender-canonical-maps

- name: configure recipient canonical maps
lineinfile:
dest: /etc/postfix/recipient_canonical_maps
regexp: '^{{ item.recipient }}.*'
line: '{{ item.recipient }} {{ item.rewrite }}'
owner: root
group: root
mode: 0644
create: true
state: present
with_items: "{{ postfix_recipient_canonical_maps }}"
notify:
- postmap recipient_canonical_maps
- restart postfix
tags:
- configuration
- postfix
- postfix-recipient-canonical-maps

- name: configure generic table
lineinfile:
dest: /etc/postfix/generic
Expand Down
3 changes: 3 additions & 0 deletions templates/etc/postfix/main.cf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ virtual_alias_maps = hash:/etc/postfix/virtual
{% if postfix_sender_canonical_maps %}
sender_canonical_maps = hash:/etc/postfix/sender_canonical_maps
{% endif %}
{% if postfix_recipient_canonical_maps %}
recipient_canonical_maps = hash:/etc/postfix/recipient_canonical_maps
{% endif %}
{% if postfix_generic %}
smtp_generic_maps = hash:/etc/postfix/generic
{% endif %}
Expand Down

0 comments on commit 87003b1

Please sign in to comment.