Skip to content
Snippets Groups Projects
Commit 019d49f4 authored by Adam Lewenberg's avatar Adam Lewenberg
Browse files

templatize dnsmasq conf file and remove need for cache_packages.pp

parent 99ebef5f
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ class base::dns( ...@@ -25,7 +25,7 @@ class base::dns(
$livermore = false $livermore = false
} }
if !$no_resolv_conf { if (!$no_resolv_conf) {
base::dns::resolv_conf { $::fqdn_lc: base::dns::resolv_conf { $::fqdn_lc:
ensure => present, ensure => present,
dns_cache => $dns_cache, dns_cache => $dns_cache,
......
# This class adds a reference to a local DNS caching server. # This class adds a reference to a local DNS caching server.
class base::dns::cache inherits base::dns { #
include base::dns::cache_packages # NOTE: This class only works with Debian.
#
# $cache_size_entries: the number of entries to cache.
# Default: 10000
# We need daemontools for wheezy servers. class base::dns::cache(
$cache_size_entries = 10000
) inherits base::dns {
if ($::osfamily != 'Debian') {
fail 'base::dns::cache_packages only works with Debian'
}
Base::Dns::Resolv_conf[$::fqdn_lc] { dns_cache => true }
# We use stanford-dnscache for wheezy and dnsmasq for jessie and later.
if ($::lsbdistcodename == 'wheezy') { if ($::lsbdistcodename == 'wheezy') {
# WHEEZY
include base::daemontools include base::daemontools
# Stanford package for DNS caching.
package { 'stanford-dnscache':
ensure => present,
notify => Exec['chown dnslog:dnslog /var/log/dnscache'],
}
# This is required because ownership is wrong on reinstall of packages
# but not on initial install.
exec {'chown dnslog:dnslog /var/log/dnscache':
command => 'chown -R dnslog:dnslog /var/log/dnscache',
refreshonly => true,
}
} else {
# JESSIE and beyond
package { 'dnsmasq':
ensure => present,
}
# Call the template for /etc/dnsmasq.d/stanford-dnscache.conf. This
# template uses the $cache_size_entries class parameter.
file {'/etc/dnsmasq.d/stanford-dnscache.conf':
content => template('base/dns/etc/dnsmasq.d/stanford-dnscache.conf.erb'),
require => Package['dnsmasq'],
notify => Service['dnsmasq'],
}
# Define the service and make sure it runs. Restart the service if
# /etc/resolv.conf changes.
service { 'dnsmasq':
ensure => 'running',
require => Package['dnsmasq'],
subscribe => File['/etc/resolv.conf'],
}
} }
Base::Dns::Resolv_conf[$::fqdn_lc] { dns_cache => true }
} }
# This class only works with Debian. # REMOVE THIS FILE
class base::dns::cache_packages { # NOTE: This class only works with Debian.
# $cache_size_entries: the number of entries to cache.
# Default: 10000
class base::dns::cache_packages(
$cache_size_entries = 10000
){
if ($::osfamily != 'Debian') { if ($::osfamily != 'Debian') {
fail 'base::dns::cache_packages only works with Debian' fail 'base::dns::cache_packages only works with Debian'
...@@ -27,8 +34,10 @@ class base::dns::cache_packages { ...@@ -27,8 +34,10 @@ class base::dns::cache_packages {
ensure => present, ensure => present,
} }
# Call the template for /etc/dnsmasq.d/stanford-dnscache.conf. This
# template uses the $cache_size_entries class parameter.
file {'/etc/dnsmasq.d/stanford-dnscache.conf': file {'/etc/dnsmasq.d/stanford-dnscache.conf':
source => 'puppet:///modules/base/dns/etc/dnsmasq.d/stanford-dnscache.conf', content => template('base/dns/etc/dnsmasq.d/stanford-dnscache.conf')
require => Package['dnsmasq'], require => Package['dnsmasq'],
notify => Service['dnsmasq'], notify => Service['dnsmasq'],
} }
...@@ -41,4 +50,4 @@ class base::dns::cache_packages { ...@@ -41,4 +50,4 @@ class base::dns::cache_packages {
subscribe => File['/etc/resolv.conf'], subscribe => File['/etc/resolv.conf'],
} }
} }
} }
...@@ -4,5 +4,5 @@ listen-address=127.0.0.1 ...@@ -4,5 +4,5 @@ listen-address=127.0.0.1
# really bind only the interfaces it is listening on # really bind only the interfaces it is listening on
bind-interfaces bind-interfaces
# Cache up to 10000 addresses # Cache up to <%= @cache_size_entries %> addresses
cache-size=10000 cache-size=<%= @cache_size_entries %>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment