Add kosmos_strfry cookbook, configs
This commit is contained in:
13
site-cookbooks/kosmos_strfry/recipes/firewall.rb
Normal file
13
site-cookbooks/kosmos_strfry/recipes/firewall.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Cookbook Name:: kosmos_strfry
|
||||
# Recipe:: firewall
|
||||
#
|
||||
|
||||
include_recipe "kosmos-base::firewall"
|
||||
|
||||
firewall_rule "strfry" do
|
||||
port node["strfry"]["port"]
|
||||
source "10.1.1.0/24"
|
||||
protocol :tcp
|
||||
command :allow
|
||||
end
|
||||
29
site-cookbooks/kosmos_strfry/recipes/nginx.rb
Normal file
29
site-cookbooks/kosmos_strfry/recipes/nginx.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# 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
|
||||
Reference in New Issue
Block a user