diff --git a/roles/postfix/handlers/main.yml b/roles/postfix/handlers/main.yml index 24fdff6..5c65f90 100644 --- a/roles/postfix/handlers/main.yml +++ b/roles/postfix/handlers/main.yml @@ -1,7 +1,5 @@ --- - name: restart postfix - service: name=postfix state=restarted enabled=yes + service: name=postfix state=restarted -- name: rehash relay_auth - command: postmap /etc/postfix/relay_auth ... diff --git a/roles/postfix/tasks/main.yml b/roles/postfix/tasks/main.yml index 9436106..f44aa11 100644 --- a/roles/postfix/tasks/main.yml +++ b/roles/postfix/tasks/main.yml @@ -20,7 +20,15 @@ - name: Deploy Relay authentication map template: src=relay_auth.j2 dest=/etc/postfix/relay_auth mode=600 owner=root group=root - notify: rehash relay_auth + register: relay_auth_file + +- name: Check if relay_auth has been hashed + stat: path=/etc/postfix/relay_auth.db + register: relay_auth_hashed + +- name: Rehash postfix relay auth + command: postmap /etc/postfix/relay_auth + when: relay_auth_file.changed or not relay_auth_hashed.stat.exists - name: Handle postfix port iptables_raw: