]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/unbound/manifests/init.pp
3a0eeb34ec8bdac2b009f6ca659221decc963466
[dsa-puppet.git] / modules / unbound / manifests / init.pp
1 # = Class: unbound
2 #
3 # This class installs and configures unbound
4 #
5 # == Sample Usage:
6 #
7 #   include unbound
8 #
9 class unbound {
10
11         $is_recursor   = getfromhash($site::nodeinfo, 'misc', 'resolver-recursive')
12         $client_ranges = hiera('allow_dns_query')
13         $empty_client_range = empty($client_ranges)
14         $ns            = hiera('nameservers')
15
16         package { 'unbound':
17                 ensure => installed
18         }
19
20         service { 'unbound':
21                 ensure => running,
22                 hasstatus => false,
23                 pattern   => 'unbound',
24         }
25
26         file { '/var/lib/unbound':
27                 ensure  => directory,
28                 owner   => unbound,
29                 group   => unbound,
30                 require => Package['unbound'],
31                 mode    => '0775',
32         }
33         file { '/var/lib/unbound/root.key':
34                 ensure  => present,
35                 replace => false,
36                 owner   => unbound,
37                 group   => unbound,
38                 mode    => '0644',
39                 source  => 'puppet:///modules/unbound/root.key'
40         }
41         file { '/var/lib/unbound/debian.org.key':
42                 ensure  => present,
43                 replace => false,
44                 owner   => unbound,
45                 group   => unbound,
46                 mode    => '0644',
47                 source  => 'puppet:///modules/unbound/debian.org.key'
48         }
49         file { '/var/lib/unbound/29.172.in-addr.arpa.key':
50                 ensure  => present,
51                 replace => false,
52                 owner   => unbound,
53                 group   => unbound,
54                 mode    => '0644',
55                 source  => 'puppet:///modules/unbound/29.172.in-addr.arpa.key'
56         }
57         file { '/etc/unbound/unbound.conf':
58                 content => template('unbound/unbound.conf.erb'),
59                 require => [
60                         Package['unbound'],
61                         File['/var/lib/unbound/root.key'],
62                         File['/var/lib/unbound/debian.org.key']
63                 ],
64                 notify  => Service['unbound']
65         }
66
67         if ($is_recursor and !$empty_client_range) { 
68                 @ferm::rule { 'dsa-dns':
69                         domain      => 'ip',
70                         description => 'Allow nameserver access',
71                         rule        => sprintf('&TCP_UDP_SERVICE_RANGE(53, (%s))', join_spc(filter_ipv4($client_ranges))),
72                 }
73                 @ferm::rule { 'dsa-dns6':
74                         domain      => 'ip6',
75                         description => 'Allow nameserver access',
76                         rule        => sprintf('&TCP_UDP_SERVICE_RANGE(53, (%s))', join_spc(filter_ipv6($client_ranges))),
77                 }
78         }
79 }