]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/resolv/templates/resolv.conf.erb
no more lenny
[dsa-puppet.git] / modules / resolv / templates / resolv.conf.erb
index 99d8c0a64bc27e91b49c32e03eb87fea78110da8..2e1968b639785d625a38b1cd0e45ffbf58e5ad7d 100644 (file)
@@ -6,28 +6,37 @@
 <%=
 nameservers = []
 searchpaths = []
-options = []
+options     = []
+resolvconf  = ''
 
-if %w{draghi liszt widor spohr samosa}.include?(hostname)
+if %w{draghi}.include?(hostname)
   nameservers << "127.0.0.1"
 end
 
-nameservers += hosterinfo['nameservers'] if hosterinfo['nameservers']
-searchpaths += hosterinfo['searchpaths'] if hosterinfo['searchpaths']
-options += hosterinfo['resolvoptions'] if hosterinfo['resolvoptions']
+nameservers += scope.lookupvar('ns')
+searchpaths += scope.lookupvar('sp')
+options     += scope.lookupvar('opts')
 
 searchpaths << "debian.org"
 
-if nameservers.empty?
-  raise Puppet::ParseError, "Something has gone wrong writing resolv.conf: probably included for wrong hoster"
-end
+resolvconf += "search " + searchpaths.to_a.flatten.join(" ") + "\n"
 
-resolvconf  = ''
-resolvconf += "search " + searchpaths.join(" ") + "\n"
-nameservers.each do |ns|
-  resolvconf += "nameserver " + ns + "\n"
+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
-options.each do |opt|
+
+options.to_a.flatten.each do |opt|
   resolvconf += "options " + opt + "\n"
 end