Skip to content

Commit

Permalink
Improve certificate existence check by removing bashisms
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Jan 25, 2022
1 parent 95c899b commit 9c0d000
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tasks/check-existence.yml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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') }}"

0 comments on commit 9c0d000

Please sign in to comment.