From: Tom Hughes Date: Sun, 14 Aug 2016 15:45:11 +0000 (+0100) Subject: Don't configure resolv.conf if no nameservers are defined X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/821c29b09ce6a0bd444f89c4cf80c207f2c8df26 Don't configure resolv.conf if no nameservers are defined Fixes #81 --- diff --git a/cookbooks/networking/recipes/default.rb b/cookbooks/networking/recipes/default.rb index 3adc18d6c..2f2812aa9 100644 --- a/cookbooks/networking/recipes/default.rb +++ b/cookbooks/networking/recipes/default.rb @@ -73,18 +73,20 @@ template "/etc/hosts" do mode 0o644 end -link "/etc/resolv.conf" do - action :delete - link_type :symbolic - to "/run/resolvconf/resolv.conf" - only_if { File.symlink?("/etc/resolv.conf") } -end +unless node[:networking][:nameservers].empty? + link "/etc/resolv.conf" do + action :delete + link_type :symbolic + to "/run/resolvconf/resolv.conf" + only_if { File.symlink?("/etc/resolv.conf") } + end -template "/etc/resolv.conf" do - source "resolv.conf.erb" - owner "root" - group "root" - mode 0o644 + template "/etc/resolv.conf" do + source "resolv.conf.erb" + owner "root" + group "root" + mode 0o644 + end end node.interfaces(:role => :internal) do |interface|