Implement support for DNS install method

This commit is contained in:
Dan Morrison
2024-02-06 18:44:07 +13:00
parent 4be771f12a
commit ce3240e162
6 changed files with 62 additions and 12 deletions
+9
View File
@@ -0,0 +1,9 @@
---
- name: Check if certificate already exists.
stat:
path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
register: letsencrypt_cert
- name: Generate new certificate if one doesn't exist.
command: "{{ certbot_create_command }}"
when: not letsencrypt_cert.stat.exists
+7 -1
View File
@@ -1,7 +1,13 @@
---
- name: Install Certbot.
- name: Install Certbot via package.
package: "name={{ certbot_package }} state=present"
- name: Install Certbot DNS plugin via package.
package: "name=python3-certbot-dns-{{ certbot_dns_plugin }} state=present"
when:
- certbot_create_method == 'dns'
- certbot_dns_plugin is defined
- name: Set Certbot script variable.
set_fact:
certbot_script: "{{ certbot_package }}"
+8
View File
@@ -29,6 +29,14 @@
name: certbot
classic: true
- name: Install certbot DNS plugin via snap.
snap:
name: "certbot-dns-{{ certbot_dns_plugin }}"
classic: true
when:
- certbot_create_method == 'dns'
- certbot_dns_plugin is defined
- name: Symlink certbot into place.
file:
src: /snap/bin/certbot
+8
View File
@@ -29,5 +29,13 @@
loop_control:
loop_var: cert_item
- include_tasks: create-cert-dns.yml
with_items: "{{ certbot_certs }}"
when:
- certbot_create_if_missing
- certbot_create_method == 'dns'
loop_control:
loop_var: cert_item
- import_tasks: renew-cron.yml
when: certbot_auto_renew