]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/networking/recipes/default.rb
Attempt to fix test failures caused by crazy docker networking
[chef.git] / cookbooks / networking / recipes / default.rb
index 116d90c726d19a769757871734bdcaf1212106f0..fa3f97d00f6a6230416101d88a0f230c3c1119d6 100644 (file)
@@ -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",
@@ -326,15 +342,9 @@ template "/etc/systemd/resolved.conf.d/99-chef.conf" do
   notifies :restart, "service[systemd-resolved]", :immediately
 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
-  end
-end
-
 link "/etc/resolv.conf" do
   to "../run/systemd/resolve/stub-resolv.conf"
+  not_if { ENV["TEST_KITCHEN"] }
 end
 
 zones = {}
@@ -460,9 +470,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 "net"
+    source wireguard_source
     dest "fw"
     proto "udp"
     dest_ports "51820"