]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/resolv/templates/resolv.conf.erb
try the hiera way of getting this info
[dsa-puppet.git] / modules / resolv / templates / resolv.conf.erb
index 4f7cd63da7937e41a8ce778a34f8325a274aedc8..2ca70739f6a8c2199e11ad24194bccbd5de85128 100644 (file)
@@ -6,24 +6,38 @@
 <%=
 nameservers = []
 searchpaths = []
-resolvconf  = ''
+options = []
 
-if %w{draghi liszt widor spohr samosa}.include?(hostname)
+if %w{draghi liszt}.include?(hostname)
   nameservers << "127.0.0.1"
 end
 
-nameservers += hosterinfo['nameservers'] if hosterinfo['nameservers']
-searchpaths += hosterinfo['searchpaths'] if hosterinfo['searchpaths']
+nameservers += scope.lookupvar('ns')
+searchpaths += scope.lookupvar('site::nodeinfo')['hoster']['searchpaths'] if scope.lookupvar('site::nodeinfo')['hoster']['searchpaths']
+options += scope.lookupvar('site::nodeinfo')['hoster']['resolvoptions'] if scope.lookupvar('site::nodeinfo')['hoster']['resolvoptions']
 
 searchpaths << "debian.org"
 
-if nameservers.empty?
-  raise Puppet::ParseError, "Something has gone wrong writing resolv.conf: probably included for wrong hoster"
+resolvconf  = ''
+resolvconf += "search " + searchpaths.join(" ") + "\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
 
-resolvconf += "search " + searchpaths.join(" ") + "\n"
-nameservers.each do |ns|
-  resolvconf += "nameserver " + ns + "\n"
+options.each do |opt|
+  resolvconf += "options " + opt + "\n"
 end
 
 resolvconf