Compare commits

...

5 Commits

Author SHA1 Message Date
Niyazi Gokberk Gunduz
d39a5a8228
Merge 9dcabdc972d4b906908015b89b57926a9cb664e1 into d35de757e01902399e685c2b344823ebc09b3372 2025-08-19 12:24:51 +04:00
Jeff Geerling
d35de757e0
Merge pull request #239 from C0rn3j/patch-1
Fix broken conditionals in create-cert-standalone.yml
2025-08-19 00:52:32 -04:00
Martin
ef85f3e63d
Fix broken conditionals in create-cert-standalone.yml 2025-07-28 10:01:44 +02:00
Niyazi Gokberk Gunduz
9dcabdc972 Define renewal hook variables in defaults/main.yml 2024-05-16 11:13:22 +02:00
Niyazi Gokberk Gunduz
b9415db0f0 Enhance certbot role to support configurable renewal hooks
- Added variables for pre, post, and deploy renewal hooks in defaults/main.yml.
- Created a new task file tasks/setup-hooks.yml to manage the hooks setup.
- Included setup-hooks.yml in tasks/main.yml to ensure hooks are created if specified.
2024-05-16 10:48:43 +02:00
4 changed files with 40 additions and 2 deletions

View File

@ -9,6 +9,12 @@ certbot_auto_renew_options: "--quiet"
certbot_testmode: false certbot_testmode: false
certbot_hsts: false certbot_hsts: false
certbot_renewal_hook_post: ""
certbot_renewal_hook_pre: ""
certbot_renewal_hook_deploy: ""
certbot_renewal_hook_post_filename: "post.sh"
certbot_renewal_hook_pre_filename: "pre.sh"
certbot_renewal_hook_deploy_filename: "deploy.sh"
# Parameters used when creating new Certbot certs. # Parameters used when creating new Certbot certs.
certbot_create_if_missing: false certbot_create_if_missing: false

View File

@ -28,7 +28,7 @@
mode: 0750 mode: 0750
when: when:
- certbot_create_standalone_stop_services is defined - certbot_create_standalone_stop_services is defined
- certbot_create_standalone_stop_services - certbot_create_standalone_stop_services is truthy
- name: Create post hook to start services. - name: Create post hook to start services.
template: template:
@ -39,7 +39,7 @@
mode: 0750 mode: 0750
when: when:
- certbot_create_standalone_stop_services is defined - certbot_create_standalone_stop_services is defined
- certbot_create_standalone_stop_services - certbot_create_standalone_stop_services is truthy
- name: Check if domains have changed - name: Check if domains have changed
block: block:

View File

@ -29,5 +29,7 @@
loop_control: loop_control:
loop_var: cert_item loop_var: cert_item
- import_tasks: setup-hooks.yml
- import_tasks: renew-cron.yml - import_tasks: renew-cron.yml
when: certbot_auto_renew when: certbot_auto_renew

30
tasks/setup-hooks.yml Normal file
View File

@ -0,0 +1,30 @@
---
- name: Ensure renewal hook directories exist
file:
path: "/etc/letsencrypt/renewal-hooks/{{ item }}"
state: directory
with_items:
- post
- pre
- deploy
- name: Create post-renewal hook
copy:
content: "{{ certbot_renewal_hook_post }}"
dest: "/etc/letsencrypt/renewal-hooks/post/{{ certbot_renewal_hook_post_filename }}"
mode: "0755"
when: certbot_renewal_hook_post != ""
- name: Create pre-renewal hook
copy:
content: "{{ certbot_renewal_hook_pre }}"
dest: "/etc/letsencrypt/renewal-hooks/pre/{{ certbot_renewal_hook_pre_filename }}"
mode: "0755"
when: certbot_renewal_hook_pre != ""
- name: Create deploy-renewal hook
copy:
content: "{{ certbot_renewal_hook_deploy }}"
dest: "/etc/letsencrypt/renewal-hooks/deploy/{{ certbot_renewal_hook_deploy_filename }}"
mode: "0755"
when: certbot_renewal_hook_deploy != ""