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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
Puppet::Type.newtype(:dns_zone2, :self_refresh => true) do
@doc = %q{
}
newproperty(:ensure) do
newvalue(:present) do
provider.write_zone (resource.should_content)
end
# This should ideally remove the zone. This is however managed
# "higher" up in the puppet code.
# dns::init has a purge on the directory, and the named
# configuration file is fully managed by us.
# This means that decomissioning is as simple as removing the zone
# from the puppet environment.
newvalue(:absent) do
# provider.destroy
end
defaultto :present
def retrieve
if provider.exists?
:present
else
:absent
end
end
end
def refresh
provider.write_zone(should_content)
end
newparam(:origin, :namevar => true) do
munge do |value|
if value[-1] == '.'
value
else
"#{value}."
end
end
end
newparam(:cls) do
defaultto :IN
end
newparam(:view) do
defaultto '_default'
end
newparam(:type) do
newvalues(:master, :slave,
:mirror, :hint, :stub, :static_stub, :forward, :redirect)
aliasvalue :primary, :master
aliasvalue :secondary, :slave
defaultto :master
end
newparam(:default_ttl) do
defaultto '300'
end
newparam(:mname) do
munge do |value|
if value[-1] == '.'
value
else
"#{value}."
end
end
end
newparam(:rname) do
munge do |value|
if value[-1] == '.'
value
else
"#{value}."
end
end
end
newparam(:soa_ttl) do
end
newparam(:refresh) do
end
newparam(:retry) do
end
newparam(:expire) do
end
newparam(:negative_ttl) do
end
# List of all DNS records (at all)
#
# Should ideally be limited to records in this zone here instead of
# further down.
def records
catalog.resources.filter do |r|
r.is_a?(Puppet::Type.type(:dns_record2))
end
end
# Create the file resource for us.
# This prevents the directory purge on /var/named/zones from deleting us.
def generate
[Puppet::Type.type(:file).new({
ensure: :present,
path: provider.filename,
})]
end
def should_content
provider.zone_content(records)
end
# def eval_generate
# content = should_content
# catalog.resource("File[/var/named/zones/#{self[:name]}db]")[:content] = content
# # provider.refresh (resource.records)
# [catalog.resource("File[/var/named/zones/#{self[:name]}db]")]
# end
# autorequire(:file) {["/var/named/zones/#{self[:name]}db"]}
end
|