]> git.openstreetmap.org Git - chef.git/commitdiff
Don't configure resolv.conf if no nameservers are defined
authorTom Hughes <tom@compton.nu>
Sun, 14 Aug 2016 15:45:11 +0000 (16:45 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 14 Aug 2016 15:45:11 +0000 (16:45 +0100)
Fixes #81

cookbooks/networking/recipes/default.rb

index 3adc18d6c367846583c92f4e515516b45b518883..2f2812aa9cb4e01d20f84d659a701e86ea755aab 100644 (file)
@@ -73,18 +73,20 @@ template "/etc/hosts" do
   mode 0o644
 end
 
   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|
 end
 
 node.interfaces(:role => :internal) do |interface|