# # Cookbook Name:: kosmos-akkounts # Recipe:: nginx_api # domain = node["akkounts_api"]["domain"] upstream_hosts = [] search(:node, "role:akkounts").each do |node| upstream_hosts << node["knife_zero"]["host"] end upstream_hosts.push("localhost") if upstream_hosts.empty? tls_cert_for domain do auth "gandi_dns" action :create end openresty_site domain do template "nginx_conf_akkounts_api.erb" 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" end