Skip to content

Commit 2c7fb5c

Browse files
Updated certificate renewal
Signed-off-by: Russell Seymour <[email protected]>
1 parent 740eb3d commit 2c7fb5c

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

cookbooks/camsa/templates/default/renew_cert.sh renamed to cookbooks/camsa/files/default/configure_automate_crt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@ executeCmd "chef-automate config patch ssl_cert.toml"
9898
log "Restarting Services"
9999
executeCmd "chef-automate restart-services"
100100

101-
popd
101+
popd

cookbooks/camsa/libraries/camsa_certificate.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ def schedule_check
8282
stop_command = new_resource.stop_command
8383

8484
# Use the template to create the script that will be run to renew the certificate
85-
filename = ::File.join(node['camsa']['dirs']['bin'], 'renew_cert.sh')
86-
template filename do
87-
source 'renew_cert.sh'
88-
variables ({
89-
stop_command: stop_command,
90-
start_command: start_command,
85+
script_filename = ::File.join(node['camsa']['dirs']['bin'], 'configure_automate_crt.sh')
86+
cookbook_file script_filename do
87+
source 'configure_automate_crt.sh'
88+
mode '0755'
89+
end
90+
91+
cron_filename = ::File.join(node['camsa']['dirs']['bin'], 'cron_ssl_renew.sh')
92+
template cron_filename do
93+
source 'cron_ssl_renew.sh'
94+
variables({
95+
renew_cert_path: script_filename
9196
})
9297
mode '0755'
9398
end
@@ -100,7 +105,7 @@ def schedule_check
100105
day timing[2]
101106
month timing[3]
102107
weekday timing[4]
103-
command filename
108+
command cron_filename
104109
end
105110

106111
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
# Determine the command to use to stop the service based on what commands
4+
# are installed on the server
5+
if [ -f '/usr/local/bin/chef-automate' ]
6+
PRE_HOOK="chef-automate stop"
7+
POST_HOOK="<%= @renew_cert_path %>"
8+
else
9+
PRE_HOOK="chef-server-ctl stop nginx"
10+
POST_HOOK="chef-server-ctl start nginx"
11+
fi
12+
13+
certbot renew --pre-hook "${PRE_HOOK}" --post-hook "${POST_HOOK}"

0 commit comments

Comments
 (0)