Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jessecooper committed Mar 16, 2017
2 parents c7e417a + e14147d commit c414440
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
2 changes: 2 additions & 0 deletions defaults/main.yml
Expand Up @@ -8,3 +8,5 @@ postfix_relayhost: ''
postfix_use_smtp: false
postfix_relayhost_user: false
postfix_relayhost_pass: false
postfix_inet_interfaces: loopback-only
postfix_mynetworks: "127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128"
12 changes: 7 additions & 5 deletions handlers/main.yml
@@ -1,6 +1,10 @@
---
# Handlers for Postfix notifications.

- name: postmap sasl
command: >
/usr/sbin/postmap {{ postfix_config_dir }}/sasl_passwd
- name: stop postfix
service: >
name={{ postfix_service }}
Expand All @@ -18,11 +22,9 @@
state=restarted
enabled=yes
- name: postmap sasl
command: >
/usr/sbin/postmap {{ postfix_config_dir }}/sasl_passwd
- name: send test email
when:
- postfix_notify_email and not false
- postfix_notify_email is defined
shell: >
echo "This is a test message from Ansible configuration of {{ ansible_hostname }} at $(date -R)" | sendmail {{ postfix_notify_email }}
when: postfix_notify_email is defined
19 changes: 18 additions & 1 deletion tasks/main.yml
Expand Up @@ -7,6 +7,8 @@
- common
- postfix

# @todo: Update to use new mktemp module from
# https://github.com/ansible/ansible-modules-extras/pull/2991
- name: Create pre-seed values for Postfix configuration
template: >
src=tmp-postfix_selections.j2
Expand All @@ -31,7 +33,7 @@
apt: >
pkg={{ item }}
update_cache=yes
state=latest
state=installed
with_items: '{{ postfix_packages }}'
when: ansible_os_family == 'Debian'
tags:
Expand Down Expand Up @@ -82,6 +84,21 @@
- common
- postfix

- name: Write Postfix configuration for masquerading
template: >
src=recipient_canonical_map.j2
dest={{ postfix_config_dir }}/recipient_canonical_map
mode=0644 owner=root group=root
backup=yes
notify:
- restart postfix
- send test email
tags:
- common
- postfix
when:
- postfix_masquerade_address is defined

- name: Start Postfix on server boot
service: >
name={{ postfix_service }}
Expand Down
12 changes: 9 additions & 3 deletions templates/main-cf.j2
Expand Up @@ -30,10 +30,16 @@ smtp_use_tls = yes
myhostname = {{ inventory_hostname }}
myorigin = $mydomain
mydestination =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mynetworks = {{ postfix_mynetworks }}
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
relayhost = {% if postfix_relayhost is defined %}{{ postfix_relayhost }}{% else %}$mydomain{% endif %}
inet_interfaces = {{ postfix_inet_interfaces }}
{% if postfix_relayhost is defined %}
relayhost = {{ postfix_relayhost }}
{% endif %}
{% if postfix_masquerade_address is defined %}
recipient_canonical_classes = envelope_recipient
recipient_canonical_maps = regexp:/etc/postfix/recipient_canonical_map
{% endif %}
1 change: 1 addition & 0 deletions templates/recipient_canonical_map.j2
@@ -0,0 +1 @@
/./ {{ postfix_masquerade_address }}

0 comments on commit c414440

Please sign in to comment.