diff --git a/defaults/main.yml b/defaults/main.yml index ba01b0f..21cdc36 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,5 @@ --- -sasl_host: "" -sasl_user: "" -sasl_domain: "" -sasl_passwd: "{{ vault_sasl_passwd }}" +postfix_relay_sasl_host: smtp.gmail.com +postfix_relay_sasl_user: user +postfix_relay_sasl_domain: gmail.com +postfix_relay_sasl_passwd: secure diff --git a/tasks/config.yml b/tasks/config.yml index e0b6193..4ed501c 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -1,8 +1,8 @@ --- - name: Configure postfix template: - src: 'etc/postfix/main.cf.j2' - dest: '/etc/postfix/main.cf' + src: etc/postfix/main.cf.j2 + dest: /etc/postfix/main.cf owner: root group: root mode: 0644 @@ -10,8 +10,8 @@ - name: Create sasl template: - src: 'etc/postfix/sasl_passwd.j2' - dest: '/etc/postfix/sasl_passwd' + src: etc/postfix/sasl_passwd.j2 + dest: /etc/postfix/sasl_passwd owner: root group: root mode: 0600 @@ -19,18 +19,18 @@ - name: Ensure sasl_passwd.db exist stat: - path: '/etc/postfix/sasl_passwd.db' + path: /etc/postfix/sasl_passwd.db register: sasldb - name: Create sasl_passwd.db - command: '/usr/sbin/postmap hash:/etc/postfix/sasl_passwd' - when: sasldb.stat.exists == 'false' or sasl_result.changed + command: /usr/sbin/postmap hash:/etc/postfix/sasl_passwd + when: not sasldb.stat.exists or sasl_result.changed register: sasldb_update notify: postfix_restart - name: Set permissions for sasl_passwd.db file: - path: '/etc/postfix/sasl_passwd.db' + path: /etc/postfix/sasl_passwd.db owner: root group: root mode: 0600 @@ -38,8 +38,8 @@ - name: Override outgoing header template: - src: 'etc/postfix/sender_canonical.j2' - dest: '/etc/postfix/sender_canonical' + src: etc/postfix/sender_canonical.j2 + dest: /etc/postfix/sender_canonical owner: root group: root mode: 0600 @@ -47,11 +47,11 @@ - name: Ensure sender_canonical.db exist stat: - path: '/etc/postfix/sender_canonical.db' + path: /etc/postfix/sender_canonical.db register: senderdb - name: Hash sender_canoncial - command: '/usr/sbin/postmap hash:/etc/postfix/sender_canonical' - when: senderdb.stat.exists == false or sender_result.changed + command: "/usr/sbin/postmap hash:/etc/postfix/sender_canonical" + when: not senderdb.stat.exists or sender_result.changed register: senderdb_update notify: postfix_restart diff --git a/templates/etc/postfix/sasl_passwd.j2 b/templates/etc/postfix/sasl_passwd.j2 index 8c3071f..d5e73a5 100644 --- a/templates/etc/postfix/sasl_passwd.j2 +++ b/templates/etc/postfix/sasl_passwd.j2 @@ -1,3 +1,3 @@ # {{ ansible_managed }} -{{ sasl_host }} {{ sasl_user }}@{{ sasl_domain }}:{{ sasl_passwd }} +{{ postfix_relay_sasl_host }} {{ postfix_relay_sasl_user }}@{{ postfix_relay_sasl_domain }}:{{ postfix_relay_sasl_passwd }} diff --git a/templates/etc/postfix/sender_canonical.j2 b/templates/etc/postfix/sender_canonical.j2 index b65ceae..6205fff 100644 --- a/templates/etc/postfix/sender_canonical.j2 +++ b/templates/etc/postfix/sender_canonical.j2 @@ -1,3 +1,3 @@ # {{ ansible_managed }} -root {{ ansible_hostname }}@{{ sasl_domain }} +root {{ ansible_hostname }}@{{ postfix_relay_sasl_domain }}