Puppet Class: named::caching

Defined in:
manifests/caching.pp

Summary

Configures a caching nameserver.

Overview

You will need to call named::caching::forwarders to make it useful.

There is also named::caching::root_hints which allows you to set the entire contents of the ‘named.ca’ hint file.

If you want something other than the defaults provided here, use the main named class.

Parameters:

  • chroot_path (Stdlib::Absolutepath)

    The path to the chroot location.

    • Has no effect if SELinux is enforcing.

    • Defaults to ‘named::chroot_path` per module Hiera data.

Author:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'manifests/caching.pp', line 19

class named::caching(
  Stdlib::Absolutepath $chroot_path
) {

  if defined(Class['named']) {
    fail('You cannot include both ::named and ::named::caching')
  }

  simplib::assert_metadata($module_name)

  # Some trickery to use common file resources for chrooted/non chrooted
  # caching files
  $selinux = str2bool($facts['os']['selinux']['enforced'])
  $_chroot_path = $selinux ? {
    true  => '',
    false => $chroot_path
  }

  # Installation and service
  if !empty($_chroot_path) {
    file_line { 'bind_chroot':
      path      => '/etc/sysconfig/named',
      line      => "OPTIONS=\"-t ${_chroot_path}\"",
      before    => Class['named::service'],
      subscribe => Package['bind-chroot']
    }
    file { '/etc/named.conf':
      ensure => 'symlink',
      target => "${_chroot_path}/etc/named.conf",
      notify => Class['named::service']
    }
  }
  class { 'named::install':
    chroot      => !empty($_chroot_path),
    chroot_path => $chroot_path
  }
  class { 'named::service':
    chroot      => !empty($_chroot_path),
    chroot_path => $chroot_path
  }
  Class['named::install'] -> Class['named::caching']
  Class['named::install'] ~> Class['named::service']

  concat { 'named_caching':
    order  => numeric,
    notify => Class['named::service'],
    owner  => 'root',
    group  => 'named',
    mode   => '0640',
    path   => "${_chroot_path}/etc/named_caching.forwarders"
  }

  concat_fragment { 'named_caching+header':
    order   => 0,
    target  => 'named_caching',
    content => 'forwarders {'
  }

  concat_fragment { 'named_caching+footer':
    order   => 100,
    target  => 'named_caching',
    content => '};'
  }

  file { "${_chroot_path}/etc/named.rfc1912.zones":
    ensure => 'file',
    owner  => 'root',
    group  => 'named',
    mode   => '0640',
    source => 'puppet:///modules/named/chroot/etc/named.rfc1912.zones',
    notify => Class['named::service']
  }

  file { "${_chroot_path}/var/named/data":
    ensure => 'directory',
    owner  => 'named',
    group  => 'named',
    mode   => '0750',
    before => Class['named::service']
  }

  file { "${_chroot_path}/var/named/localdomain.zone":
    ensure => 'file',
    owner  => 'root',
    group  => 'named',
    mode   => '0640',
    source => 'puppet:///modules/named/chroot/var/named/localdomain.zone',
    notify => Class['named::service']
  }

  file { "${_chroot_path}/var/named/localhost.zone":
    ensure => 'file',
    owner  => 'root',
    group  => 'named',
    mode   => '0640',
    source => 'puppet:///modules/named/chroot/var/named/localhost.zone',
    notify => Class['named::service']
  }

  file { "${_chroot_path}/var/named/named.broadcast":
    ensure => 'file',
    owner  => 'root',
    group  => 'named',
    mode   => '0640',
    source => 'puppet:///modules/named/chroot/var/named/named.broadcast',
    notify => Class['named::service']
  }

  file { "${_chroot_path}/var/named/named.ip6.local":
    ensure => 'file',
    owner  => 'root',
    group  => 'named',
    mode   => '0640',
    source => 'puppet:///modules/named/chroot/var/named/named.ip6.local',
    notify => Class['named::service']
  }

  file { "${_chroot_path}/var/named/named.local":
    ensure => 'file',
    owner  => 'root',
    group  => 'named',
    mode   => '0640',
    source => 'puppet:///modules/named/chroot/var/named/named.local',
    notify => Class['named::service']
  }

  file { "${_chroot_path}/var/named/named.zero":
    ensure => 'file',
    owner  => 'root',
    group  => 'named',
    mode   => '0644',
    source => 'puppet:///modules/named/chroot/var/named/named.zero',
    notify => Class['named::service']
  }

  file { "${_chroot_path}/etc/named.conf":
    ensure  => 'file',
    owner   => 'root',
    group   => 'named',
    mode    => '0640',
    content => template('named/named.caching.conf.erb'),
    notify  => Class['named::service']
  }


}