puppet 0.13.6 → 0.16.0
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 +57 -0
- data/Rakefile +38 -410
- data/bin/puppet +14 -12
- data/bin/puppetca +1 -3
- data/bin/puppetd +25 -7
- data/bin/puppetdoc +161 -104
- data/bin/puppetmasterd +4 -4
- data/conf/epm.list +8 -0
- data/conf/redhat/client.init +6 -1
- data/conf/redhat/no-chuser-0.15.1.patch +38 -0
- data/conf/redhat/puppet.spec +20 -5
- data/conf/redhat/puppetd.conf +1 -1
- data/conf/redhat/puppetmasterd.conf +1 -1
- data/conf/redhat/server.init +2 -4
- data/examples/code/snippets/{casestatement → casestatement.pp} +12 -1
- data/examples/code/snippets/selectorvalues.pp +15 -0
- data/examples/code/snippets/singleselector.pp +22 -0
- data/examples/code/snippets/tag.pp +9 -0
- data/ext/module_puppet +1 -1
- data/install.rb +303 -303
- data/lib/puppet.rb +7 -9
- data/lib/puppet/client.rb +18 -5
- data/lib/puppet/client/dipper.rb +12 -10
- data/lib/puppet/client/master.rb +113 -41
- data/lib/puppet/client/pelement.rb +20 -0
- data/lib/puppet/config.rb +113 -6
- data/lib/puppet/element.rb +1 -3
- data/lib/puppet/event.rb +12 -23
- data/lib/puppet/filetype.rb +93 -5
- data/lib/puppet/inifile.rb +201 -0
- data/lib/puppet/log.rb +18 -6
- data/lib/puppet/parameter.rb +80 -29
- data/lib/puppet/parser/ast.rb +6 -4
- data/lib/puppet/parser/ast/caseopt.rb +13 -4
- data/lib/puppet/parser/ast/casestatement.rb +2 -2
- data/lib/puppet/parser/ast/component.rb +4 -14
- data/lib/puppet/parser/ast/hostclass.rb +1 -1
- data/lib/puppet/parser/ast/leaf.rb +12 -0
- data/lib/puppet/parser/ast/node.rb +4 -4
- data/lib/puppet/parser/ast/objectdef.rb +5 -51
- data/lib/puppet/parser/ast/selector.rb +2 -0
- data/lib/puppet/parser/ast/tag.rb +26 -0
- data/lib/puppet/parser/interpreter.rb +89 -74
- data/lib/puppet/parser/lexer.rb +4 -3
- data/lib/puppet/parser/parser.rb +440 -378
- data/lib/puppet/parser/scope.rb +844 -887
- data/lib/puppet/server.rb +12 -1
- data/lib/puppet/server/authconfig.rb +166 -0
- data/lib/puppet/server/authstore.rb +8 -6
- data/lib/puppet/server/ca.rb +23 -26
- data/lib/puppet/server/filebucket.rb +24 -23
- data/lib/puppet/server/fileserver.rb +116 -47
- data/lib/puppet/server/master.rb +58 -19
- data/lib/puppet/server/pelement.rb +176 -0
- data/lib/puppet/server/rights.rb +78 -0
- data/lib/puppet/server/servlet.rb +19 -6
- data/lib/puppet/sslcertificates.rb +4 -2
- data/lib/puppet/sslcertificates/ca.rb +66 -34
- data/lib/puppet/storage.rb +20 -26
- data/lib/puppet/transaction.rb +49 -92
- data/lib/puppet/type.rb +142 -35
- data/lib/puppet/type/cron.rb +29 -14
- data/lib/puppet/type/exec.rb +92 -35
- data/lib/puppet/type/group.rb +29 -11
- data/lib/puppet/type/nameservice.rb +50 -1
- data/lib/puppet/type/nameservice/netinfo.rb +68 -1
- data/lib/puppet/type/nameservice/objectadd.rb +1 -0
- data/lib/puppet/type/package.rb +150 -109
- data/lib/puppet/type/package/apple.rb +27 -0
- data/lib/puppet/type/package/apt.rb +1 -0
- data/lib/puppet/type/package/darwinport.rb +97 -0
- data/lib/puppet/type/package/dpkg.rb +10 -2
- data/lib/puppet/type/package/freebsd.rb +19 -0
- data/lib/puppet/type/package/{bsd.rb → openbsd.rb} +36 -7
- data/lib/puppet/type/package/ports.rb +98 -0
- data/lib/puppet/type/package/rpm.rb +43 -7
- data/lib/puppet/type/package/sun.rb +53 -36
- data/lib/puppet/type/package/yum.rb +5 -16
- data/lib/puppet/type/parsedtype.rb +41 -29
- data/lib/puppet/type/parsedtype/host.rb +13 -5
- data/lib/puppet/type/parsedtype/mount.rb +250 -0
- data/lib/puppet/type/parsedtype/port.rb +8 -6
- data/lib/puppet/type/pfile.rb +284 -30
- data/lib/puppet/type/pfile/checksum.rb +96 -68
- data/lib/puppet/type/pfile/content.rb +16 -13
- data/lib/puppet/type/pfile/ensure.rb +64 -126
- data/lib/puppet/type/pfile/group.rb +12 -5
- data/lib/puppet/type/pfile/mode.rb +16 -4
- data/lib/puppet/type/pfile/source.rb +47 -73
- data/lib/puppet/type/pfile/target.rb +81 -0
- data/lib/puppet/type/pfile/uid.rb +10 -3
- data/lib/puppet/type/pfilebucket.rb +12 -3
- data/lib/puppet/type/schedule.rb +5 -1
- data/lib/puppet/type/service.rb +138 -66
- data/lib/puppet/type/service/debian.rb +9 -3
- data/lib/puppet/type/service/init.rb +51 -56
- data/lib/puppet/type/service/smf.rb +16 -6
- data/lib/puppet/type/state.rb +71 -32
- data/lib/puppet/type/symlink.rb +12 -7
- data/lib/puppet/type/tidy.rb +5 -1
- data/lib/puppet/type/user.rb +116 -20
- data/lib/puppet/type/yumrepo.rb +314 -0
- data/lib/puppet/util.rb +84 -14
- data/test/client/client.rb +41 -18
- data/test/client/master.rb +50 -4
- data/test/executables/puppetbin.rb +31 -4
- data/test/executables/puppetca.rb +18 -2
- data/test/language/ast.rb +201 -31
- data/test/language/interpreter.rb +8 -2
- data/test/{parser → language}/lexer.rb +1 -1
- data/test/language/node.rb +84 -0
- data/test/{parser → language}/parser.rb +1 -1
- data/test/language/scope.rb +101 -2
- data/test/language/snippets.rb +23 -2
- data/test/other/config.rb +99 -1
- data/test/other/filetype.rb +95 -0
- data/test/other/inifile.rb +114 -0
- data/test/other/log.rb +3 -2
- data/test/other/transactions.rb +55 -10
- data/test/puppet/utiltest.rb +25 -1
- data/test/puppettest.rb +140 -46
- data/test/server/authconfig.rb +56 -0
- data/test/server/bucket.rb +32 -18
- data/test/server/fileserver.rb +75 -30
- data/test/server/master.rb +27 -4
- data/test/server/pelement.rb +298 -0
- data/test/server/rights.rb +41 -0
- data/test/server/server.rb +2 -2
- data/test/tagging/tagging.rb +100 -1
- data/test/types/basic.rb +3 -3
- data/test/types/cron.rb +24 -1
- data/test/types/exec.rb +99 -1
- data/test/types/file.rb +298 -2
- data/test/types/filebucket.rb +4 -15
- data/test/types/filesources.rb +43 -14
- data/test/types/group.rb +1 -13
- data/test/types/mount.rb +277 -0
- data/test/types/package.rb +164 -33
- data/test/types/parameter.rb +107 -0
- data/test/types/port.rb +2 -1
- data/test/types/service.rb +37 -2
- data/test/types/state.rb +92 -0
- data/test/types/symlink.rb +30 -2
- data/test/types/tidy.rb +2 -14
- data/test/types/type.rb +35 -1
- data/test/types/user.rb +110 -1
- data/test/types/yumrepo.rb +95 -0
- metadata +316 -290
- data/test/types/filetype.rb +0 -160
data/lib/puppet.rb
CHANGED
@@ -14,7 +14,7 @@ require 'puppet/util'
|
|
14
14
|
#
|
15
15
|
# it's also a place to find top-level commands like 'debug'
|
16
16
|
module Puppet
|
17
|
-
PUPPETVERSION = '0.
|
17
|
+
PUPPETVERSION = '0.16.0'
|
18
18
|
|
19
19
|
def Puppet.version
|
20
20
|
return PUPPETVERSION
|
@@ -48,10 +48,6 @@ module Puppet
|
|
48
48
|
str = @message.to_s
|
49
49
|
end
|
50
50
|
|
51
|
-
#if Puppet[:debug] and @stack
|
52
|
-
# str += @stack.to_s
|
53
|
-
#end
|
54
|
-
|
55
51
|
return str
|
56
52
|
end
|
57
53
|
end
|
@@ -124,7 +120,6 @@ module Puppet
|
|
124
120
|
},
|
125
121
|
:statefile => { :default => "$statedir/state.yaml",
|
126
122
|
:mode => 0660,
|
127
|
-
:group => "$group",
|
128
123
|
:desc => "Where puppetd and puppetmasterd store state associated
|
129
124
|
with the running configuration. In the case of puppetmasterd,
|
130
125
|
this file reflects the state discovered through interacting
|
@@ -132,7 +127,7 @@ module Puppet
|
|
132
127
|
},
|
133
128
|
:ssldir => {
|
134
129
|
:default => "$confdir/ssl",
|
135
|
-
:mode =>
|
130
|
+
:mode => 0771,
|
136
131
|
:owner => "root",
|
137
132
|
:desc => "Where SSL certificates are kept."
|
138
133
|
},
|
@@ -144,6 +139,7 @@ module Puppet
|
|
144
139
|
"Whether to just print a manifest to stdout and exit. Only makes
|
145
140
|
sense when used interactively. Takes into account arguments specified
|
146
141
|
on the CLI."],
|
142
|
+
:color => [true, "Whether to use ANSI colors when logging to the console."],
|
147
143
|
:mkusers => [false,
|
148
144
|
"Whether to create the necessary user and group that puppetd will
|
149
145
|
run as."]
|
@@ -190,7 +186,9 @@ module Puppet
|
|
190
186
|
:owner => "root",
|
191
187
|
:mode => 0644,
|
192
188
|
:desc => "The file in which puppetd stores a list of the classes
|
193
|
-
associated with the retrieved configuratiion.
|
189
|
+
associated with the retrieved configuratiion. Can be loaded in
|
190
|
+
the separate ``puppet`` executable using the ``--loadclasses``
|
191
|
+
option."},
|
194
192
|
:puppetdlog => { :default => "$logdir/puppetd.log",
|
195
193
|
:owner => "root",
|
196
194
|
:mode => 0640,
|
@@ -335,4 +333,4 @@ require 'puppet/server'
|
|
335
333
|
require 'puppet/type'
|
336
334
|
require 'puppet/storage'
|
337
335
|
|
338
|
-
# $Id: puppet.rb
|
336
|
+
# $Id: puppet.rb 1094 2006-04-06 06:51:26Z luke $
|
data/lib/puppet/client.rb
CHANGED
@@ -11,12 +11,15 @@ module Puppet
|
|
11
11
|
include Puppet
|
12
12
|
include SignalObserver
|
13
13
|
|
14
|
+
include Puppet::Util
|
15
|
+
|
16
|
+
|
14
17
|
# FIXME The cert stuff should only come up with networking, so it
|
15
18
|
# should be in the network client, not the normal client. But if i do
|
16
19
|
# that, it's hard to tell whether the certs have been initialized.
|
17
20
|
include Puppet::Daemon
|
18
|
-
attr_reader :
|
19
|
-
attr_accessor :schedule, :lastrun
|
21
|
+
attr_reader :secureinit
|
22
|
+
attr_accessor :schedule, :lastrun, :local, :stopping
|
20
23
|
|
21
24
|
class << self
|
22
25
|
attr_reader :drivername
|
@@ -85,6 +88,10 @@ module Puppet
|
|
85
88
|
|
86
89
|
# A wrapper method to run and then store the last run time
|
87
90
|
def runnow
|
91
|
+
if self.stopping
|
92
|
+
Puppet.notice "In shutdown progress; skipping run"
|
93
|
+
return
|
94
|
+
end
|
88
95
|
begin
|
89
96
|
self.run
|
90
97
|
self.lastrun = Time.now.to_i
|
@@ -112,9 +119,15 @@ module Puppet
|
|
112
119
|
@driver.ca_file = @cacertfile
|
113
120
|
end
|
114
121
|
|
122
|
+
# FIXME this should probably not store every single time.
|
115
123
|
def shutdown
|
116
|
-
|
117
|
-
|
124
|
+
if self.stopping
|
125
|
+
Puppet.notice "Already in shutdown"
|
126
|
+
else
|
127
|
+
self.stopping = true
|
128
|
+
Puppet::Storage.store
|
129
|
+
exit
|
130
|
+
end
|
118
131
|
end
|
119
132
|
|
120
133
|
# Start listening for events. We're pretty much just listening for
|
@@ -151,4 +164,4 @@ module Puppet
|
|
151
164
|
end
|
152
165
|
end
|
153
166
|
|
154
|
-
# $Id: client.rb
|
167
|
+
# $Id: client.rb 1098 2006-04-10 22:13:10Z luke $
|
data/lib/puppet/client/dipper.rb
CHANGED
@@ -3,7 +3,10 @@ module Puppet
|
|
3
3
|
# The client class for filebuckets.
|
4
4
|
class Dipper < Puppet::Client
|
5
5
|
@drivername = :Bucket
|
6
|
+
|
7
|
+
attr_accessor :name
|
6
8
|
|
9
|
+
# Create our bucket client
|
7
10
|
def initialize(hash = {})
|
8
11
|
if hash.include?(:Path)
|
9
12
|
bucket = Puppet::Server::FileBucket.new(
|
@@ -16,26 +19,25 @@ module Puppet
|
|
16
19
|
super(hash)
|
17
20
|
end
|
18
21
|
|
22
|
+
# Back up a file to our bucket
|
19
23
|
def backup(file)
|
20
24
|
unless FileTest.exists?(file)
|
21
|
-
raise(BucketError, "File %s does not exist" % file
|
25
|
+
raise(BucketError, "File %s does not exist" % file)
|
22
26
|
end
|
23
|
-
contents = File.
|
24
|
-
|
27
|
+
contents = File.read(file)
|
25
28
|
string = Base64.encode64(contents)
|
26
|
-
#puts "string is created"
|
27
29
|
|
28
30
|
sum = @driver.addfile(string,file)
|
29
|
-
|
31
|
+
string = ""
|
32
|
+
contents = ""
|
30
33
|
return sum
|
31
34
|
end
|
32
35
|
|
36
|
+
# Restore the file
|
33
37
|
def restore(file,sum)
|
34
38
|
restore = true
|
35
39
|
if FileTest.exists?(file)
|
36
|
-
|
37
|
-
|
38
|
-
cursum = Digest::MD5.hexdigest(contents)
|
40
|
+
cursum = Digest::MD5.hexdigest(File.read(file))
|
39
41
|
|
40
42
|
# if the checksum has changed...
|
41
43
|
# this might be extra effort
|
@@ -48,6 +50,7 @@ module Puppet
|
|
48
50
|
#puts "Restoring %s" % file
|
49
51
|
if tmp = @driver.getfile(sum)
|
50
52
|
newcontents = Base64.decode64(tmp)
|
53
|
+
tmp = ""
|
51
54
|
newsum = Digest::MD5.hexdigest(newcontents)
|
52
55
|
changed = nil
|
53
56
|
unless FileTest.writable?(file)
|
@@ -69,10 +72,9 @@ module Puppet
|
|
69
72
|
else
|
70
73
|
return nil
|
71
74
|
end
|
72
|
-
|
73
75
|
end
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
78
|
-
# $Id: dipper.rb
|
80
|
+
# $Id: dipper.rb 1113 2006-04-17 16:15:33Z luke $
|
data/lib/puppet/client/master.rb
CHANGED
@@ -1,45 +1,53 @@
|
|
1
1
|
# The client for interacting with the puppetmaster config server.
|
2
|
+
require 'sync'
|
3
|
+
|
2
4
|
class Puppet::Client::MasterClient < Puppet::Client
|
5
|
+
@@sync = Sync.new
|
6
|
+
|
3
7
|
Puppet.setdefaults("puppetd",
|
4
8
|
:puppetdlockfile => [ "$statedir/puppetdlock",
|
5
|
-
"A lock file to temporarily stop puppetd from doing anything."]
|
9
|
+
"A lock file to temporarily stop puppetd from doing anything."],
|
10
|
+
:usecacheonfailure => [true,
|
11
|
+
"Whether to use the cached configuration when the remote
|
12
|
+
configuration will not compile. This option is useful for testing
|
13
|
+
new configurations, where you want to fix the broken configuration
|
14
|
+
rather than reverting to a known-good one."
|
15
|
+
]
|
16
|
+
|
17
|
+
|
6
18
|
)
|
7
19
|
|
8
20
|
@drivername = :Master
|
9
21
|
|
22
|
+
attr_accessor :objects
|
23
|
+
|
10
24
|
def self.facts
|
11
25
|
facts = {}
|
12
26
|
Facter.each { |name,fact|
|
13
27
|
facts[name] = fact.downcase
|
14
28
|
}
|
15
29
|
|
30
|
+
# Add our client version to the list of facts, so people can use it
|
31
|
+
# in their manifests
|
32
|
+
facts["clientversion"] = Puppet.version.to_s
|
33
|
+
|
16
34
|
facts
|
17
35
|
end
|
18
36
|
|
19
|
-
# This method
|
20
|
-
# objects. For now, just descend into the tree and perform and
|
21
|
-
# necessary manipulations.
|
37
|
+
# This method actually applies the configuration.
|
22
38
|
def apply
|
23
|
-
Puppet.notice "Beginning configuration run"
|
24
39
|
dostorage()
|
25
40
|
unless defined? @objects
|
26
41
|
raise Puppet::Error, "Cannot apply; objects not defined"
|
27
42
|
end
|
28
43
|
|
29
|
-
#Puppet.err :yay
|
30
|
-
#p @objects
|
31
|
-
#Puppet.err :mark
|
32
|
-
#@objects = @objects.to_type
|
33
44
|
# this is a gross hack... but i don't see a good way around it
|
34
45
|
# set all of the variables to empty
|
35
46
|
Puppet::Transaction.init
|
36
47
|
|
37
|
-
# For now we just evaluate the top-level object, but eventually
|
38
|
-
# there will be schedules and such associated with each object,
|
39
|
-
# and probably with the container itself.
|
40
48
|
transaction = @objects.evaluate
|
41
|
-
#transaction = Puppet::Transaction.new(objects)
|
42
49
|
transaction.toplevel = true
|
50
|
+
|
43
51
|
begin
|
44
52
|
transaction.evaluate
|
45
53
|
rescue Puppet::Error => detail
|
@@ -59,7 +67,6 @@ class Puppet::Client::MasterClient < Puppet::Client
|
|
59
67
|
Metric.store
|
60
68
|
Metric.graph
|
61
69
|
end
|
62
|
-
Puppet.notice "Finished configuration run"
|
63
70
|
|
64
71
|
return transaction
|
65
72
|
end
|
@@ -85,15 +92,19 @@ class Puppet::Client::MasterClient < Puppet::Client
|
|
85
92
|
@cachefile
|
86
93
|
end
|
87
94
|
|
88
|
-
# Disable running the configuration.
|
89
|
-
|
90
|
-
|
95
|
+
# Disable running the configuration. This can be used from the command line, but
|
96
|
+
# is also used to make sure only one client is running at a time.
|
97
|
+
def disable(running = false)
|
98
|
+
text = nil
|
99
|
+
if running
|
100
|
+
text = Process.pid
|
101
|
+
else
|
102
|
+
text = ""
|
103
|
+
Puppet.notice "Disabling puppetd"
|
104
|
+
end
|
91
105
|
Puppet.config.use(:puppet)
|
92
|
-
#unless FileTest.exists? File.dirname(Puppet[:puppetdlockfile])
|
93
|
-
# Puppet.recmkdir(File.dirname(Puppet[:puppetdlockfile]))
|
94
|
-
#end
|
95
106
|
begin
|
96
|
-
File.open(Puppet[:puppetdlockfile], "w") { |f| f.puts
|
107
|
+
File.open(Puppet[:puppetdlockfile], "w") { |f| f.puts text }
|
97
108
|
rescue => detail
|
98
109
|
raise Puppet::Error, "Could not lock puppetd: %s" % detail
|
99
110
|
end
|
@@ -116,9 +127,12 @@ class Puppet::Client::MasterClient < Puppet::Client
|
|
116
127
|
end
|
117
128
|
end
|
118
129
|
|
119
|
-
# Enable running again.
|
120
|
-
|
121
|
-
|
130
|
+
# Enable running again. This can be used from the command line, but
|
131
|
+
# is also used to make sure only one client is running at a time.
|
132
|
+
def enable(running = false)
|
133
|
+
unless running
|
134
|
+
Puppet.notice "Enabling puppetd"
|
135
|
+
end
|
122
136
|
if FileTest.exists? Puppet[:puppetdlockfile]
|
123
137
|
File.unlink(Puppet[:puppetdlockfile])
|
124
138
|
end
|
@@ -171,11 +185,19 @@ class Puppet::Client::MasterClient < Puppet::Client
|
|
171
185
|
|
172
186
|
textfacts = CGI.escape(YAML.dump(facts))
|
173
187
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
188
|
+
benchmark(:debug, "Retrieved configuration") do
|
189
|
+
# error handling for this is done in the network client
|
190
|
+
begin
|
191
|
+
textobjects = @driver.getconfig(textfacts, "yaml")
|
192
|
+
rescue => detail
|
193
|
+
Puppet.err "Could not retrieve configuration: %s" % detail
|
194
|
+
|
195
|
+
unless Puppet[:usecacheonfailure]
|
196
|
+
@objects = nil
|
197
|
+
Puppet.warning "Not using cache on failed configuration"
|
198
|
+
return
|
199
|
+
end
|
200
|
+
end
|
179
201
|
end
|
180
202
|
|
181
203
|
fromcache = false
|
@@ -186,13 +208,14 @@ class Puppet::Client::MasterClient < Puppet::Client
|
|
186
208
|
"Cannot connect to server and there is no cached configuration"
|
187
209
|
)
|
188
210
|
end
|
189
|
-
Puppet.
|
211
|
+
Puppet.warning "Could not get config; using cached copy"
|
190
212
|
fromcache = true
|
213
|
+
else
|
214
|
+
@configstamp = Time.now.to_i
|
191
215
|
end
|
192
216
|
|
193
217
|
begin
|
194
218
|
textobjects = CGI.unescape(textobjects)
|
195
|
-
@configstamp = Time.now.to_i
|
196
219
|
rescue => detail
|
197
220
|
raise Puppet::Error, "Could not CGI.unescape configuration"
|
198
221
|
end
|
@@ -215,11 +238,7 @@ class Puppet::Client::MasterClient < Puppet::Client
|
|
215
238
|
"Invalid returned objects of type %s" % objects.class
|
216
239
|
end
|
217
240
|
|
218
|
-
|
219
|
-
self.setclasses(classes)
|
220
|
-
else
|
221
|
-
Puppet.info "No classes to store"
|
222
|
-
end
|
241
|
+
self.setclasses(objects.classes)
|
223
242
|
|
224
243
|
# Clear all existing objects, so we can recreate our stack.
|
225
244
|
if defined? @objects
|
@@ -244,6 +263,37 @@ class Puppet::Client::MasterClient < Puppet::Client
|
|
244
263
|
return @objects
|
245
264
|
end
|
246
265
|
|
266
|
+
# Make sure only one client runs at a time, and make sure only one thread
|
267
|
+
# runs at a time. However, this does not lock local clients -- you could have
|
268
|
+
# as many separate puppet scripts running as you want.
|
269
|
+
def lock
|
270
|
+
if @local
|
271
|
+
yield
|
272
|
+
else
|
273
|
+
@@sync.synchronize(Sync::EX) do
|
274
|
+
disable(true)
|
275
|
+
begin
|
276
|
+
yield
|
277
|
+
ensure
|
278
|
+
enable(true)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
def locked?
|
285
|
+
if FileTest.exists? Puppet[:puppetdlockfile]
|
286
|
+
text = File.read(Puppet[:puppetdlockfile]).chomp
|
287
|
+
if text =~ /\d+/
|
288
|
+
return text
|
289
|
+
else
|
290
|
+
return true
|
291
|
+
end
|
292
|
+
else
|
293
|
+
return false
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
247
297
|
# Retrieve the cached config
|
248
298
|
def retrievecache
|
249
299
|
if FileTest.exists?(self.cachefile)
|
@@ -255,16 +305,38 @@ class Puppet::Client::MasterClient < Puppet::Client
|
|
255
305
|
|
256
306
|
# The code that actually runs the configuration.
|
257
307
|
def run
|
258
|
-
if
|
259
|
-
|
308
|
+
if pid = locked?
|
309
|
+
t = ""
|
310
|
+
if pid == true
|
311
|
+
Puppet.notice "Locked by process %s" % pid
|
312
|
+
end
|
313
|
+
Puppet.notice "Lock file %s exists; skipping configuration run" %
|
260
314
|
Puppet[:puppetdlockfile]
|
261
315
|
else
|
262
|
-
|
263
|
-
|
316
|
+
lock do
|
317
|
+
self.getconfig
|
318
|
+
|
319
|
+
if defined? @objects and @objects
|
320
|
+
unless @local
|
321
|
+
Puppet.notice "Starting configuration run"
|
322
|
+
end
|
323
|
+
benchmark(:notice, "Finished configuration run") do
|
324
|
+
self.apply
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
264
328
|
end
|
265
329
|
end
|
266
330
|
|
331
|
+
# Store the classes in the classfile, but only if we're not local.
|
267
332
|
def setclasses(ary)
|
333
|
+
if @local
|
334
|
+
return
|
335
|
+
end
|
336
|
+
unless ary and ary.length > 0
|
337
|
+
Puppet.info "No classes to store"
|
338
|
+
return
|
339
|
+
end
|
268
340
|
begin
|
269
341
|
File.open(Puppet[:classfile], "w") { |f|
|
270
342
|
f.puts ary.join("\n")
|
@@ -276,4 +348,4 @@ class Puppet::Client::MasterClient < Puppet::Client
|
|
276
348
|
end
|
277
349
|
end
|
278
350
|
|
279
|
-
# $Id: master.rb
|
351
|
+
# $Id: master.rb 1129 2006-04-21 19:14:59Z luke $
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Puppet::Client::FileClient < Puppet::Client::ProxyClient
|
2
|
+
@drivername = :FileServer
|
3
|
+
|
4
|
+
# set up the appropriate interface methods
|
5
|
+
@handler = Puppet::Server::FileServer
|
6
|
+
|
7
|
+
self.mkmethods
|
8
|
+
|
9
|
+
def initialize(hash = {})
|
10
|
+
if hash.include?(:FileServer)
|
11
|
+
unless hash[:FileServer].is_a?(Puppet::Server::FileServer)
|
12
|
+
raise Puppet::DevError, "Must pass an actual FS object"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
super(hash)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# $Id: pelement.rb 1123 2006-04-20 05:14:13Z luke $
|