From 082a9af871d66a542e045d9bdf0ea7e6b1a23b50 Mon Sep 17 00:00:00 2001
From: Meei You Lee <meeilee@stanford.edu>
Date: Mon, 10 Feb 2014 15:54:56 -0800
Subject: [PATCH] base:  add code to generate reoslv.conf for DNS servers

---
 NEWS                              | 12 +++++++++
 manifests/dns.pp                  | 23 ++++++++++++-----
 templates/dns/etc/resolv.conf.erb | 43 ++++++++++++++++++++++++++++++-
 3 files changed, 70 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index 7bcb94a..31b1d50 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,15 @@
+        amd64        AFS distributed filesystem client support
+ii  openafs-krb5                          1.6.5.2-1~bpo70+1                amd64        AFS distributed filesystem Kerberos 5 integration
+ii  openafs-modules-3.2.0-4-amd64         1.6.5-1~bpo70+1+3.2.46-1         amd64        AFS distributed filesystem kernel module
+pisa-test:~>  exit
+logout
+Connection to pisa-test closed.
+(rootpag) luckdragon:~/base> ls
+NEWS  TODO  files  lib  manifests  templates
+(rootpag) luckdragon:~/base> vi NEWS
+
+unreleased 
+   add code to generate different  resolv.conf for DNS servers. (meeile)
 release/003.008 (2014-02-05)
 
     Update comment documentation in base::pam::workgroup.  Remove 
diff --git a/manifests/dns.pp b/manifests/dns.pp
index 40d2355..1b2e268 100644
--- a/manifests/dns.pp
+++ b/manifests/dns.pp
@@ -30,17 +30,21 @@ class base::dns::cache_packages {
 # This class is for servers at Livermore.  The resolv.conf puts the
 # Livermore dns server first in the search list.
 class base::dns::dr inherits base::dns {
-  # Commented out until the server out there returns.
   Base::Dns::Resolv_conf[$::fqdn] { first_dns_server => '204.63.227.68' }
 }
 
-# This class is for servers at Livermore.  The resolv.conf puts the
-# local caching server first and includes Livermore dns server.
-class base::dns::dr-cache inherits base::dns::cache {
-  # Commented out until the server out there returns.
+
+class base::dns::dr inherits base::dns {
   Base::Dns::Resolv_conf[$::fqdn] { first_dns_server => '204.63.227.68' }
 }
 
+
+# This class is for domain name servers.  
+class base::dns::dns-server inherits base::dns {
+  Base::Dns::Resolv_conf[$::fqdn] { is_dns_server  => ture  }
+
+}
+
 # RHEL6 requires a custom resolv.conf to deal with a single-threaded lookup
 # bug which reduces performance to a crawl for services like sshd.
 #
@@ -48,7 +52,8 @@ class base::dns::dr-cache inherits base::dns::cache {
 define base::dns::resolv_conf (
   $ensure           = present,
   $dns_cache        = 'NONE',
-  $first_dns_server = 'NONE'
+  $first_dns_server = 'NONE',
+  $is_dns_server    = false ,
 ) {
   if $::lsbdistcodename == 'santiago' {
     $set_dns_options = true
@@ -70,8 +75,12 @@ define base::dns::resolv_conf (
   }
 
   # resolv.conf is constructed from a template
+  if  $is_dns_server  {
+    $dns_server_name=$::hostname
+  }
+
   file { '/etc/resolv.conf':
     ensure  => $ensure,
     content => template('base/dns/etc/resolv.conf.erb'),
-  }
+  } 
 }
diff --git a/templates/dns/etc/resolv.conf.erb b/templates/dns/etc/resolv.conf.erb
index 6f433b5..7228c69 100644
--- a/templates/dns/etc/resolv.conf.erb
+++ b/templates/dns/etc/resolv.conf.erb
@@ -1,3 +1,43 @@
+<% if is_dns_server -%>
+# Standard resolver configuration file for DNS servers
+# Do not change the order of 'nameserver' lines
+#
+domain stanford.edu
+search stanford.edu sunet
+
+# Standard DNS serveers
+<% case dns_server_name 
+when 'calypso' %>
+nameserver 204.63.227.68
+nameserver 171.64.7.121
+nameserver 171.64.7.55
+<% when  'caribou' %>
+nameserver 204.63.227.68
+nameserver 171.64.7.121
+nameserver 171.64.7.77
+<% when 'cassandra' %>
+nameserver 171.64.7.121
+nameserver 171.64.7.99
+nameserver 171.64.7.55
+<% when 'cicci' %>
+nameserver 171.64.7.77
+nameserver 171.64.7.99
+nameserver 171.64.7.55
+<% when 'cilantro' %>
+nameserver 171.64.7.121
+nameserver 171.64.7.77
+nameserver 171.64.7.55
+<% when 'roll','rock', 'aerathea'  %>
+nameserver 4.2.2.4
+nameserver 4.2.2.2
+nameserver 4.2.2.6
+<% else %>
+nameserver 171.64.7.121
+nameserver 171.64.7.77
+nameserver 171.64.7.99
+nameserver 171.64.7.5
+<% end %>
+<% else %>
 # Standard resolver configuration file
 
 domain stanford.edu
@@ -18,7 +58,8 @@ nameserver 171.64.7.55
 # Stanford anycast DNS servers
 nameserver 171.64.1.234
 nameserver 171.67.1.234
-<% if set_dns_options -%>
+<% end %>
 
+<% if set_dns_options -%>
 options <%= dns_options %>
 <% end -%>
-- 
GitLab