]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/exim/recipes/default.rb
Estabish tunnels between shenron and gateway machines
[chef.git] / cookbooks / exim / recipes / default.rb
index 6234aa96412ab3034b1f5cbf3b0a6540efaef7a4..994e9454b5caa1d5e093dc4c176927698daef855 100644 (file)
@@ -76,6 +76,18 @@ end
 relay_from_hosts = node[:exim][:relay_from_hosts]
 
 if node[:exim][:smarthost_name]
+  search(:node, "roles:gateway") do |gateway|
+    allowed_ips = gateway.interfaces(:role => :internal).map do |interface|
+      "#{interface[:network]}/#{interface[:prefix]}"
+    end
+
+    node.default[:networking][:wireguard][:peers] << {
+      :public_key => gateway[:networking][:wireguard][:public_key],
+      :allowed_ips => allowed_ips,
+      :endpoint => "#{gateway.name}:51820"
+    }
+  end
+
   search(:node, "exim_smarthost_via:#{node[:exim][:smarthost_name]}\\:*").each do |host|
     relay_from_hosts |= host.ipaddresses(:role => :external)
   end