---
+
+lookup_options:
+ # with merge: unique entries in other hiera sources add to the array
+ searchpaths:
+ merge: unique
+ apt::sources::debian::location:
+ merge: unique
+
nameservers: []
-searchpaths: []
+searchpaths: ['debian.org']
resolvoptions: []
allow_dns_query: []
role_config__mirrors:
letsencrypt_dir: '/srv/puppet.debian.org/from-letsencrypt'
auto_certs_dir: '/srv/puppet.debian.org/ca/RESULT/certs'
auto_clientcerts_dir: '/srv/puppet.debian.org/ca/RESULT/clientcerts'
-
-lookup_options:
- # entries in other hiera sources add to the array
- apt::sources::debian::location:
- merge: unique
apt::sources::debian::location: 'http://deb.debian.org/debian/'
# all of these should be retired in favour of including the class role
class resolv {
- $ns = hiera('nameservers')
- $sp = hiera('searchpaths')
- $opts = hiera('resolvoptions')
+ $nameservers = $facts['unbound'] ? {
+ true => ['127.0.0.1'],
+ default => hiera('nameservers'),
+ }
+
+ $searchpaths = hiera('searchpaths')
+ $resolvoptions = hiera('resolvoptions')
file { '/etc/resolv.conf':
content => template('resolv/resolv.conf.erb');
### USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
###
-<%
-searchpaths = []
-searchpaths += @sp
-searchpaths << "debian.org" -%>
-search <%= searchpaths.to_a.flatten.join(" ") %>
-<%
-nameservers = []
-if %w{draghi}.include?(@hostname)
- nameservers << "127.0.0.1"
-end
-nameservers += @ns
-if @unbound
- nameservers = ['127.0.0.1']
-end
+<%
+nameservers = @nameservers
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 |nms| -%>
-nameserver <%= nms %>
+%>
+
+<% if @searchpaths.size() > 0 %>
+options <%= @searchpaths.join(" ") %>
<% end -%>
-<%
-options = []
-options += @opts -%>
-<% options.to_a.flatten.each do |opt| -%>
-options <%= opt %>
+
+<%= nameservers.map{ |ns| "nameserver #{ns}"}.join("\n") %>
+
+<% if @resolvoptions.size() > 0 %>
+options <%= @searchpaths.join(" ") %>
<% end -%>