certbot-dns-cloudflare/tasks/main.yaml
changeset 174 431c6d5e5dd4
parent 133 effd8e58a796
child 227 2e0366f2dcbe
--- a/certbot-dns-cloudflare/tasks/main.yaml	Sat Jul 24 22:12:04 2021 -0500
+++ b/certbot-dns-cloudflare/tasks/main.yaml	Sun Jul 25 10:30:51 2021 -0500
@@ -21,3 +21,14 @@
     mode: "0644"
     owner: "root"
     group: "root"
+
+- name: check if cert exists
+  become: yes
+  stat: path="/etc/letsencrypt/live/{{certbot_dns_cloudflare_domain}}/cert.pem"
+  register: cert
+
+- name: run certbot
+  become: yes
+  command: "certbot certonly -n --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/cred.conf -d {{certbot_dns_cloudflare_domain}}"
+  when: not cert.stat.exists
+  changed_when: false