Explcitly disable IPv6 on the IC internal network
authorTom Hughes <tom@compton.nu>
Mon, 21 Mar 2016 12:46:27 +0000 (12:46 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 21 Mar 2016 12:46:27 +0000 (12:46 +0000)
cookbooks/networking/recipes/default.rb
cookbooks/networking/templates/default/interfaces.erb
roles/ic.rb

index 39611a9..67d7bcf 100644 (file)
@@ -25,6 +25,7 @@ require "ipaddr"
 node[:networking][:interfaces].each do |name, interface|
   if interface[:role] && (role = node[:networking][:roles][interface[:role]])
     if role[interface[:family]]
+      node.set[:networking][:interfaces][name][:method] = role[interface[:family]][:method]
       node.set[:networking][:interfaces][name][:prefix] = role[interface[:family]][:prefix]
       node.set[:networking][:interfaces][name][:gateway] = role[interface[:family]][:gateway]
     end
@@ -33,12 +34,14 @@ node[:networking][:interfaces].each do |name, interface|
     node.set[:networking][:interfaces][name][:zone] = role[:zone]
   end
 
+  node.set_unless[:networking][:interfaces][name][:method] = "static"
+
+  next unless interface[:address]
+
   prefix = node[:networking][:interfaces][name][:prefix]
 
-  # rubocop:disable Style/RedundantParentheses
   node.set[:networking][:interfaces][name][:netmask] = (~IPAddr.new(interface[:address]).mask(0)).mask(prefix)
   node.set[:networking][:interfaces][name][:network] = IPAddr.new(interface[:address]).mask(prefix)
-  # rubocop:enable Style/RedundantParentheses
 end
 
 template "/etc/network/interfaces" do
index 89fc316..33cc662 100644 (file)
@@ -3,8 +3,10 @@
 iface lo inet loopback
 <% node[:networking][:interfaces].each do |name,interface| -%>
 
-iface <%= interface[:interface] %> <%= interface[:family] %> static
+iface <%= interface[:interface] %> <%= interface[:family] %> <%= interface[:method] %>
+<% if interface[:address] -%>
       address   <%= interface[:address] %>
+<% end -%>
 <% if interface[:family] == "inet" -%>
       netmask   <%= interface[:netmask] %>
 <% elsif interface[:family] == "inet6" -%>
index af78c9f..ea4d17b 100644 (file)
@@ -14,6 +14,9 @@ default_attributes(
         :inet => {
           :prefix => "27",
           :gateway => "146.179.159.177"
+        },
+        :inet6 => {
+          :method => "manual"
         }
       },
       :external => {