more ordering
[mirror/dsa-puppet.git] / modules / resolv / templates / resolv.conf.erb
1 ##
2 ### THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
3 ### USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
4 ###
5
6 <%=
7 nameservers = []
8 searchpaths = []
9 options     = []
10 resolvconf  = ''
11
12 if %w{draghi liszt}.include?(hostname)
13   nameservers << "127.0.0.1"
14 end
15
16 nameservers += scope.lookupvar('ns')
17 searchpaths += scope.lookupvar('sp')
18 options     += scope.lookupvar('opts')
19
20 searchpaths << "debian.org"
21
22 resolvconf += "search " + searchpaths.to_a.flatten.join(" ") + "\n"
23
24 if has_variable?('unbound') and unbound and unbound == "true"
25   resolvconf += "nameserver 127.0.0.1\n"
26 else
27   if nameservers.empty?
28     #raise Puppet::ParseError, "Something has gone wrong writing resolv.conf.  No nameservers to use!"
29     scope.function_warning(["Something has gone wrong writing resolv.conf.  No nameservers to use - using google's!"])
30     nameservers << '8.8.8.8'
31     nameservers << '8.8.4.4'
32   end
33
34   nameservers.to_a.flatten.each do |ns|
35     resolvconf += "nameserver " + ns + "\n"
36   end
37 end
38
39 options.to_a.flatten.each do |opt|
40   resolvconf += "options " + opt + "\n"
41 end
42
43 resolvconf
44 %>