Compare commits

...

5 Commits

Author SHA1 Message Date
Greg Karékinian
5ba700cd00 Add the kosmos-dirsrv recipe to barnard 2019-12-04 17:34:15 +01:00
Greg Karékinian
4e7d453942 Move the firewall and backup recipes outside of the custom resource
See the comment for more details
2019-12-04 17:33:41 +01:00
Greg Karékinian
e24cd01287 Add an empty template because the nginx_certbot_site resource needs one 2019-12-04 17:33:13 +01:00
Greg Karékinian
632cb38aab Pass an empty passphrase on the command line for the p12 cert 2019-12-04 17:32:40 +01:00
Greg Karékinian
9d9493af0d Add a missing dependency on the kosmos-nginx cookbook 2019-12-04 17:32:03 +01:00
4 changed files with 35 additions and 16 deletions

View File

@ -35,6 +35,8 @@
"sockethub::proxy",
"kosmos-akkounts",
"kosmos-akkounts::default",
"kosmos-dirsrv",
"kosmos-dirsrv::default",
"apt::default",
"timezone_iii::default",
"timezone_iii::debian",
@ -75,7 +77,8 @@
"sockethub::_firewall",
"kosmos-akkounts::nginx",
"git::default",
"git::package"
"git::package",
"ulimit::default"
],
"platform": "ubuntu",
"platform_version": "18.04",
@ -107,6 +110,7 @@
"recipe[kosmos-hubot::wormhole]",
"recipe[sockethub]",
"recipe[sockethub::proxy]",
"recipe[kosmos-akkounts]"
"recipe[kosmos-akkounts]",
"recipe[kosmos-dirsrv]"
]
}

View File

@ -11,3 +11,4 @@ depends "firewall"
depends "apt"
depends "ulimit"
depends "backup"
depends "kosmos-nginx"

View File

@ -31,3 +31,21 @@ dirsrv_instance "master" do
admin_password credentials['admin_password']
suffix "dc=kosmos,dc=org"
end
# FIXME: The firewall and backup recipes do not work in the custom resource, so
# the code lives here for now. The issue is described here, but I think messing
# with the run context is confusing:
#
# https://github.com/chef-cookbooks/firewall/issues/134
unless node.chef_environment == "development"
include_recipe "firewall"
firewall_rule "ldap" do
port [389, 636]
protocol :tcp
command :allow
end
# backup the data dir and the config files
node.override["backup"]["archives"]["dirsrv"] = ["/etc/dirsrv", "/var/lib/dirsrv"]
include_recipe "backup"
end

View File

@ -70,8 +70,9 @@ action :create do
action :nothing
end
unless node.chef_environment == "development"
package "libnss3-tools" # provides pk12util
cookbook_file "#{Chef::Config[:file_cache_path]}/tls.ldif" do
source "tls.ldif"
owner "root"
@ -80,6 +81,12 @@ action :create do
include_recipe "kosmos-nginx"
template "#{node['nginx']['dir']}/sites-available/#{new_resource.hostname}" do
source 'nginx_conf_empty.erb'
owner node["nginx"]["user"]
mode 0640
end
nginx_certbot_site new_resource.hostname do
notifies :run, "execute[generate p12 cert]", :immediately
end
@ -87,13 +94,13 @@ action :create do
# Merge the full chain and private key into one cert, to import into the
# dirsrv dir
execute "generate p12 cert" do
command "openssl pkcs12 -export -in /etc/letsencrypt/live/#{new_resource.hostname}/fullchain.pem -inkey /etc/letsencrypt/live/#{new_resource.hostname}/privkey.pem -out #{Chef::Config[:file_cache_path]}/#{new_resource.hostname}.p12 -name 'Server-Cert'"
command "openssl pkcs12 -export -in /etc/letsencrypt/live/#{new_resource.hostname}/fullchain.pem -inkey /etc/letsencrypt/live/#{new_resource.hostname}/privkey.pem -out #{Chef::Config[:file_cache_path]}/#{new_resource.hostname}.p12 -name 'Server-Cert' -passout pass:"
action :nothing
notifies :run, "execute[import p12 cert]", :immediately
end
execute "import p12 cert" do
command "pk12util -i #{Chef::Config[:file_cache_path]}/#{new_resource.hostname}.p12 -d #{inst_dir}"
command "pk12util -i #{Chef::Config[:file_cache_path]}/#{new_resource.hostname}.p12 -d #{inst_dir} -W ''"
action :nothing
notifies :run, "execute[add tls config]", :immediately
end
@ -103,16 +110,5 @@ action :create do
sensitive true
action :nothing
end
include_recipe "firewall"
firewall_rule "ldap" do
port [config[:port], 636]
protocol :tcp
command :allow
end
# backup the data dir and the config files
node.override["backup"]["archives"]["dirsrv"] = ["/etc/dirsrv", "/var/lib/dirsrv"]
include_recipe "backup"
end
end