Ansible Role - Certbot (for Let's Encrypt)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-role-certbot/tasks/test-cert-exists.yml

20 lines
662 B

---
- name: Check if certificate already exists.
stat:
path: /etc/letsencrypt/live/{{ cert_item.domains | first }}/cert.pem
register: letsencrypt_cert_exists
- name: Check if certificate domain list has changed.
lineinfile:
path: /etc/letsencrypt/domains-{{ cert_item.domains | first }}.json
line: " {{ cert_item.domains | to_json }}"
state: present
create: yes
check_mode: yes
register: letsencrypt_cert_contents
when: letsencrypt_cert_exists.stat.exists
- set_fact:
letsencrypt_cert_updated: "{{ (letsencrypt_cert_contents | changed) or (letsencrypt_cert_contents | failed) }}"
when: letsencrypt_cert_exists.stat.exists