31 lines
		
	
	
		
			767 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			767 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
#
 | 
						|
# Cookbook Name:: kosmos-akkounts
 | 
						|
# Recipe:: nginx_api
 | 
						|
#
 | 
						|
 | 
						|
include_recipe "kosmos-nginx"
 | 
						|
domain = node["akkounts_api"]["domain"]
 | 
						|
 | 
						|
nginx_certbot_site domain
 | 
						|
 | 
						|
upstream_hosts = []
 | 
						|
search(:node, "role:akkounts").each do |node|
 | 
						|
  upstream_hosts << node["knife_zero"]["host"]
 | 
						|
end
 | 
						|
 | 
						|
template "#{node["nginx"]["dir"]}/sites-available/#{domain}" do
 | 
						|
  source "nginx_conf_akkounts_api.erb"
 | 
						|
  owner "www-data"
 | 
						|
  mode 0640
 | 
						|
  variables domain: domain,
 | 
						|
            upstream_port: node["akkounts"]["port"],
 | 
						|
            upstream_hosts: upstream_hosts,
 | 
						|
            ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
 | 
						|
            ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem"
 | 
						|
  notifies :reload, "service[nginx]", :delayed
 | 
						|
end
 | 
						|
 | 
						|
nginx_site domain do
 | 
						|
  action :enable
 | 
						|
end
 |