Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance certbot role to support configurable renewal hooks #215

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 30 additions & 0 deletions tasks/setup-hooks.yml
Original file line number Diff line number Diff line change
@@ -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 != ""
Loading