diff --git a/library/roles/postfix-relay/tasks/postfix-letsencrypt-hook.yml b/library/roles/postfix-relay/tasks/postfix-letsencrypt-hook.yml index d391d0be..8d634215 100644 --- a/library/roles/postfix-relay/tasks/postfix-letsencrypt-hook.yml +++ b/library/roles/postfix-relay/tasks/postfix-letsencrypt-hook.yml @@ -1,4 +1,8 @@ --- +- name: Create the acme hooks directory if it does not exist + file: dest=/usr/lib/acme/hooks state=directory + tags: [ 'postfix', 'postfix-relay', 'postfix_letsencrypt', 'letsencrypt' ] + - name: Install a hook for letsencrypt template: src=postfix-letsencrypt-hook dest=/usr/lib/acme/hooks/postfix owner=root group=root mode=4555 - tags: [ 'postfix', 'postfix-relay' ] + tags: [ 'postfix', 'postfix-relay', 'postfix_letsencrypt', 'letsencrypt' ] diff --git a/library/roles/postfix/tasks/postfix-letsencrypt-hook.yml b/library/roles/postfix/tasks/postfix-letsencrypt-hook.yml index 5d67e52b..202a0b3a 100644 --- a/library/roles/postfix/tasks/postfix-letsencrypt-hook.yml +++ b/library/roles/postfix/tasks/postfix-letsencrypt-hook.yml @@ -1,8 +1,18 @@ --- -- name: Create the acme hooks directory if it does not exist - file: dest=/usr/lib/acme/hooks/postfix state=directory - tags: [ 'postfix', 'postfix-relay', 'letsencrypt' ] +- name: Manage the letsencrypt hook for postfix + block: + - name: Create the acme hooks directory if it does not exist + file: dest=/usr/lib/acme/hooks state=directory -- name: Install a hook for letsencrypt - template: src=postfix-letsencrypt-hook dest=/usr/lib/acme/hooks/postfix owner=root group=root mode=4555 - tags: [ 'postfix', 'postfix-relay', 'letsencrypt' ] + - name: In the past we created a directory instead of a file. Check if it's the case + stat: path=/usr/lib/acme/hooks/postfix + register: postfix_hookdir + + - name: Remove the wrong directory if it's present + file: dest=/usr/lib/acme/hooks/postfix state=absent + when: postfix_hookdir.stat.isdir is defined and postfix_hookdir.stat.isdir + + - name: Install a hook for letsencrypt + template: src=postfix-letsencrypt-hook dest=/usr/lib/acme/hooks/postfix owner=root group=root mode=0555 + + tags: [ 'postfix', 'postfix_letsencrypt', 'letsencrypt' ] diff --git a/library/roles/postfix/tasks/smtp-sasl-auth.yml b/library/roles/postfix/tasks/smtp-sasl-auth.yml index bc4f2a2e..62a806e9 100644 --- a/library/roles/postfix/tasks/smtp-sasl-auth.yml +++ b/library/roles/postfix/tasks/smtp-sasl-auth.yml @@ -1,7 +1,7 @@ --- - name: Write sasl hash file template: src=sasl_passwd.j2 dest=/etc/postfix/sasl_passwd owner=root group=root mode=0400 - when: postfix_use_sasl_auth + when: postfix_use_sasl_auth | bool register: update_sasl_hash tags: postfix-relay