Skip to content

Commit

Permalink
Merge in pull request salt-formulas#20
Browse files Browse the repository at this point in the history
  • Loading branch information
NixM0nk3y committed Aug 3, 2018
2 parents 4635aac + 5ac07b9 commit 20673c6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,28 @@ You are able to use multidomain certificates:
- awk.opensource-expert.com
- www.awk.opensource-expert.com
You can add renewal hooks if needed; these can be useful for services that
don't run as root, to move certs somewhere they can access:

.. code-block:: yaml
letsencrypt:
client:
hooks:
pre:
- salt://path/to/prehook1.sh
- salt://path/to/prehook2.sh
deploy:
- salt://path/to/deployhook1.sh
post:
- salt://path/to/posthook1.sh
# You can define hooks literally in pillar too
pillarhooks:
deploy:
deployhook1.sh: |
#!/bin/bash
echo "Triggered deploy hook"
Legacy configuration
--------------------

Expand Down
28 changes: 28 additions & 0 deletions letsencrypt/client/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,32 @@ certbot_cron:
{%- endif %}
{%- for hookset, hooks in client.get("hooks", {}).items() %}
{%- for hook in hooks %}
{#- FIXME: Should probably complain if something other than
pre/post/deploy is given, but I'm not sure how. #}
{%- set basename = hook.split("/") | last %}
certbot_renewal_{{ hookset }}_hook_{{ basename }}:
file.managed:
- name: /etc/letsencrypt/renewal-hooks/{{ hookset }}/{{ basename }}
- source: {{ hook }}
- template: jinja
- mode: 700
- require:
- cmd: certbot_installed
{%- endfor %}
{%- endfor %}
{%- for hookset, hooks in client.get("pillarhooks", {}).items() %}
{%- for basename in hooks.keys() %}
certbot_renewal_{{ hookset }}_phook_{{ loop.index }}:
file.managed:
- name: /etc/letsencrypt/renewal-hooks/{{ hookset }}/{{ basename }}
- contents_pillar: letsencrypt:client:pillarhooks:{{ hookset }}:{{ basename }}
- mode: 700
- require:
- cmd: certbot_installed
{%- endfor %}
{%- endfor %}
{%- endif %}

0 comments on commit 20673c6

Please sign in to comment.