Improve the letsencrypt recipe
Add missing dependency Regenerate the nginx vhost after generating the cert for the first time
This commit is contained in:
parent
14542f8419
commit
bfd2d52ea8
@ -1,11 +1,14 @@
|
||||
# nginx config to generate a Let's Encrypt cert
|
||||
|
||||
include_recipe "kosmos-base::letsencrypt"
|
||||
|
||||
root_directory = "/var/www/xmpp.5apps.com"
|
||||
|
||||
directory root_directory do
|
||||
directory "#{root_directory}/.well-known" do
|
||||
owner node["nginx"]["user"]
|
||||
group node["nginx"]["group"]
|
||||
action :create
|
||||
recursive true
|
||||
end
|
||||
|
||||
template "#{node['nginx']['dir']}/sites-available/xmpp.5apps.com" do
|
||||
@ -19,11 +22,16 @@ template "#{node['nginx']['dir']}/sites-available/xmpp.5apps.com" do
|
||||
notifies :reload, 'service[nginx]', :delayed
|
||||
end
|
||||
|
||||
# Generate a Let's Encrypt cert (only if the nginx vhost exists and no cert
|
||||
# has been generated before. The renew cron will take care of renewing
|
||||
execute "letsencrypt cert for xmpp.5apps.com" do
|
||||
command "./certbot-auto certonly --webroot --agree-tos --email ops@5apps.com --webroot-path #{root_directory} -d xmpp.5apps.com -n"
|
||||
cwd "/usr/local/certbot"
|
||||
not_if { File.exist? "/etc/letsencrypt/live/xmpp.5apps.com/fullchain.pem" }
|
||||
notifies :reload, "service[nginx]", :delayed
|
||||
only_if do
|
||||
File.exist?("#{node['nginx']['dir']}/sites-enabled/xmpp.5apps.com") &&
|
||||
! File.exist?("/etc/letsencrypt/live/xmpp.5apps.com/fullchain.pem")
|
||||
end
|
||||
notifies :create, "template[#{node['nginx']['dir']}/sites-available/xmpp.5apps.com]", :delayed
|
||||
notifies :run, "execute[copy the tls cert to prosody folder]", :delayed
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user