]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/unbound/manifests/init.pp
13a6adba300df218760430c870ad5c67fa625c70
[dsa-puppet.git] / modules / unbound / manifests / init.pp
1 class unbound {
2
3         package { 'unbound':
4                 ensure => installed
5         }
6
7         service { 'unbound':
8                 ensure => running,
9                 hasstatus => false,
10                 pattern   => 'unbound',
11         }
12
13         file { '/var/lib/unbound':
14                 ensure  => directory,
15                 owner   => unbound,
16                 group   => unbound,
17                 require => Package['unbound'],
18                 mode    => '0775',
19         }
20         file { '/var/lib/unbound/root.key':
21                 ensure  => present,
22                 replace => false,
23                 owner   => unbound,
24                 group   => unbound,
25                 mode    => '0644',
26                 source  => 'puppet:///modules/unbound/root.key'
27         }
28         file { '/var/lib/unbound/debian.org.key':
29                 ensure  => present,
30                 replace => false,
31                 owner   => unbound,
32                 group   => unbound,
33                 mode    => '0644',
34                 source  => 'puppet:///modules/unbound/debian.org.key'
35         }
36         file { '/etc/unbound/unbound.conf':
37                 content => template('unbound/unbound.conf.erb'),
38                 require => [
39                         Package['unbound'],
40                         File['/var/lib/unbound/root.key'],
41                         File['/var/lib/unbound/debian.org.key']
42                 ],
43                 notify  => Service['unbound']
44         }
45
46         if getfromhash($site::nodeinfo, 'misc', 'resolver-recursive') {
47                 if getfromhash($site::nodeinfo, 'hoster', 'allow_dns_query') {
48                         @ferm::rule { 'dsa-dns':
49                                 domain      => 'ip',
50                                 description => 'Allow nameserver access',
51                                 rule        => sprintf('&TCP_UDP_SERVICE_RANGE(53, (%s))', join_spc(filter_ipv4(getfromhash($site::nodeinfo, 'hoster', 'allow_dns_query')))),
52                         }
53                         @ferm::rule { 'dsa-dns6':
54                                 domain      => 'ip6',
55                                 description => 'Allow nameserver access',
56                                 rule        => sprintf('&TCP_UDP_SERVICE_RANGE(53, (%s))', join_spc(filter_ipv6(getfromhash($site::nodeinfo, 'hoster', 'allow_dns_query')))),
57                         }
58                 }
59         }
60 }