puppet 0.16.0 → 0.18.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +98 -0
- data/Rakefile +5 -1
- data/bin/puppet +1 -1
- data/bin/puppetca +25 -11
- data/bin/puppetd +189 -66
- data/bin/puppetdoc +79 -62
- data/bin/puppetmasterd +93 -49
- data/bin/puppetrun +385 -0
- data/conf/redhat/client.init +5 -2
- data/conf/redhat/fileserver.conf +1 -1
- data/conf/redhat/lsb-config.patch +51 -0
- data/conf/redhat/puppet.spec +45 -18
- data/conf/redhat/puppetd.conf +32 -4
- data/conf/redhat/server.init +5 -2
- data/conf/solaris/pkginfo +7 -0
- data/conf/solaris/smf/puppetd.xml +77 -0
- data/conf/solaris/smf/puppetmasterd.xml +77 -0
- data/conf/solaris/smf/svc-puppetd +66 -0
- data/conf/solaris/smf/svc-puppetmasterd +62 -0
- data/examples/code/failers/noobjectrvalue +1 -0
- data/examples/code/snippets/deepclassheirarchy.pp +23 -0
- data/examples/code/snippets/defineoverrides.pp +17 -0
- data/examples/code/snippets/emptyexec.pp +3 -0
- data/examples/code/snippets/selectorvalues.pp +6 -1
- data/examples/code/snippets/tagged.pp +35 -0
- data/ext/ldap/puppet.schema +2 -2
- data/install.rb +4 -2
- data/lib/puppet.rb +206 -15
- data/lib/puppet/client.rb +30 -20
- data/lib/puppet/client/ca.rb +2 -2
- data/lib/puppet/client/dipper.rb +5 -9
- data/lib/puppet/client/master.rb +224 -44
- data/lib/puppet/client/pelement.rb +54 -9
- data/lib/puppet/client/proxy.rb +3 -2
- data/lib/puppet/client/reporter.rb +34 -0
- data/lib/puppet/client/runner.rb +17 -0
- data/lib/puppet/config.rb +136 -55
- data/lib/puppet/daemon.rb +59 -37
- data/lib/puppet/element.rb +2 -1
- data/lib/puppet/event.rb +14 -3
- data/lib/puppet/filetype.rb +28 -19
- data/lib/puppet/log.rb +297 -132
- data/lib/puppet/metric.rb +31 -131
- data/lib/puppet/networkclient.rb +73 -46
- data/lib/puppet/parameter.rb +49 -1
- data/lib/puppet/parsedfile.rb +32 -12
- data/lib/puppet/parser/ast.rb +6 -1
- data/lib/puppet/parser/ast/astarray.rb +32 -6
- data/lib/puppet/parser/ast/collection.rb +91 -0
- data/lib/puppet/parser/ast/compdef.rb +2 -2
- data/lib/puppet/parser/ast/component.rb +24 -11
- data/lib/puppet/parser/ast/function.rb +50 -0
- data/lib/puppet/parser/ast/hostclass.rb +70 -22
- data/lib/puppet/parser/ast/node.rb +17 -8
- data/lib/puppet/parser/ast/nodedef.rb +1 -1
- data/lib/puppet/parser/ast/objectdef.rb +28 -10
- data/lib/puppet/parser/ast/selector.rb +4 -1
- data/lib/puppet/parser/functions.rb +145 -0
- data/lib/puppet/parser/interpreter.rb +243 -86
- data/lib/puppet/parser/lexer.rb +5 -4
- data/lib/puppet/parser/parser.rb +586 -505
- data/lib/puppet/parser/scope.rb +337 -187
- data/lib/puppet/rails.rb +115 -0
- data/lib/puppet/rails/database.rb +40 -0
- data/lib/puppet/rails/host.rb +83 -0
- data/lib/puppet/rails/rails_object.rb +42 -0
- data/lib/puppet/rails/rails_parameter.rb +5 -0
- data/lib/puppet/reports/rrdgraph.rb +20 -0
- data/lib/puppet/reports/tagmail.rb +94 -0
- data/lib/puppet/server.rb +20 -4
- data/lib/puppet/server/authconfig.rb +14 -3
- data/lib/puppet/server/authstore.rb +2 -2
- data/lib/puppet/server/ca.rb +23 -11
- data/lib/puppet/server/filebucket.rb +10 -10
- data/lib/puppet/server/fileserver.rb +4 -8
- data/lib/puppet/server/master.rb +19 -22
- data/lib/puppet/server/pelement.rb +28 -16
- data/lib/puppet/server/report.rb +184 -0
- data/lib/puppet/server/runner.rb +62 -0
- data/lib/puppet/server/servlet.rb +23 -9
- data/lib/puppet/sslcertificates/ca.rb +25 -1
- data/lib/puppet/statechange.rb +34 -53
- data/lib/puppet/storage.rb +1 -2
- data/lib/puppet/transaction.rb +305 -133
- data/lib/puppet/transaction/report.rb +42 -0
- data/lib/puppet/transportable.rb +57 -33
- data/lib/puppet/type.rb +260 -127
- data/lib/puppet/type/component.rb +9 -21
- data/lib/puppet/type/cron.rb +367 -116
- data/lib/puppet/type/exec.rb +15 -16
- data/lib/puppet/type/group.rb +9 -1
- data/lib/puppet/type/nameservice.rb +2 -5
- data/lib/puppet/type/nameservice/netinfo.rb +3 -0
- data/lib/puppet/type/nameservice/objectadd.rb +23 -10
- data/lib/puppet/type/nameservice/pw.rb +16 -3
- data/lib/puppet/type/package.rb +25 -75
- data/lib/puppet/type/package/apple.rb +15 -1
- data/lib/puppet/type/package/apt.rb +37 -2
- data/lib/puppet/type/package/blastwave.rb +136 -0
- data/lib/puppet/type/package/dpkg.rb +4 -4
- data/lib/puppet/type/package/gem.rb +119 -0
- data/lib/puppet/type/package/openbsd.rb +7 -6
- data/lib/puppet/type/package/ports.rb +7 -2
- data/lib/puppet/type/package/rpm.rb +1 -1
- data/lib/puppet/type/package/sun.rb +23 -9
- data/lib/puppet/type/package/sunfreeware.rb +7 -0
- data/lib/puppet/type/package/yum.rb +16 -9
- data/lib/puppet/type/parsedtype.rb +7 -5
- data/lib/puppet/type/parsedtype/mount.rb +55 -34
- data/lib/puppet/type/parsedtype/port.rb +7 -1
- data/lib/puppet/type/parsedtype/sshkey.rb +6 -16
- data/lib/puppet/type/pfile.rb +115 -23
- data/lib/puppet/type/pfile/checksum.rb +18 -5
- data/lib/puppet/type/pfile/content.rb +2 -2
- data/lib/puppet/type/pfile/ensure.rb +3 -3
- data/lib/puppet/type/pfile/group.rb +2 -2
- data/lib/puppet/type/pfile/source.rb +28 -17
- data/lib/puppet/type/pfile/target.rb +25 -17
- data/lib/puppet/type/pfilebucket.rb +25 -6
- data/lib/puppet/type/schedule.rb +6 -6
- data/lib/puppet/type/service.rb +24 -14
- data/lib/puppet/type/service/debian.rb +1 -1
- data/lib/puppet/type/service/redhat.rb +13 -10
- data/lib/puppet/type/service/smf.rb +3 -3
- data/lib/puppet/type/state.rb +1 -2
- data/lib/puppet/type/symlink.rb +3 -4
- data/lib/puppet/type/user.rb +22 -10
- data/lib/puppet/type/yumrepo.rb +6 -1
- data/lib/puppet/type/zone.rb +595 -0
- data/lib/puppet/util.rb +58 -12
- data/test/client/client.rb +2 -2
- data/test/client/master.rb +92 -3
- data/test/client/pelement.rb +99 -0
- data/test/executables/puppetbin.rb +3 -4
- data/test/executables/puppetca.rb +3 -3
- data/test/executables/puppetd.rb +3 -3
- data/test/executables/puppetmasterd.rb +1 -5
- data/test/executables/puppetmodule.rb +2 -2
- data/test/language/ast.rb +200 -11
- data/test/language/functions.rb +245 -0
- data/test/language/interpreter.rb +155 -6
- data/test/language/lexer.rb +35 -2
- data/test/language/node.rb +48 -1
- data/test/language/parser.rb +250 -1
- data/test/language/rails.rb +105 -0
- data/test/language/scope.rb +304 -10
- data/test/language/snippets.rb +54 -5
- data/test/language/transportable.rb +60 -28
- data/test/other/config.rb +214 -1
- data/test/other/events.rb +67 -9
- data/test/other/log.rb +31 -5
- data/test/other/metrics.rb +23 -21
- data/test/other/parsedfile.rb +29 -2
- data/test/other/puppet.rb +79 -0
- data/test/other/report.rb +106 -0
- data/test/other/storage.rb +2 -2
- data/test/other/transactions.rb +128 -2
- data/test/puppet/utiltest.rb +10 -5
- data/test/puppettest.rb +193 -21
- data/test/server/authstore.rb +13 -4
- data/test/server/bucket.rb +33 -8
- data/test/server/ca.rb +44 -6
- data/test/server/master.rb +6 -7
- data/test/server/pelement.rb +15 -5
- data/test/server/report.rb +93 -0
- data/test/server/runner.rb +107 -0
- data/test/server/server.rb +28 -1
- data/test/types/cron.rb +339 -31
- data/test/types/file.rb +256 -24
- data/test/types/filebucket.rb +6 -2
- data/test/types/filesources.rb +41 -92
- data/test/types/group.rb +31 -1
- data/test/types/host.rb +2 -1
- data/test/types/mount.rb +18 -1
- data/test/types/package.rb +200 -18
- data/test/types/service.rb +5 -1
- data/test/types/sshkey.rb +2 -1
- data/test/types/symlink.rb +3 -2
- data/test/types/type.rb +180 -1
- data/test/types/user.rb +65 -27
- data/test/types/yumrepo.rb +15 -0
- data/test/types/zone.rb +437 -0
- metadata +43 -4
- data/bin/cf2puppet +0 -186
- data/conf/redhat/puppetmasterd.conf +0 -5
@@ -1,20 +1,65 @@
|
|
1
|
-
class Puppet::Client::
|
2
|
-
@drivername = :
|
1
|
+
class Puppet::Client::PElement < Puppet::Client
|
2
|
+
@drivername = :PElementServer
|
3
3
|
|
4
|
-
|
5
|
-
@handler = Puppet::Server::FileServer
|
4
|
+
@handler = Puppet::Server::PElement
|
6
5
|
|
7
|
-
|
6
|
+
def apply(bucket)
|
7
|
+
|
8
|
+
case bucket
|
9
|
+
when Puppet::TransObject
|
10
|
+
tmp = Puppet::TransBucket.new
|
11
|
+
tmp.push bucket
|
12
|
+
bucket = tmp
|
13
|
+
bucket.name = Facter["hostname"].value
|
14
|
+
bucket.type = "pelement"
|
15
|
+
when Puppet::TransBucket
|
16
|
+
# nothing
|
17
|
+
else
|
18
|
+
raise Puppet::DevError, "You must pass a transportable object, not a %s" %
|
19
|
+
bucket.class
|
20
|
+
end
|
21
|
+
|
22
|
+
unless @local
|
23
|
+
bucket = Base64.encode64(YAML::dump(bucket))
|
24
|
+
end
|
25
|
+
report = @driver.apply(bucket, "yaml")
|
26
|
+
|
27
|
+
return report
|
28
|
+
end
|
29
|
+
|
30
|
+
def describe(type, name, retrieve = false, ignore = false)
|
31
|
+
Puppet.info "Describing %s[%s]" % [type, name]
|
32
|
+
text = @driver.describe(type, name, retrieve, ignore, "yaml")
|
33
|
+
|
34
|
+
object = nil
|
35
|
+
if @local
|
36
|
+
object = text
|
37
|
+
else
|
38
|
+
object = YAML::load(Base64.decode64(text))
|
39
|
+
end
|
40
|
+
|
41
|
+
return object
|
42
|
+
end
|
8
43
|
|
9
44
|
def initialize(hash = {})
|
10
|
-
if hash.include?(:
|
11
|
-
unless hash[:
|
12
|
-
raise Puppet::DevError, "Must pass an actual
|
45
|
+
if hash.include?(:PElementServer)
|
46
|
+
unless hash[:PElementServer].is_a?(Puppet::Server::PElement)
|
47
|
+
raise Puppet::DevError, "Must pass an actual PElement server object"
|
13
48
|
end
|
14
49
|
end
|
15
50
|
|
16
51
|
super(hash)
|
17
52
|
end
|
53
|
+
|
54
|
+
def list(type, ignore = false, base = false)
|
55
|
+
bucket = @driver.list(type, ignore, base, "yaml")
|
56
|
+
|
57
|
+
unless @local
|
58
|
+
bucket = YAML::load(Base64.decode64(bucket))
|
59
|
+
end
|
60
|
+
|
61
|
+
return bucket
|
62
|
+
end
|
18
63
|
end
|
19
64
|
|
20
|
-
# $Id: pelement.rb
|
65
|
+
# $Id: pelement.rb 1145 2006-04-28 04:08:38Z luke $
|
data/lib/puppet/client/proxy.rb
CHANGED
@@ -6,10 +6,11 @@ class Puppet::Client::ProxyClient < Puppet::Client
|
|
6
6
|
interface = @handler.interface
|
7
7
|
namespace = interface.prefix
|
8
8
|
|
9
|
+
|
9
10
|
interface.methods.each { |ary|
|
10
11
|
method = ary[0]
|
11
12
|
Puppet.debug "%s: defining %s.%s" % [self, namespace, method]
|
12
|
-
|
13
|
+
define_method(method) { |*args|
|
13
14
|
begin
|
14
15
|
@driver.send(method, *args)
|
15
16
|
rescue XMLRPC::FaultException => detail
|
@@ -24,4 +25,4 @@ class Puppet::Client::ProxyClient < Puppet::Client
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
# $Id: proxy.rb
|
28
|
+
# $Id: proxy.rb 1145 2006-04-28 04:08:38Z luke $
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Puppet::Client::Reporter < Puppet::Client
|
2
|
+
@drivername = :Report
|
3
|
+
|
4
|
+
# set up the appropriate interface methods
|
5
|
+
@handler = Puppet::Server::Report
|
6
|
+
|
7
|
+
def initialize(hash = {})
|
8
|
+
if hash.include?(:Report)
|
9
|
+
hash[:Report] = Puppet::Server::Report.new()
|
10
|
+
end
|
11
|
+
|
12
|
+
super(hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Send our report. We get the transaction report and convert it to YAML
|
16
|
+
# as appropriate.
|
17
|
+
def report(transreport)
|
18
|
+
report = YAML.dump(transreport)
|
19
|
+
|
20
|
+
unless self.local
|
21
|
+
report = CGI.escape(report)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Now send the report
|
25
|
+
file = nil
|
26
|
+
benchmark(:info, "Sent transaction report") do
|
27
|
+
file = @driver.report(report)
|
28
|
+
end
|
29
|
+
|
30
|
+
file
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# $Id: reporter.rb 1422 2006-07-22 03:32:56Z luke $
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Puppet::Client::Runner < Puppet::Client::ProxyClient
|
2
|
+
@drivername = :Runner
|
3
|
+
|
4
|
+
# set up the appropriate interface methods
|
5
|
+
@handler = Puppet::Server::Runner
|
6
|
+
self.mkmethods
|
7
|
+
|
8
|
+
def initialize(hash = {})
|
9
|
+
if hash.include?(:Runner)
|
10
|
+
hash[:Runner] = Puppet::Server::Runner.new()
|
11
|
+
end
|
12
|
+
|
13
|
+
super(hash)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# $Id: runner.rb 1212 2006-05-18 20:41:54Z luke $
|
data/lib/puppet/config.rb
CHANGED
@@ -9,30 +9,39 @@ class Config
|
|
9
9
|
|
10
10
|
@@sync = Sync.new
|
11
11
|
|
12
|
+
attr_reader :file, :timer
|
12
13
|
|
13
14
|
# Retrieve a config value
|
14
15
|
def [](param)
|
15
16
|
param = symbolize(param)
|
17
|
+
|
18
|
+
# Yay, recursion.
|
19
|
+
self.reparse() unless param == :filetimeout
|
16
20
|
if @config.include?(param)
|
17
21
|
if @config[param]
|
18
22
|
val = @config[param].value
|
19
23
|
return val
|
20
24
|
end
|
21
25
|
else
|
22
|
-
raise ArgumentError, "
|
26
|
+
raise ArgumentError, "Undefined configuration parameter '%s'" % param
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
26
30
|
# Set a config value. This doesn't set the defaults, it sets the value itself.
|
27
31
|
def []=(param, value)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
@@sync.synchronize do # yay, thread-safe
|
33
|
+
param = symbolize(param)
|
34
|
+
unless @config.include?(param)
|
35
|
+
raise Puppet::Error,
|
36
|
+
"Unknown configuration parameter %s" % param.inspect
|
37
|
+
end
|
38
|
+
unless @order.include?(param)
|
39
|
+
@order << param
|
40
|
+
end
|
41
|
+
@config[param].value = value
|
34
42
|
end
|
35
|
-
|
43
|
+
|
44
|
+
return value
|
36
45
|
end
|
37
46
|
|
38
47
|
# A simplified equality operator.
|
@@ -50,6 +59,10 @@ class Config
|
|
50
59
|
# understand, and add them to the passed option list.
|
51
60
|
def addargs(options)
|
52
61
|
require 'getoptlong'
|
62
|
+
|
63
|
+
# Hackish, but acceptable. Copy the current ARGV for restarting.
|
64
|
+
Puppet.args = ARGV.dup
|
65
|
+
|
53
66
|
# Add all of the config parameters as valid options.
|
54
67
|
self.each { |param, obj|
|
55
68
|
if self.boolean?(param)
|
@@ -87,12 +100,19 @@ class Config
|
|
87
100
|
end
|
88
101
|
end
|
89
102
|
|
90
|
-
# Remove all set values.
|
91
|
-
def clear
|
103
|
+
# Remove all set values, potentially skipping cli values.
|
104
|
+
def clear(exceptcli = false)
|
92
105
|
@config.each { |name, obj|
|
93
|
-
obj.
|
106
|
+
unless exceptcli and obj.setbycli
|
107
|
+
obj.clear
|
108
|
+
end
|
94
109
|
}
|
95
|
-
|
110
|
+
|
111
|
+
# Don't clear the 'used' in this case, since it's a config file reparse,
|
112
|
+
# and we want to retain this info.
|
113
|
+
unless exceptcli
|
114
|
+
@used = []
|
115
|
+
end
|
96
116
|
end
|
97
117
|
|
98
118
|
# This is mostly just used for testing.
|
@@ -100,15 +120,6 @@ class Config
|
|
100
120
|
@used = []
|
101
121
|
end
|
102
122
|
|
103
|
-
def symbolize(param)
|
104
|
-
case param
|
105
|
-
when String: return param.intern
|
106
|
-
when Symbol: return param
|
107
|
-
else
|
108
|
-
raise ArgumentError, "Invalid param type %s" % param.class
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
123
|
def each
|
113
124
|
@order.each { |name|
|
114
125
|
if @config.include?(name)
|
@@ -143,12 +154,7 @@ class Config
|
|
143
154
|
|
144
155
|
# Handle a command-line argument.
|
145
156
|
def handlearg(opt, value = nil)
|
146
|
-
|
147
|
-
value = true
|
148
|
-
end
|
149
|
-
if value == "false"
|
150
|
-
value = false
|
151
|
-
end
|
157
|
+
value = mungearg(value) if value
|
152
158
|
str = opt.sub(/^--/,'')
|
153
159
|
bool = true
|
154
160
|
newstr = str.sub(/^no-/, '')
|
@@ -171,6 +177,11 @@ class Config
|
|
171
177
|
end
|
172
178
|
end
|
173
179
|
|
180
|
+
def include?(name)
|
181
|
+
name = name.intern if name.is_a? String
|
182
|
+
@config.include?(name)
|
183
|
+
end
|
184
|
+
|
174
185
|
# Create a new config object
|
175
186
|
def initialize
|
176
187
|
@order = []
|
@@ -196,6 +207,18 @@ class Config
|
|
196
207
|
end
|
197
208
|
end
|
198
209
|
|
210
|
+
# Convert arguments appropriately.
|
211
|
+
def mungearg(value)
|
212
|
+
# Handle different data types correctly
|
213
|
+
return case value
|
214
|
+
when /^false$/i: false
|
215
|
+
when /^true$/i: true
|
216
|
+
when /^\d+$/i: Integer(value)
|
217
|
+
else
|
218
|
+
value.gsub(/^["']|["']$/,'')
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
199
222
|
# Return all of the parameters associated with a given section.
|
200
223
|
def params(section)
|
201
224
|
section = section.intern if section.is_a? String
|
@@ -209,23 +232,31 @@ class Config
|
|
209
232
|
# Parse a configuration file.
|
210
233
|
def parse(file)
|
211
234
|
text = nil
|
212
|
-
|
235
|
+
|
236
|
+
if file.is_a? Puppet::ParsedFile
|
237
|
+
@file = file
|
238
|
+
else
|
239
|
+
@file = Puppet::ParsedFile.new(file)
|
240
|
+
end
|
241
|
+
|
242
|
+
# Create a timer so that this.
|
243
|
+
settimer()
|
213
244
|
|
214
245
|
begin
|
215
|
-
text = File.read(file)
|
246
|
+
text = File.read(@file.file)
|
216
247
|
rescue Errno::ENOENT
|
217
248
|
raise Puppet::Error, "No such file %s" % file
|
218
249
|
rescue Errno::EACCES
|
219
250
|
raise Puppet::Error, "Permission denied to file %s" % file
|
220
251
|
end
|
221
252
|
|
222
|
-
# Store it for later, in a way that we can test and such.
|
223
|
-
@file = Puppet::ParsedFile.new(file)
|
224
|
-
|
225
253
|
@values = Hash.new { |names, name|
|
226
254
|
names[name] = {}
|
227
255
|
}
|
228
256
|
|
257
|
+
# Get rid of the values set by the file, keeping cli values.
|
258
|
+
self.clear(true)
|
259
|
+
|
229
260
|
section = "puppet"
|
230
261
|
metas = %w{owner group mode}
|
231
262
|
values = Hash.new { |hash, key| hash[key] = {} }
|
@@ -236,7 +267,7 @@ class Config
|
|
236
267
|
when /^\s*$/: next # Skip blanks
|
237
268
|
when /^\s*(\w+)\s*=\s*(.+)$/: # settings
|
238
269
|
var = $1.intern
|
239
|
-
value = $2
|
270
|
+
value = mungearg($2)
|
240
271
|
|
241
272
|
# Mmm, "special" attributes
|
242
273
|
if metas.include?(var.to_s)
|
@@ -288,15 +319,15 @@ class Config
|
|
288
319
|
case value
|
289
320
|
when true, false, "true", "false":
|
290
321
|
klass = CBoolean
|
291
|
-
when
|
322
|
+
when /^\$\w+\//, /^\//:
|
292
323
|
klass = CFile
|
293
324
|
when String, Integer, Float: # nothing
|
294
325
|
klass = CElement
|
295
326
|
else
|
296
327
|
raise Puppet::Error, "Invalid value '%s' for %s" % [value.inspect, hash[:name]]
|
297
328
|
end
|
329
|
+
hash[:parent] = self
|
298
330
|
element = klass.new(hash)
|
299
|
-
element.parent = self
|
300
331
|
|
301
332
|
@order << element.name
|
302
333
|
|
@@ -313,6 +344,27 @@ class Config
|
|
313
344
|
}
|
314
345
|
end
|
315
346
|
|
347
|
+
# Reparse our config file, if necessary.
|
348
|
+
def reparse
|
349
|
+
if defined? @file and @file.changed?
|
350
|
+
Puppet.notice "Reparsing %s" % @file.file
|
351
|
+
@@sync.synchronize do
|
352
|
+
parse(@file)
|
353
|
+
end
|
354
|
+
reuse()
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
def reuse
|
359
|
+
return unless defined? @used
|
360
|
+
@@sync.synchronize do # yay, thread-safe
|
361
|
+
@used.each do |section|
|
362
|
+
@used.delete(section)
|
363
|
+
self.use(section)
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
316
368
|
# Get a list of objects per section
|
317
369
|
def sectionlist
|
318
370
|
sectionlist = []
|
@@ -410,6 +462,28 @@ class Config
|
|
410
462
|
}
|
411
463
|
end
|
412
464
|
|
465
|
+
# Create a timer to check whether the file should be reparsed.
|
466
|
+
def settimer
|
467
|
+
if Puppet[:filetimeout] > 0
|
468
|
+
@timer = Puppet.newtimer(
|
469
|
+
:interval => Puppet[:filetimeout],
|
470
|
+
:tolerance => 1,
|
471
|
+
:start? => true
|
472
|
+
) do
|
473
|
+
self.reparse()
|
474
|
+
end
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
def symbolize(param)
|
479
|
+
case param
|
480
|
+
when String: return param.intern
|
481
|
+
when Symbol: return param
|
482
|
+
else
|
483
|
+
raise ArgumentError, "Invalid param type %s" % param.class
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
413
487
|
# Convert our list of objects into a component that can be applied.
|
414
488
|
def to_component
|
415
489
|
transport = self.to_transportable
|
@@ -452,8 +526,8 @@ Generated on #{Time.now}.
|
|
452
526
|
}
|
453
527
|
|
454
528
|
topbucket = Puppet::TransBucket.new
|
455
|
-
if defined? @file and @file
|
456
|
-
topbucket.name = @file
|
529
|
+
if defined? @file.file and @file.file
|
530
|
+
topbucket.name = @file.file
|
457
531
|
else
|
458
532
|
topbucket.name = "configtop"
|
459
533
|
end
|
@@ -480,16 +554,6 @@ Generated on #{Time.now}.
|
|
480
554
|
return manifest
|
481
555
|
end
|
482
556
|
|
483
|
-
def reuse
|
484
|
-
return unless defined? @used
|
485
|
-
@@sync.synchronize do # yay, thread-safe
|
486
|
-
@used.each do |section|
|
487
|
-
@used.delete(section)
|
488
|
-
self.use(section)
|
489
|
-
end
|
490
|
-
end
|
491
|
-
end
|
492
|
-
|
493
557
|
# Create the necessary objects to use a section. This is idempotent;
|
494
558
|
# you can 'use' a section as many times as you want.
|
495
559
|
def use(*sections)
|
@@ -518,12 +582,22 @@ Generated on #{Time.now}.
|
|
518
582
|
objects = bucket.to_type
|
519
583
|
|
520
584
|
objects.finalize
|
585
|
+
tags = nil
|
586
|
+
if Puppet[:tags]
|
587
|
+
tags = Puppet[:tags]
|
588
|
+
Puppet[:tags] = ""
|
589
|
+
end
|
521
590
|
trans = objects.evaluate
|
522
591
|
trans.evaluate
|
592
|
+
if tags
|
593
|
+
Puppet[:tags] = tags
|
594
|
+
end
|
523
595
|
|
524
596
|
# Remove is a recursive process, so it's sufficient to just call
|
525
597
|
# it on the component.
|
526
|
-
objects.remove
|
598
|
+
objects.remove(true)
|
599
|
+
|
600
|
+
objects = nil
|
527
601
|
|
528
602
|
runners.each { |s| @used << s }
|
529
603
|
end
|
@@ -618,8 +692,9 @@ Generated on #{Time.now}.
|
|
618
692
|
if value =~ /\$(\w+)/
|
619
693
|
parent = $1
|
620
694
|
if pval = @parent[parent]
|
621
|
-
newval = value.sub(/\$#{parent}/, pval)
|
622
|
-
return File.join(newval.split("/"))
|
695
|
+
newval = value.to_s.sub(/\$#{parent.to_s}/, pval.to_s)
|
696
|
+
#return File.join(newval.split("/"))
|
697
|
+
return newval
|
623
698
|
else
|
624
699
|
raise Puppet::DevError, "Could not find value for %s" % parent
|
625
700
|
end
|
@@ -634,6 +709,10 @@ Generated on #{Time.now}.
|
|
634
709
|
|
635
710
|
# Create the new element. Pretty much just sets the name.
|
636
711
|
def initialize(args = {})
|
712
|
+
if args.include?(:parent)
|
713
|
+
self.parent = args[:parent]
|
714
|
+
args.delete(:parent)
|
715
|
+
end
|
637
716
|
args.each do |param, value|
|
638
717
|
method = param.to_s + "="
|
639
718
|
unless self.respond_to? method
|
@@ -802,7 +881,7 @@ Generated on #{Time.now}.
|
|
802
881
|
obj[:loglevel] = "debug"
|
803
882
|
|
804
883
|
if self.section
|
805
|
-
obj.tags
|
884
|
+
obj.tags += ["puppet", "configuration", self.section, self.name]
|
806
885
|
end
|
807
886
|
objects << obj
|
808
887
|
objects
|
@@ -812,9 +891,11 @@ Generated on #{Time.now}.
|
|
812
891
|
def validate(value)
|
813
892
|
return true unless value.is_a? String
|
814
893
|
value.scan(/\$(\w+)/) { |name|
|
815
|
-
name =
|
816
|
-
unless @parent
|
817
|
-
raise
|
894
|
+
name = $1
|
895
|
+
unless @parent.include?(name)
|
896
|
+
raise ArgumentError,
|
897
|
+
"Configuration parameter '%s' is undefined" %
|
898
|
+
name
|
818
899
|
end
|
819
900
|
}
|
820
901
|
end
|
@@ -835,4 +916,4 @@ Generated on #{Time.now}.
|
|
835
916
|
end
|
836
917
|
end
|
837
918
|
|
838
|
-
# $Id: config.rb
|
919
|
+
# $Id: config.rb 1421 2006-07-21 23:12:51Z luke $
|