Merge pull request 'Use the right variable for the TLS cert's domain in kosmos-dirsrv's instance resource' (#194) from bugfix/193-dirsrv_undefined_var into master

This commit is contained in:
Râu Cao 2020-07-22 14:16:53 +00:00
commit 3563b05932

View File

@ -157,16 +157,16 @@ done
end end
nginx_certbot_site new_resource.hostname do nginx_certbot_site new_resource.hostname do
notifies :run, "execute[letsencrypt cert for #{domain}]", :delayed notifies :run, "execute[letsencrypt cert for #{new_resource.hostname}]", :delayed
end end
# Generate a Let's Encrypt cert (only if the nginx vhost exists and no cert # 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 # has been generated before. The renew cron will take care of renewing
execute "letsencrypt cert for #{domain}" do execute "letsencrypt cert for #{new_resource.hostname}" do
command "/usr/bin/certbot certonly --webroot --agree-tos --email ops@kosmos.org --webroot-path #{root_directory} --deploy-hook /etc/letsencrypt/renewal-hooks/deploy/dirsrv -d #{domain} -n" command "/usr/bin/certbot certonly --webroot --agree-tos --email ops@kosmos.org --webroot-path #{root_directory} --deploy-hook /etc/letsencrypt/renewal-hooks/deploy/dirsrv -d #{new_resource.hostname} -n"
only_if do only_if do
::File.exist?("#{node['nginx']['dir']}/sites-enabled/#{domain}_certbot") && ::File.exist?("#{node['nginx']['dir']}/sites-enabled/#{new_resource.hostname}_certbot") &&
!::File.exist?("/etc/letsencrypt/live/#{domain}/fullchain.pem") !::File.exist?("/etc/letsencrypt/live/#{new_resource.hostname}/fullchain.pem")
end end
notifies :run, "execute[add tls config]", :immediately notifies :run, "execute[add tls config]", :immediately
end end