From bfff39cc89aef2813a7bf57c42f8300f559ebd9c Mon Sep 17 00:00:00 2001 From: Russ Allbery <rra@stanford.edu> Date: Tue, 9 Jul 2013 14:43:51 -0700 Subject: [PATCH] Fix the inheritance structure of base::dns These classes all need to inherit from each other or the include methods we use don't work properly. Recreate the inheritance structure and use overrides to change the resolv.conf parameters. Also fix a few coding style issues. --- manifests/dns.pp | 83 ++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 49 deletions(-) diff --git a/manifests/dns.pp b/manifests/dns.pp index 4777ad7..684a473 100644 --- a/manifests/dns.pp +++ b/manifests/dns.pp @@ -1,17 +1,14 @@ # Defines the DNS configuration of a system. class base::dns { - base::dns::resolv_conf { "$fqdn": ensure => present } + base::dns::resolv_conf { $::fqdn: ensure => present } } # This class adds a reference to a local DNS caching server. -class base::dns::cache { +class base::dns::cache inherits base::dns { include base::dns::cache_packages - base::dns::resolv_conf { "$fqdn": - ensure => present, - dns_cache => true, - } + Base::Dns::Resolv_conf[$::fqdn] { dns_cache => true } } class base::dns::cache_packages { @@ -31,59 +28,47 @@ 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 { - base::dns::resolv_conf { $fqdn : - ensure => present, - first_dns_server => '204.63.227.68', - } +class base::dns::dr inherits base::dns { + 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 { - include base::dns::cache_packages - - base::dns::resolv_conf { $fqdn : - ensure => present, - dns_cache => true, - first_dns_server => '204.63.227.68', - } +class base::dns::dr-cache inherits base::dns::cache { + Base::Dns::Resolv_conf[$::fqdn] { first_dns_server => '204.63.227.68' } } +# RHEL6 requires a custom resolv.conf to deal with a single-threaded lookup +# bug which reduces performance to a crawl for services like sshd. +# +# TODO: remove EL6 custom resolv.conf when this bug is fixed. define base::dns::resolv_conf ( $ensure = present, $dns_cache = 'NONE', $first_dns_server = 'NONE' ) { - case $ensure { - 'absent': { - file { '/etc/resolv.conf': ensure => absent } - } - 'present': { - # RHEL6 requires a custom resolv.conf to deal with a - # single-threaded lookup bug which reduces performance to a - # crawl for services like sshd. TODO: remove EL6 custom - # resolv.conf when this bug is fixed. - if $::lsbdistcodename == 'santiago' { - $set_dns_options = true - $dns_options = 'single-request-reopen' - } else { - $set_dns_options = false - } - if $dns_cache != 'NONE' { - $set_dns_cache = true - } else { - $set_dns_cache = false - } - if $first_dns_server != 'NONE' { - $set_first_dns_server = true - } else { - $set_first_dns_server = false - } - # resolv.conf is constructed from a template - file { '/etc/resolv.conf': - content => template('base/dns/etc/resolv.conf.erb') - } - } + if $::lsbdistcodename == 'santiago' { + $set_dns_options = true + $dns_options = 'single-request-reopen' + } else { + $set_dns_options = false + } + + if $dns_cache != 'NONE' { + $set_dns_cache = true + } else { + $set_dns_cache = false + } + + if $first_dns_server != 'NONE' { + $set_first_dns_server = true + } else { + $set_first_dns_server = false + } + + # resolv.conf is constructed from a template + file { '/etc/resolv.conf': + ensure => $ensure, + content => template('base/dns/etc/resolv.conf.erb'), } } -- GitLab