-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from mvdriel/deploy-letsencrypt-certificates-…
…clean-branch Deploy letsencrypt certificates (clean branch)
- Loading branch information
Showing
8 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# tasks file for haproxy | ||
--- | ||
- name: letsencrypt | copy SSL deploy script | ||
template: | ||
src: "{{ haproxy_letsencrypt_ssl_deploy_template }}" | ||
dest: "{{ haproxy_letsencrypt_ssl_deploy }}" | ||
owner: root | ||
group: root | ||
mode: 0755 | ||
tags: | ||
- haproxy-letsencrypt-ssl-deploy | ||
|
||
- name: letsencrypt | copy OCSP deploy script | ||
template: | ||
src: "{{ haproxy_letsencrypt_ocsp_deploy_template }}" | ||
dest: "{{ haproxy_letsencrypt_ocsp_deploy }}" | ||
owner: root | ||
group: root | ||
mode: 0755 | ||
tags: | ||
- haproxy-letsencrypt-ocsp-deploy | ||
|
||
- name: letsencrypt | configure (cron) job for OCSP deploy | ||
cron: | ||
name: haproxy-letsencrypt-ocsp-deploy | ||
job: "{{ haproxy_letsencrypt_ocsp_deploy }}" | ||
state: "{{ haproxy_letsencrypt_ocsp_deploy_job.state | default('absent') }}" | ||
day: "{{ haproxy_letsencrypt_ocsp_deploy_job.day | default('*') }}" | ||
hour: "{{ haproxy_letsencrypt_ocsp_deploy_job.hour | default(0) }}" | ||
minute: "{{ haproxy_letsencrypt_ocsp_deploy_job.minute | default(0) }}" | ||
month: "{{ haproxy_letsencrypt_ocsp_deploy_job.month | default('*') }}" | ||
weekday: "{{ haproxy_letsencrypt_ocsp_deploy_job.weekday | default('*') }}" | ||
cron_file: haproxy-letsencrypt-ocsp-deploy | ||
user: root | ||
tags: | ||
- haproxy-letsencrypt-cron-ocsp-deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
templates/usr/local/bin/haproxy-letsencrypt-ocsp-deploy.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# {{ ansible_managed }} | ||
# | ||
# set -x; | ||
set -e; | ||
set -o pipefail; | ||
# | ||
thisFile="$(readlink -f "${0}")"; | ||
thisFilePath="$(dirname "${thisFile}")"; | ||
|
||
for path in $(ls -1d {{ haproxy_letsencrypt_ssl_src_path }}/*/); do | ||
cert="$(basename ${path})"; | ||
|
||
prefix="100"; | ||
removePrefix="000"; | ||
|
||
if [ "${cert}" == "{{ haproxy_letsencrypt_ssl_first_cert }}" ]; then | ||
prefix="000"; | ||
removePrefix="100"; | ||
fi | ||
|
||
ocspUrl="$(openssl x509 -noout -ocsp_uri -in ${path}{{ haproxy_letsencrypt_ssl_cert_name }})"; | ||
|
||
openssl ocsp -no_nonce -respout "{{ haproxy_global_crt_base }}/${prefix}-${cert}.ocsp" \ | ||
-issuer "${path}{{ haproxy_letsencrypt_ssl_chain_name }}" \ | ||
-verify_other "${path}{{ haproxy_letsencrypt_ssl_chain_name }}" \ | ||
-cert "${path}{{ haproxy_letsencrypt_ssl_cert_name }}" \ | ||
-url "${ocspUrl}"; | ||
|
||
rm -f "{{ haproxy_global_crt_base }}/${removePrefix}-${cert}.ocsp"; | ||
done | ||
|
||
{% if ansible_service_mgr == 'systemd' %} | ||
systemctl reload haproxy; | ||
{% else %} | ||
service haproxy reload; | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# {{ ansible_managed }} | ||
# | ||
# set -x; | ||
set -e; | ||
set -o pipefail; | ||
# | ||
thisFile="$(readlink -f "${0}")"; | ||
thisFilePath="$(dirname "${thisFile}")"; | ||
|
||
for path in $(ls -1d {{ haproxy_letsencrypt_ssl_src_path }}/*/); do | ||
cert="$(basename ${path})"; | ||
|
||
prefix="100"; | ||
removePrefix="000"; | ||
|
||
if [ "${cert}" == "{{ haproxy_letsencrypt_ssl_first_cert }}" ]; then | ||
prefix="000"; | ||
removePrefix="100"; | ||
fi | ||
|
||
cat "${path}{{ haproxy_letsencrypt_ssl_fullchain_name }}" "${path}{{ haproxy_letsencrypt_ssl_privkey_name }}" > "{{ haproxy_global_crt_base }}/${prefix}-${cert}.pem"; | ||
|
||
rm -f "{{ haproxy_global_crt_base }}/${removePrefix}-${cert}.pem"; | ||
done | ||
|
||
{{ haproxy_letsencrypt_ocsp_deploy }}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters