X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/2bd7d1dd8dcc3abb3eda77447182fda66c631ae6..0044078ddc06dac65be8e6405e3bb0f54d63d5b7:/cookbooks/networking/recipes/default.rb diff --git a/cookbooks/networking/recipes/default.rb b/cookbooks/networking/recipes/default.rb index 38c2156f2..5c73c5cc3 100644 --- a/cookbooks/networking/recipes/default.rb +++ b/cookbooks/networking/recipes/default.rb @@ -48,10 +48,12 @@ node[:networking][:interfaces].each do |name, interface| node.normal[:networking][:interfaces][name][:zone] = role[:zone] end - prefix = node[:networking][:interfaces][name][:prefix] + if interface[:address] + prefix = node[:networking][:interfaces][name][:prefix] - node.normal[:networking][:interfaces][name][:netmask] = (~IPAddr.new(interface[:address]).mask(0)).mask(prefix) - node.normal[:networking][:interfaces][name][:network] = IPAddr.new(interface[:address]).mask(prefix) + node.normal[:networking][:interfaces][name][:netmask] = (~IPAddr.new(interface[:address]).mask(0)).mask(prefix) + node.normal[:networking][:interfaces][name][:network] = IPAddr.new(interface[:address]).mask(prefix) + end interface = node[:networking][:interfaces][name] @@ -77,7 +79,9 @@ node[:networking][:interfaces].each do |name, interface| } end - deviceplan["addresses"].push("#{interface[:address]}/#{prefix}") + if interface[:address] + deviceplan["addresses"].push("#{interface[:address]}/#{prefix}") + end if interface[:mtu] deviceplan["mtu"] = interface[:mtu] @@ -182,8 +186,8 @@ ohai "reload-hostname" do plugin "hostname" end -execute "hostnamectl-set-static" do - command "hostnamectl set-static #{node[:networking][:hostname]}" +execute "hostnamectl-set-hostname" do + command "hostnamectl set-hostname #{node[:networking][:hostname]}" notifies :reload, "ohai[reload-hostname]" not_if { ENV.key?("TEST_KITCHEN") || node[:hostnamectl][:static_hostname] == node[:networking][:hostname] } end