mirror of
https://github.com/geerlingguy/ansible-role-certbot.git
synced 2025-04-19 17:01:37 +02:00
Use only lineinfile module, even to check the file exists
This commit is contained in:
parent
b469b40ed6
commit
36c5ac6d29
@ -13,6 +13,7 @@
|
||||
shell: "{{ certbot_create_command }}"
|
||||
when: not letsencrypt_cert_exists.stat.exists or letsencrypt_cert_updated
|
||||
|
||||
# TODO May use a more direct https://docs.ansible.com/ansible/latest/copy_module.html
|
||||
- name: Persist domain list to host
|
||||
lineinfile:
|
||||
path: /etc/letsencrypt/domains-{{ cert_item.domains | first }}
|
||||
|
@ -4,21 +4,16 @@
|
||||
path: /etc/letsencrypt/live/{{ cert_item.domains | first }}/cert.pem
|
||||
register: letsencrypt_cert_exists
|
||||
|
||||
- name: Check if certificate domain list exists.
|
||||
stat:
|
||||
path: /etc/letsencrypt/domains-{{ cert_item.domains | first }}
|
||||
register: letsencrypt_cert_list_exists
|
||||
when: letsencrypt_cert_exists.stat.exists
|
||||
|
||||
- name: Check if certificate domain list has changed.
|
||||
lineinfile:
|
||||
path: /etc/letsencrypt/domains-{{ cert_item.domains | first }}
|
||||
line: "{{ cert_item.domains }}"
|
||||
state: present
|
||||
create: yes
|
||||
check_mode: yes
|
||||
register: letsencrypt_cert_contents
|
||||
when: letsencrypt_cert_exists.stat.exists and letsencrypt_cert_list_exists.stat.exists
|
||||
when: letsencrypt_cert_exists.stat.exists
|
||||
|
||||
- set_fact:
|
||||
letsencrypt_cert_updated: "{{ not letsencrypt_cert_list_exists.stat.exists or (letsencrypt_cert_contents | changed) or (letsencrypt_cert_contents | failed) }}"
|
||||
letsencrypt_cert_updated: "{{ (letsencrypt_cert_contents | changed) or (letsencrypt_cert_contents | failed) }}"
|
||||
when: letsencrypt_cert_exists.stat.exists
|
||||
|
Loading…
x
Reference in New Issue
Block a user