summaryrefslogtreecommitdiff
path: root/puppet/modules/site_openvpn/manifests/resolver.pp
blob: cea0153afe758f9e5017ce312f79783b033ec51c (plain)
1
2
3
4
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
class site_openvpn::resolver {

  if $site_openvpn::openvpn_allow_unlimited {
    $ensure_unlimited = 'present'
    file {
      '/etc/unbound/unbound.conf.d/vpn_unlimited_udp_resolver.conf':
        content => "server:\n\tinterface: ${site_openvpn::openvpn_unlimited_udp_network_prefix}.1\n\taccess-control: ${site_openvpn::openvpn_unlimited_udp_network_prefix}.0/${site_openvpn::openvpn_unlimited_udp_cidr} allow\n",
        owner   => root,
        group   => root,
        mode    => '0644',
        require => [ Class['site_config::caching_resolver'], Service['openvpn'] ],
        notify  => Service['unbound'];
      '/etc/unbound/unbound.conf.d/vpn_unlimited_tcp_resolver.conf':
        content => "server:\n\tinterface: ${site_openvpn::openvpn_unlimited_tcp_network_prefix}.1\n\taccess-control: ${site_openvpn::openvpn_unlimited_tcp_network_prefix}.0/${site_openvpn::openvpn_unlimited_tcp_cidr} allow\n",
        owner   => root,
        group   => root,
        mode    => '0644',
        require => [ Class['site_config::caching_resolver'], Service['openvpn'] ],
        notify  => Service['unbound'];
    }
  } else {
    $ensure_unlimited = 'absent'
    tidy { '/etc/unbound/unbound.conf.d/vpn_unlimited_udp_resolver.conf': }
    tidy { '/etc/unbound/unbound.conf.d/vpn_unlimited_tcp_resolver.conf': }
  }

  if $site_openvpn::openvpn_allow_limited {
    $ensure_limited = 'present'
    file {
      '/etc/unbound/unbound.conf.d/vpn_limited_udp_resolver.conf':
        content => "server:\n\tinterface: ${site_openvpn::openvpn_limited_udp_network_prefix}.1\n\taccess-control: ${site_openvpn::openvpn_limited_udp_network_prefix}.0/${site_openvpn::openvpn_limited_udp_cidr} allow\n",
        owner   => root,
        group   => root,
        mode    => '0644',
        require => [ Class['site_config::caching_resolver'], Service['openvpn'] ],
        notify  => Service['unbound'];
      '/etc/unbound/unbound.conf.d/vpn_limited_tcp_resolver.conf':
        content => "server\n\tinterface: ${site_openvpn::openvpn_limited_tcp_network_prefix}.1\n\taccess-control: ${site_openvpn::openvpn_limited_tcp_network_prefix}.0/${site_openvpn::openvpn_limited_tcp_cidr} allow\n",
        owner   => root,
        group   => root,
        mode    => '0644',
        require => [ Class['site_config::caching_resolver'], Service['openvpn'] ],
        notify  => Service['unbound'];
    }
  } else {
    $ensure_limited = 'absent'
    tidy { '/etc/unbound/unbound.conf.d/vpn_limited_udp_resolver.conf': }
    tidy { '/etc/unbound/unbound.conf.d/vpn_limited_tcp_resolver.conf': }
  }
}