Compare commits

...

4 Commits

Author SHA1 Message Date
Niyazi Gokberk Gunduz
dd9c3bcf25
Merge 9dcabdc972d4b906908015b89b57926a9cb664e1 into 3b3cc546d123c06b294182c747cacaab83174fca 2025-05-07 14:40:57 +02:00
Jeff Geerling
3b3cc546d1 Syntax adjust. 2025-05-04 20:02:06 -05: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 41 additions and 1 deletions

View File

@ -9,6 +9,12 @@ certbot_auto_renew_options: "--quiet"
certbot_testmode: 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.
certbot_create_if_missing: false

View File

@ -1,6 +1,8 @@
---
- name: Install Certbot.
package: "name={{ certbot_package }} state=present"
package:
name: "{{ certbot_package }}"
state: present
- name: Set Certbot script variable.
set_fact:

View File

@ -29,5 +29,7 @@
loop_control:
loop_var: cert_item
- import_tasks: setup-hooks.yml
- import_tasks: renew-cron.yml
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 != ""