]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/resolv/templates/resolv.conf.erb
and options
[dsa-puppet.git] / modules / resolv / templates / resolv.conf.erb
index 9bc11ba9664e90a63b189e5d328aad840e14ce15..a5291bfad5d09d6da453940c4701491a10040625 100644 (file)
@@ -6,34 +6,37 @@
 <%=
 nameservers = []
 searchpaths = []
-options = []
+options     = []
+resolvconf  = ''
 
-if %w{draghi liszt widor spohr}.include?(hostname)
+if %w{draghi liszt}.include?(hostname)
   nameservers << "127.0.0.1"
 end
 
-nameservers += nodeinfo['hoster']['nameservers'] if nodeinfo['hoster']['nameservers']
-searchpaths += nodeinfo['hoster']['searchpaths'] if nodeinfo['hoster']['searchpaths']
-options += nodeinfo['hoster']['resolvoptions'] if nodeinfo['hoster']['resolvoptions']
+nameservers += scope.lookupvar('ns')
+searchpaths += scope.lookupvar('sp')
+options     += scope.lookupvar('opts')
 
 searchpaths << "debian.org"
 
-resolvconf  = ''
-resolvconf += "search " + searchpaths.join(" ") + "\n"
+resolvconf += "search " + searchpaths.to_a.flatten.join(" ") + "\n"
 
-if runs_local_resolver
+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!"
+    #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.each do |ns|
+  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