30 lines
		
	
	
		
			714 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			714 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
#
 | 
						|
# Cookbook Name:: kosmos_strfry
 | 
						|
# Recipe:: nginx
 | 
						|
#
 | 
						|
 | 
						|
domain = node["strfry"]["domain"]
 | 
						|
 | 
						|
upstream_hosts = []
 | 
						|
search(:node, 'role:strfry').each do |node|
 | 
						|
  upstream_hosts << node['knife_zero']['host']
 | 
						|
end
 | 
						|
if upstream_hosts.empty?
 | 
						|
  Chef::Log.warn("No node found with 'strfry' role. Not configuring nginx site.")
 | 
						|
  return
 | 
						|
end
 | 
						|
 | 
						|
tls_cert_for domain do
 | 
						|
  auth "gandi_dns"
 | 
						|
  action :create
 | 
						|
end
 | 
						|
 | 
						|
openresty_site domain do
 | 
						|
  template "nginx_conf_strfry.erb"
 | 
						|
  variables domain: domain,
 | 
						|
            upstream_port: node['strfry']['port'],
 | 
						|
            upstream_hosts: upstream_hosts,
 | 
						|
            ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
 | 
						|
            ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem"
 | 
						|
end
 |