diff --git a/tasks/main.yml b/tasks/main.yml index 3c8f5da..b74c99c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -32,6 +32,9 @@ ansible.builtin.include_tasks: mta-sts.yml tags: mta-sts loop: "{{ postfix_domains }}" + args: + apply: + delegate_to: "{{ gateway_host }}" - name: Hostname ansible.builtin.import_tasks: hostname.yml diff --git a/tasks/mta-sts.yml b/tasks/mta-sts.yml index 1ff8a83..f60bd0b 100644 --- a/tasks/mta-sts.yml +++ b/tasks/mta-sts.yml @@ -4,13 +4,13 @@ src: nginx/mta-sts.txt.j2 dest: /var/www/html/mta-sts.txt mode: "0644" + when: item.mta_sts is defined and item.mta_sts - name: "MTA-STS | Get certificate" ansible.builtin.lineinfile: path: /etc/dehydrated/domains.txt line: "mta-sts.{{ item.name }}" when: "'dehydrated' in ansible_facts.packages and item.mta_sts is defined and item.mta_sts" - loop: "{{ postfix_domains }}" notify: Get certificate - name: "MTA-STS | Copy Nginx configuration" @@ -19,7 +19,6 @@ dest: "/etc/nginx/sites-available/mta-sts.{{ item.name }}" mode: "0644" when: item.mta_sts is defined and item.mta_sts - loop: "{{ postfix_domains }}" - name: "MTA-STS | Enable Nginx configuration" ansible.builtin.file: @@ -27,5 +26,4 @@ dest: "/etc/nginx/sites-enabled/mta-sts.{{ item.name }}" state: link when: item.mta_sts is defined and item.mta_sts - loop: "{{ postfix_domains }}" notify: reload nginx