X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/b7c926d43d0e238a1800f16a9679f98cedde9724..7df2b876815f8d466160f6b5bbd0b2cb3c9fb6a8:/cookbooks/networking/recipes/default.rb?ds=sidebyside diff --git a/cookbooks/networking/recipes/default.rb b/cookbooks/networking/recipes/default.rb index 695f19df5..eba2208f5 100644 --- a/cookbooks/networking/recipes/default.rb +++ b/cookbooks/networking/recipes/default.rb @@ -236,6 +236,22 @@ if node[:networking][:wireguard][:enabled] } end + search(:node, "roles:mail") do |server| + allowed_ips = server.interfaces(:role => :internal).map do |interface| + "#{interface[:network]}/#{interface[:prefix]}" + end + + if server[:networking][:private_address] + allowed_ips << "#{server[:networking][:private_address]}/32" + end + + node.default[:networking][:wireguard][:peers] << { + :public_key => server[:networking][:wireguard][:public_key], + :allowed_ips => allowed_ips, + :endpoint => "#{server.name}:51820" + } + end + node.default[:networking][:wireguard][:peers] << { :public_key => "7Oj9ufNlgidyH/xDc+aHQKMjJPqTmD/ab13agMh6AxA=", :allowed_ips => "10.0.16.1/32", @@ -327,9 +343,8 @@ template "/etc/systemd/resolved.conf.d/99-chef.conf" do end if node[:filesystem][:by_mountpoint][:"/etc/resolv.conf"] - mount "/etc/resolv.conf" do - action :umount - device node[:filesystem][:by_mountpoint][:"/etc/resolv.conf"][:devices].first + execute "umount-resolve-conf" do + command "umount -c /etc/resolv.conf" end end @@ -432,12 +447,14 @@ if node[:networking][:firewall][:enabled] action [:enable, :start] supports :restart => true status_command "shorewall status" + ignore_failure true end else service "shorewall" do action [:disable, :stop] supports :restart => true status_command "shorewall status" + ignore_failure true end end @@ -460,9 +477,15 @@ firewall_rule "limit-icmp-echo" do end if node[:networking][:wireguard][:enabled] + wireguard_source = if node[:roles].include?("gateway") + "net" + else + "osm" + end + firewall_rule "accept-wireguard" do action :accept - source "osm" + source wireguard_source dest "fw" proto "udp" dest_ports "51820" @@ -567,12 +590,14 @@ unless node.interfaces(:family => :inet6).empty? action [:enable, :start] supports :restart => true status_command "shorewall6 status" + ignore_failure true end else service "shorewall6" do action [:disable, :stop] supports :restart => true status_command "shorewall6 status" + ignore_failure true end end