aboutsummaryrefslogtreecommitdiffstats
path: root/modules/bind/manifests/init.pp
blob: 44ca191aaba0c37a12563490df3f3e02bf211ac7 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class bind {
    class bind_base {
        package { bind: }

        service { named:
            restart => "service named restart", 
            subscribe => Package["bind"],
        }

        file { '/etc/named.conf':
            ensure => "/var/lib/named/etc/named.conf",
            require => Package[bind],
        }
        
        exec { "named_reload":
            command => "service named reload",
            refreshonly => true,
        } 
    }

    file { '/var/lib/named/etc/named.conf':
        require => Package["bind"],
        content => "",
        notify => [Service['named']]
    }

    define zone_base($content = false) {
        if ! $content {
            $zone_content = template("bind/zones/$name.zone")
        } else {
            $zone_content = $content
        }
        file { "/var/lib/named/var/named/$zone_subdir/$name.zone":
            content => $zone_content,
            require => Package[bind],
            notify => Exec[named_reload]
        }
    }

    define zone_master($content = false) {
        $zone_subdir = "master"
        zone_base { $name : 
            content => $content 
        }
    }

    define zone_reverse($content = false) {
        $zone_subdir = "reverse"
        zone_base { $name : 
            content => $content 
        } 
    }


    class bind_master inherits bind_base {
        Tld_redirections::Domain <<| |>>

        $managed_tlds = list_exported_ressources('Tld_redirections::Domain')
        file { '/var/lib/named/etc/named.conf':
            content => template("bind/named_base.conf", "bind/named_master.conf"),
        }
    }

    class bind_slave inherits bind_base {
        $managed_tlds = list_exported_ressources('Tld_redirections::Domain')
        file { '/var/lib/named/etc/named.conf':
            content => template("bind/named_base.conf", "bind/named_slave.conf"),
        }
    }
}