mirror of
https://github.com/geerlingguy/ansible-role-certbot.git
synced 2025-04-19 17:01:37 +02:00
Add cloud-init create method
This commit is contained in:
parent
00dc226101
commit
0cad084f4c
@ -36,3 +36,7 @@ certbot_keep_updated: true
|
|||||||
|
|
||||||
# Where to put Certbot when installing from source.
|
# Where to put Certbot when installing from source.
|
||||||
certbot_dir: /opt/certbot
|
certbot_dir: /opt/certbot
|
||||||
|
|
||||||
|
# When certbot_create_method==cloud-init, test certificates will be installed
|
||||||
|
# that can be used by a server (eg. nginx)
|
||||||
|
certbot_cloud_init_test_certificates: true
|
||||||
|
21
tasks/create-cert-cloud-init.yml
Normal file
21
tasks/create-cert-cloud-init.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- name: Check if certificate already exists.
|
||||||
|
stat:
|
||||||
|
path: /etc/letsencrypt/live/{{ cert_item.domains | first | replace('*.', '') }}/cert.pem
|
||||||
|
register: letsencrypt_cert
|
||||||
|
|
||||||
|
- name: Ensure cloud-init directory exists.
|
||||||
|
file:
|
||||||
|
path: /var/lib/cloud/scripts/per-instance
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Ensure cloud-init creates certificates.
|
||||||
|
template:
|
||||||
|
src: certbot-init.sh.j2
|
||||||
|
dest: "/var/lib/cloud/scripts/per-instance/certbot-init-{{ cert_item.domains | first | replace('*.', '') }}.sh"
|
||||||
|
|
||||||
|
- name: Ensure test certificates are created.
|
||||||
|
command: "{{ certbot_create_command }} --test-cert"
|
||||||
|
when:
|
||||||
|
- not letsencrypt_cert.stat.exists
|
||||||
|
- certbot_cloud_init_test_certificates
|
@ -15,5 +15,13 @@
|
|||||||
loop_control:
|
loop_control:
|
||||||
loop_var: cert_item
|
loop_var: cert_item
|
||||||
|
|
||||||
|
- include_tasks: create-cert-cloud-init.yml
|
||||||
|
with_items: "{{ certbot_certs }}"
|
||||||
|
when:
|
||||||
|
- certbot_create_if_missing
|
||||||
|
- certbot_create_method == 'cloud-init'
|
||||||
|
loop_control:
|
||||||
|
loop_var: cert_item
|
||||||
|
|
||||||
- import_tasks: renew-cron.yml
|
- import_tasks: renew-cron.yml
|
||||||
when: certbot_auto_renew
|
when: certbot_auto_renew
|
||||||
|
4
templates/certbot-init.sh.j2
Normal file
4
templates/certbot-init.sh.j2
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
{{ certbot_create_command }}
|
Loading…
x
Reference in New Issue
Block a user