diff --git a/tasks/check-existence.yml b/tasks/check-existence.yml index 01f8632..e2aee71 100644 --- a/tasks/check-existence.yml +++ b/tasks/check-existence.yml @@ -1,7 +1,6 @@ --- - name: Get installed certificates. - shell: | - {{ certbot_script }} certificates | grep "Domains:" | awk '{ gsub(/ Domains: /,""); print }' + command: "{{ certbot_script }} certificates" changed_when: false register: letsencrypt_certs @@ -13,4 +12,4 @@ set_fact: cert_exists: true when: cert_item.domains | sort | difference(item) == [] - with_list: "{{ letsencrypt_certs.stdout_lines }}" + with_list: "{{ letsencrypt_certs.stdout_lines | select('match', '.*Domains:.*') | map('regex_replace', '^.*Domains: (.*)$', '\\1') }}"