Puppet Class: nsd

Defined in:
manifests/init.pp

Overview

Class: nsd

Installs and configures NSD, the authoritative DNS resolver from NLnet Labs

Parameters:

  • config_d (String)
  • config_file (String)
  • service_name (String)
  • package_name (Variant[String,Undef])
  • control_cmd (String)
  • zonedir (String)
  • zonepurge (Boolean)
  • group (String)
  • owner (String)
  • database (String)
  • verbosity (Integer) (defaults to: 0)
  • port (Integer) (defaults to: 53)
  • interface (Array[Stdlib::Ip::Address]) (defaults to: ['::0','0.0.0.0'])
  • logfile (Optional[String]) (defaults to: undef)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
# File 'manifests/init.pp', line 5

class nsd (
  String $config_d,
  String $config_file,
  String $service_name,
  Variant[String,Undef] $package_name,
  String $control_cmd,
  String $zonedir,
  Boolean $zonepurge, # purge of unmanaged zone files
  String $group,
  String $owner,
  String $database,
  Integer $verbosity                    = 0,
  Integer $port                         = 53,
  Array[Stdlib::Ip::Address] $interface = ['::0','0.0.0.0'],
  Optional[String] $logfile             = undef,
) {
  if $package_name {
    package { $package_name:
      ensure => installed,
      before => [
        Concat[$config_file],
        Service[$service_name],
      ],
    }
  }

  service { $service_name:
    ensure  => running,
    name    => $service_name,
    enable  => true,
    require => [
      Concat[$config_file],
    ],
  }

  concat { $config_file:
    owner  => 'root',
    group  => $group,
    mode   => '0640',
    notify => Service[$service_name],
  }

  concat::fragment { 'nsd-header':
    order   => '00',
    target  => $config_file,
    content => template('nsd/nsd.conf.erb'),
  }

  exec { 'nsd-control-setup':
    command => 'nsd-control-setup',
    creates => "${config_d}/nsd_control.pem",
  }

  exec { 'nsd-control reload':
    command     => 'nsd-control reload',
    refreshonly => true,
    require     => Service[$service_name],
  }

  exec { 'nsd-control reconfig':
    command     => 'nsd-control reconfig',
    refreshonly => true,
    require     => Service[$service_name],
  }

  file { $zonedir:
    ensure  => directory,
    owner   => 'root',
    group   => $group,
    mode    => '0750',
    purge   => $zonepurge,
    recurse => true,
  }
}