ansible-role-certbot/tasks/check-existence.yml

16 lines
510 B
YAML

---
- name: Get installed certificates.
command: "{{ certbot_script }} certificates"
changed_when: false
register: letsencrypt_certs
- name: Set cert_exists to false (to check if cert exists).
set_fact:
cert_exists: false
- name: Check if certificate already exists.
set_fact:
cert_exists: true
when: cert_item.domains | sort | difference(item) == []
with_list: "{{ letsencrypt_certs.stdout_lines | select('match', '.*Domains:.*') | map('regex_replace', '^.*Domains: (.*)$', '\\1') }}"