Create a nginx_certbot_site resource to remove duplication
It creates a folder, the nginx vhost for certbot and HTTP redirects, and also runs certbot and recreates the nginx vhost that includes the TLS cert
This commit is contained in:
@@ -94,14 +94,7 @@ unless node.chef_environment == "development"
|
||||
|
||||
include_recipe "kosmos-base::letsencrypt"
|
||||
|
||||
include_recipe 'kosmos-nginx'
|
||||
|
||||
directory "/var/www/#{express_domain}/.well-known/acme-challenge" do
|
||||
owner node["nginx"]["user"]
|
||||
group node["nginx"]["group"]
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
include_recipe "kosmos-nginx"
|
||||
|
||||
template "#{node['nginx']['dir']}/sites-available/#{express_domain}" do
|
||||
source 'nginx_conf_hubot.erb'
|
||||
@@ -115,15 +108,8 @@ unless node.chef_environment == "development"
|
||||
end
|
||||
|
||||
nginx_site express_domain do
|
||||
enable true
|
||||
action :enable
|
||||
end
|
||||
|
||||
# FIXME This doesn't actually work on the first run. Apparently nginx is not
|
||||
# reloaded after adding the vhost or sth, because it does work on the second
|
||||
# run.
|
||||
execute "letsencrypt cert for #{express_domain}" do
|
||||
command "/usr/bin/certbot certonly --webroot --agree-tos --email ops@5apps.com --webroot-path /var/www/#{express_domain} -d #{express_domain} -n"
|
||||
not_if { File.exist? "/etc/letsencrypt/live/#{express_domain}/fullchain.pem" }
|
||||
notifies :create, "template[#{node['nginx']['dir']}/sites-available/#{express_domain}]", :immediately
|
||||
end
|
||||
nginx_certbot_site express_domain
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user