resolv.conf cleanup, fix 1
[mirror/dsa-puppet.git] / modules / resolv / templates / resolv.conf.erb
index a5291bf..6e02dbb 100644 (file)
@@ -3,42 +3,24 @@
 ### USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
 ###
 
-<%=
-nameservers = []
-searchpaths = []
-options     = []
-resolvconf  = ''
 
-if %w{draghi liszt}.include?(hostname)
-  nameservers << "127.0.0.1"
-end
-
-nameservers += scope.lookupvar('ns')
-searchpaths += scope.lookupvar('sp')
-options     += scope.lookupvar('opts')
+<%
+nameservers = @nameservers
 
-searchpaths << "debian.org"
-
-resolvconf += "search " + searchpaths.to_a.flatten.join(" ") + "\n"
+if nameservers.empty?
+  scope.function_warning(["Something has gone wrong writing resolv.conf.  No nameservers to use - using google's!"])
+  nameservers << '8.8.8.8'
+  nameservers << '8.8.4.4'
+end
 
-if has_variable?('unbound') and unbound and unbound == "true"
-  resolvconf += "nameserver 127.0.0.1\n"
-else
-  if nameservers.empty?
-    #raise Puppet::ParseError, "Something has gone wrong writing resolv.conf.  No nameservers to use!"
-    scope.function_warning(["Something has gone wrong writing resolv.conf.  No nameservers to use - using google's!"])
-    nameservers << '8.8.8.8'
-    nameservers << '8.8.4.4'
-  end
+%>
 
-  nameservers.to_a.flatten.each do |ns|
-    resolvconf += "nameserver " + ns + "\n"
-  end
-end
+<% if @searchpaths.size() > 0 %>
+search <%= @searchpaths.join(" ") %>
+<% end -%>
 
-options.to_a.flatten.each do |opt|
-  resolvconf += "options " + opt + "\n"
-end
+<%= nameservers.map{ |ns| "nameserver #{ns}"}.join("\n") %>
 
-resolvconf
-%>
+<% if @resolvoptions.size() > 0 %>
+options <%= @searchpaths.join(" ") %>
+<% end -%>