X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fresolv%2Ftemplates%2Fresolv.conf.erb;h=a5291bfad5d09d6da453940c4701491a10040625;hb=0a16104c67b3db4edef34356c7f31492d391a70b;hp=4e9f7650c588e0c184acbea08ad07c1cc2258f2d;hpb=2e8e944225660df69ce7767e9374995c35c4d748;p=mirror%2Fdsa-puppet.git diff --git a/modules/resolv/templates/resolv.conf.erb b/modules/resolv/templates/resolv.conf.erb index 4e9f7650c..a5291bfad 100644 --- a/modules/resolv/templates/resolv.conf.erb +++ b/modules/resolv/templates/resolv.conf.erb @@ -6,34 +6,37 @@ <%= nameservers = [] searchpaths = [] -options = [] +options = [] +resolvconf = '' -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'] -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 = '' -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 - nameservers.each do |ns| + 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