puppet 0.9.2 → 0.13.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 +58 -0
- data/README +21 -18
- data/Rakefile +176 -36
- data/bin/puppet +34 -48
- data/bin/puppetca +41 -28
- data/bin/puppetd +87 -65
- data/bin/puppetdoc +99 -23
- data/bin/puppetmasterd +72 -91
- data/conf/redhat/client.init +80 -0
- data/conf/redhat/client.sysconfig +11 -0
- data/conf/redhat/fileserver.conf +12 -0
- data/conf/redhat/puppet.spec +130 -0
- data/conf/redhat/server.init +89 -0
- data/conf/redhat/server.sysconfig +9 -0
- data/examples/code/allatonce +2 -2
- data/examples/code/assignments +1 -1
- data/examples/code/classing +2 -2
- data/examples/code/components +2 -2
- data/examples/code/file.bl +5 -5
- data/examples/code/filedefaults +2 -2
- data/examples/code/fileparsing +1 -1
- data/examples/code/filerecursion +1 -1
- data/examples/code/functions +1 -1
- data/examples/code/groups +1 -1
- data/examples/code/importing +1 -1
- data/examples/code/nodes +1 -1
- data/examples/code/one +1 -1
- data/examples/code/relationships +2 -2
- data/examples/code/simpletests +5 -5
- data/examples/code/snippets/argumentdefaults +2 -2
- data/examples/code/snippets/casestatement +16 -8
- data/examples/code/snippets/classheirarchy.pp +4 -4
- data/examples/code/snippets/classincludes.pp +4 -4
- data/examples/code/snippets/classpathtest +2 -2
- data/examples/code/snippets/componentmetaparams.pp +11 -0
- data/examples/code/snippets/dirchmod +5 -5
- data/examples/code/snippets/emptyclass.pp +9 -0
- data/examples/code/snippets/failmissingexecpath.pp +1 -1
- data/examples/code/snippets/falsevalues.pp +1 -1
- data/examples/code/snippets/filecreate +5 -5
- data/examples/code/snippets/implicititeration +5 -5
- data/examples/code/snippets/multipleinstances +4 -4
- data/examples/code/snippets/namevartest +3 -3
- data/examples/code/snippets/scopetest +1 -1
- data/examples/code/snippets/selectorvalues.pp +3 -3
- data/examples/code/snippets/simpledefaults +2 -2
- data/examples/code/snippets/simpleselector +5 -5
- data/examples/code/snippets/singleary.pp +19 -0
- data/examples/root/etc/init.d/sleeper +3 -2
- data/ext/emacs/puppet-mode-init.el +6 -0
- data/ext/emacs/puppet-mode.el +189 -0
- data/ext/ldap/puppet.schema +17 -0
- data/ext/{module:puppet → module_puppet} +30 -31
- data/ext/vim/filetype.vim +9 -0
- data/ext/vim/puppet.vim +87 -0
- data/install.rb +63 -30
- data/lib/puppet.rb +216 -122
- data/lib/puppet/client.rb +51 -416
- data/lib/puppet/client/ca.rb +17 -0
- data/lib/puppet/client/dipper.rb +78 -0
- data/lib/puppet/client/file.rb +20 -0
- data/lib/puppet/client/log.rb +17 -0
- data/lib/puppet/client/master.rb +246 -0
- data/lib/puppet/client/proxy.rb +27 -0
- data/lib/puppet/client/status.rb +7 -0
- data/lib/puppet/config.rb +563 -13
- data/lib/puppet/daemon.rb +50 -22
- data/lib/puppet/element.rb +4 -4
- data/lib/puppet/event-loop.rb +1 -0
- data/lib/puppet/event-loop/better-definers.rb +367 -0
- data/lib/puppet/event-loop/event-loop.rb +355 -0
- data/lib/puppet/event-loop/signal-system.rb +220 -0
- data/lib/puppet/event.rb +9 -11
- data/lib/puppet/filetype.rb +195 -0
- data/lib/puppet/log.rb +35 -12
- data/lib/puppet/metric.rb +2 -2
- data/lib/puppet/networkclient.rb +145 -0
- data/lib/puppet/parameter.rb +335 -0
- data/lib/puppet/parser/ast.rb +42 -1453
- data/lib/puppet/parser/ast/astarray.rb +88 -0
- data/lib/puppet/parser/ast/branch.rb +47 -0
- data/lib/puppet/parser/ast/caseopt.rb +66 -0
- data/lib/puppet/parser/ast/casestatement.rb +78 -0
- data/lib/puppet/parser/ast/classdef.rb +78 -0
- data/lib/puppet/parser/ast/compdef.rb +111 -0
- data/lib/puppet/parser/ast/component.rb +105 -0
- data/lib/puppet/parser/ast/hostclass.rb +82 -0
- data/lib/puppet/parser/ast/leaf.rb +86 -0
- data/lib/puppet/parser/ast/node.rb +103 -0
- data/lib/puppet/parser/ast/nodedef.rb +68 -0
- data/lib/puppet/parser/ast/objectdef.rb +336 -0
- data/lib/puppet/parser/ast/objectparam.rb +30 -0
- data/lib/puppet/parser/ast/objectref.rb +76 -0
- data/lib/puppet/parser/ast/selector.rb +60 -0
- data/lib/puppet/parser/ast/typedefaults.rb +45 -0
- data/lib/puppet/parser/ast/vardef.rb +44 -0
- data/lib/puppet/parser/interpreter.rb +31 -14
- data/lib/puppet/parser/lexer.rb +2 -4
- data/lib/puppet/parser/parser.rb +332 -242
- data/lib/puppet/parser/scope.rb +55 -38
- data/lib/puppet/server.rb +43 -44
- data/lib/puppet/server/authstore.rb +3 -6
- data/lib/puppet/server/ca.rb +5 -2
- data/lib/puppet/server/filebucket.rb +2 -4
- data/lib/puppet/server/fileserver.rb +28 -12
- data/lib/puppet/server/logger.rb +15 -4
- data/lib/puppet/server/master.rb +62 -7
- data/lib/puppet/sslcertificates.rb +41 -607
- data/lib/puppet/sslcertificates/ca.rb +291 -0
- data/lib/puppet/sslcertificates/certificate.rb +283 -0
- data/lib/puppet/statechange.rb +6 -1
- data/lib/puppet/storage.rb +67 -56
- data/lib/puppet/transaction.rb +25 -9
- data/lib/puppet/transportable.rb +102 -22
- data/lib/puppet/type.rb +1096 -315
- data/lib/puppet/type/component.rb +30 -21
- data/lib/puppet/type/cron.rb +409 -448
- data/lib/puppet/type/exec.rb +234 -174
- data/lib/puppet/type/group.rb +65 -82
- data/lib/puppet/type/nameservice.rb +247 -3
- data/lib/puppet/type/nameservice/netinfo.rb +29 -40
- data/lib/puppet/type/nameservice/objectadd.rb +52 -66
- data/lib/puppet/type/nameservice/posix.rb +6 -194
- data/lib/puppet/type/package.rb +447 -295
- data/lib/puppet/type/package/apt.rb +51 -50
- data/lib/puppet/type/package/bsd.rb +82 -0
- data/lib/puppet/type/package/dpkg.rb +85 -88
- data/lib/puppet/type/package/rpm.rb +67 -63
- data/lib/puppet/type/package/sun.rb +119 -98
- data/lib/puppet/type/package/yum.rb +41 -37
- data/lib/puppet/type/parsedtype.rb +295 -0
- data/lib/puppet/type/parsedtype/host.rb +143 -0
- data/lib/puppet/type/parsedtype/port.rb +232 -0
- data/lib/puppet/type/parsedtype/sshkey.rb +129 -0
- data/lib/puppet/type/pfile.rb +484 -460
- data/lib/puppet/type/pfile/checksum.rb +237 -181
- data/lib/puppet/type/pfile/content.rb +67 -0
- data/lib/puppet/type/pfile/ensure.rb +212 -0
- data/lib/puppet/type/pfile/group.rb +106 -105
- data/lib/puppet/type/pfile/mode.rb +98 -101
- data/lib/puppet/type/pfile/source.rb +228 -209
- data/lib/puppet/type/pfile/type.rb +18 -21
- data/lib/puppet/type/pfile/uid.rb +127 -130
- data/lib/puppet/type/pfilebucket.rb +68 -63
- data/lib/puppet/type/schedule.rb +341 -0
- data/lib/puppet/type/service.rb +351 -255
- data/lib/puppet/type/service/base.rb +9 -14
- data/lib/puppet/type/service/debian.rb +32 -38
- data/lib/puppet/type/service/init.rb +130 -130
- data/lib/puppet/type/service/smf.rb +48 -20
- data/lib/puppet/type/state.rb +229 -16
- data/lib/puppet/type/symlink.rb +51 -63
- data/lib/puppet/type/tidy.rb +105 -102
- data/lib/puppet/type/user.rb +118 -180
- data/lib/puppet/util.rb +100 -6
- data/test/certmgr/certmgr.rb +0 -1
- data/test/client/client.rb +4 -4
- data/test/executables/puppetbin.rb +7 -14
- data/test/executables/puppetca.rb +18 -24
- data/test/executables/puppetd.rb +7 -16
- data/test/executables/puppetmasterd.rb +7 -9
- data/test/executables/puppetmodule.rb +11 -16
- data/test/language/ast.rb +11 -7
- data/test/language/interpreter.rb +1 -1
- data/test/language/scope.rb +2 -0
- data/test/language/snippets.rb +30 -5
- data/test/language/transportable.rb +77 -0
- data/test/other/config.rb +316 -0
- data/test/other/events.rb +22 -21
- data/test/other/log.rb +14 -14
- data/test/other/metrics.rb +4 -8
- data/test/other/overrides.rb +5 -5
- data/test/other/relationships.rb +4 -2
- data/test/other/storage.rb +64 -3
- data/test/other/transactions.rb +20 -20
- data/test/parser/parser.rb +7 -4
- data/test/puppet/conffiles.rb +12 -12
- data/test/puppet/defaults.rb +13 -11
- data/test/puppet/utiltest.rb +14 -11
- data/test/puppettest.rb +156 -48
- data/test/server/bucket.rb +2 -2
- data/test/server/fileserver.rb +6 -6
- data/test/server/logger.rb +19 -11
- data/test/server/master.rb +33 -4
- data/test/server/server.rb +2 -7
- data/test/types/basic.rb +5 -7
- data/test/types/component.rb +22 -18
- data/test/types/cron.rb +111 -44
- data/test/types/exec.rb +116 -59
- data/test/types/file.rb +262 -137
- data/test/types/filebucket.rb +13 -15
- data/test/types/fileignoresource.rb +12 -16
- data/test/types/filesources.rb +73 -48
- data/test/types/filetype.rb +13 -15
- data/test/types/group.rb +15 -13
- data/test/types/host.rb +146 -0
- data/test/types/package.rb +74 -63
- data/test/types/port.rb +139 -0
- data/test/types/query.rb +8 -8
- data/test/types/schedule.rb +335 -0
- data/test/types/service.rb +137 -21
- data/test/types/sshkey.rb +140 -0
- data/test/types/symlink.rb +3 -5
- data/test/types/tidy.rb +5 -14
- data/test/types/type.rb +67 -11
- data/test/types/user.rb +25 -23
- metadata +186 -122
- data/lib/puppet/type/pfile/create.rb +0 -108
- data/lib/puppet/type/pprocess.rb +0 -97
- data/lib/puppet/type/typegen.rb +0 -149
- data/lib/puppet/type/typegen/filerecord.rb +0 -243
- data/lib/puppet/type/typegen/filetype.rb +0 -316
- data/test/other/state.rb +0 -106
data/lib/puppet/event.rb
CHANGED
@@ -158,7 +158,12 @@ module Puppet
|
|
158
158
|
end
|
159
159
|
|
160
160
|
def source
|
161
|
-
self.class.retrieve(@source)
|
161
|
+
if source = self.class.retrieve(@source)
|
162
|
+
return source
|
163
|
+
else
|
164
|
+
raise Puppet::Error, "Could not retreive dependency %s[%s]" %
|
165
|
+
@source
|
166
|
+
end
|
162
167
|
end
|
163
168
|
|
164
169
|
def sourcearray
|
@@ -192,7 +197,7 @@ module Puppet
|
|
192
197
|
end
|
193
198
|
|
194
199
|
if transaction.triggered?(self.target, @callback) > 0
|
195
|
-
|
200
|
+
self.target.info "already applied %s" % [@callback]
|
196
201
|
else
|
197
202
|
# We need to call the method, so that it gets retrieved
|
198
203
|
# as a real object.
|
@@ -201,6 +206,7 @@ module Puppet
|
|
201
206
|
# [@source,@event,@method,target]
|
202
207
|
begin
|
203
208
|
if target.respond_to?(@callback)
|
209
|
+
target.log "triggering %s" % @callback
|
204
210
|
event = target.send(@callback)
|
205
211
|
else
|
206
212
|
Puppet.debug(
|
@@ -240,14 +246,6 @@ module Puppet
|
|
240
246
|
@event = args[:event]
|
241
247
|
@source = args[:source]
|
242
248
|
@transaction = args[:transaction]
|
243
|
-
|
244
|
-
#Puppet.info "%s: %s(%s)" %
|
245
|
-
#Puppet.info "%s: %s changed from %s to %s" %
|
246
|
-
# [@object,@state.name, @state.is,@state.should]
|
247
|
-
|
248
|
-
# initially, just stuff all instances into a central bucket
|
249
|
-
# to be handled as a batch
|
250
|
-
#@@events.push self
|
251
249
|
end
|
252
250
|
|
253
251
|
def to_s
|
@@ -256,4 +254,4 @@ module Puppet
|
|
256
254
|
end
|
257
255
|
end
|
258
256
|
|
259
|
-
# $Id: event.rb
|
257
|
+
# $Id: event.rb 841 2006-01-18 17:24:15Z luke $
|
@@ -0,0 +1,195 @@
|
|
1
|
+
module Puppet
|
2
|
+
# Basic classes for reading, writing, and emptying files. Not much
|
3
|
+
# to see here.
|
4
|
+
class FileType
|
5
|
+
attr_accessor :loaded, :path, :synced
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :name
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.inspect
|
12
|
+
"SvcType(#{self.name})"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.to_s
|
16
|
+
"SvcType(#{self.name})"
|
17
|
+
end
|
18
|
+
|
19
|
+
def svctype
|
20
|
+
self.class.name
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.newfiletype(name, &block)
|
24
|
+
@filetypes ||= {}
|
25
|
+
|
26
|
+
klass = Class.new(self)
|
27
|
+
|
28
|
+
klass.name = name
|
29
|
+
|
30
|
+
klass.class_eval(&block)
|
31
|
+
|
32
|
+
const_set(name.to_s.capitalize, klass)
|
33
|
+
|
34
|
+
# Rename the read and write methods, so that we're sure they
|
35
|
+
# maintain the stats.
|
36
|
+
klass.class_eval do
|
37
|
+
# Rename the read method
|
38
|
+
define_method(:real_read, instance_method(:read))
|
39
|
+
define_method(:read) do
|
40
|
+
begin
|
41
|
+
val = real_read()
|
42
|
+
@loaded = Time.now
|
43
|
+
return val.gsub(/# HEADER.*\n/,'')
|
44
|
+
rescue Puppet::Error => detail
|
45
|
+
raise
|
46
|
+
rescue => detail
|
47
|
+
raise Puppet::Error, "%s could not read %s: %s" %
|
48
|
+
[self.class, @path, detail]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# And then the write method
|
53
|
+
define_method(:real_write, instance_method(:write))
|
54
|
+
define_method(:write) do |text|
|
55
|
+
begin
|
56
|
+
val = real_write(text)
|
57
|
+
@synced = Time.now
|
58
|
+
return val
|
59
|
+
rescue Puppet::Error => detail
|
60
|
+
raise
|
61
|
+
rescue => detail
|
62
|
+
if Puppet[:debug]
|
63
|
+
puts detail.backtrace
|
64
|
+
end
|
65
|
+
raise Puppet::Error, "%s could not write %s: %s" %
|
66
|
+
[self.class, @path, detail]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
@filetypes[name] = klass
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.filetype(type)
|
75
|
+
@filetypes[type]
|
76
|
+
end
|
77
|
+
|
78
|
+
def initialize(path)
|
79
|
+
@path = path
|
80
|
+
end
|
81
|
+
|
82
|
+
# Operate on plain files.
|
83
|
+
newfiletype(:flat) do
|
84
|
+
# Read the file.
|
85
|
+
def read
|
86
|
+
if File.exists?(@path)
|
87
|
+
File.read(@path)
|
88
|
+
else
|
89
|
+
return nil
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Remove the file.
|
94
|
+
def remove
|
95
|
+
if File.exists?(@path)
|
96
|
+
File.unlink(@path)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Overwrite the file.
|
101
|
+
def write(text)
|
102
|
+
File.open(@path, "w") { |f| f.print text; f.flush }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Operate on plain files.
|
107
|
+
newfiletype(:ram) do
|
108
|
+
def initialize(path)
|
109
|
+
super
|
110
|
+
@text = ""
|
111
|
+
end
|
112
|
+
|
113
|
+
# Read the file.
|
114
|
+
def read
|
115
|
+
Puppet.info "Reading %s" % @path
|
116
|
+
@text
|
117
|
+
end
|
118
|
+
|
119
|
+
# Remove the file.
|
120
|
+
def remove
|
121
|
+
Puppet.info "Removing %s" % @path
|
122
|
+
@text = ""
|
123
|
+
end
|
124
|
+
|
125
|
+
# Overwrite the file.
|
126
|
+
def write(text)
|
127
|
+
Puppet.info "Writing %s" % @path
|
128
|
+
@text = text
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Handle Linux-style cron tabs.
|
133
|
+
newfiletype(:crontab) do
|
134
|
+
# Only add the -u flag when the @path is different. Fedora apparently
|
135
|
+
# does not think I should be allowed to set the @path to my
|
136
|
+
def cmdbase
|
137
|
+
uid = CronType.uid(@path)
|
138
|
+
cmd = nil
|
139
|
+
if uid == Process.uid
|
140
|
+
return "crontab"
|
141
|
+
else
|
142
|
+
return "crontab -u #{@path}"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Read a specific @path's cron tab.
|
147
|
+
def read
|
148
|
+
%x{#{cmdbase(@path)} -l 2>/dev/null}
|
149
|
+
end
|
150
|
+
|
151
|
+
# Remove a specific @path's cron tab.
|
152
|
+
def remove
|
153
|
+
%x{#{cmdbase(@path)} -r 2>/dev/null}
|
154
|
+
end
|
155
|
+
|
156
|
+
# Overwrite a specific @path's cron tab; must be passed the @path name
|
157
|
+
# and the text with which to create the cron tab.
|
158
|
+
def write(text)
|
159
|
+
IO.popen("#{cmdbase(@path)} -", "w") { |p|
|
160
|
+
p.print text
|
161
|
+
}
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# SunOS has completely different cron commands; this class implements
|
166
|
+
# its versions.
|
167
|
+
newfiletype(:suntab) do
|
168
|
+
# Read a specific @path's cron tab.
|
169
|
+
def read
|
170
|
+
Puppet::Util.asuser(@path) {
|
171
|
+
%x{crontab -l 2>/dev/null}
|
172
|
+
}
|
173
|
+
end
|
174
|
+
|
175
|
+
# Remove a specific @path's cron tab.
|
176
|
+
def remove
|
177
|
+
Puppet::Util.asuser(@path) {
|
178
|
+
%x{crontab -r 2>/dev/null}
|
179
|
+
}
|
180
|
+
end
|
181
|
+
|
182
|
+
# Overwrite a specific @path's cron tab; must be passed the @path name
|
183
|
+
# and the text with which to create the cron tab.
|
184
|
+
def write(text)
|
185
|
+
Puppet::Util.asuser(@path) {
|
186
|
+
IO.popen("crontab", "w") { |p|
|
187
|
+
p.print text
|
188
|
+
}
|
189
|
+
}
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# $Id: filetype.rb 848 2006-01-24 06:01:58Z luke $
|
data/lib/puppet/log.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'syslog'
|
2
2
|
|
3
|
-
module Puppet
|
3
|
+
module Puppet
|
4
4
|
# Pass feedback to the user. Log levels are modeled after syslog's, and it is
|
5
5
|
# expected that that will be the most common log destination. Supports
|
6
6
|
# multiple destinations, one of which is a remote server.
|
@@ -27,14 +27,14 @@ module Puppet # :nodoc:
|
|
27
27
|
:crit => RESET
|
28
28
|
}
|
29
29
|
|
30
|
-
|
30
|
+
#@destinations = {:syslog => Syslog.open("puppet")}
|
31
|
+
@destinations = {:console => :console}
|
31
32
|
|
32
33
|
# Reset all logs to basics. Basically just closes all files and undefs
|
33
34
|
# all of the other objects.
|
34
35
|
def Log.close(dest = nil)
|
35
36
|
if dest
|
36
37
|
if @destinations.include?(dest)
|
37
|
-
Puppet.warning "Closing %s" % dest
|
38
38
|
if @destinations.respond_to?(:close)
|
39
39
|
@destinations[dest].close
|
40
40
|
end
|
@@ -67,6 +67,12 @@ module Puppet # :nodoc:
|
|
67
67
|
# Create a new log message. The primary role of this method is to
|
68
68
|
# avoid creating log messages below the loglevel.
|
69
69
|
def Log.create(hash)
|
70
|
+
unless hash.include?(:level)
|
71
|
+
raise Puppet::DevError, "Logs require a level"
|
72
|
+
end
|
73
|
+
unless @levels.index(hash[:level])
|
74
|
+
raise Puppet::DevError, "Invalid log level %s" % hash[:level]
|
75
|
+
end
|
70
76
|
if @levels.index(hash[:level]) >= @loglevel
|
71
77
|
return Puppet::Log.new(hash)
|
72
78
|
else
|
@@ -74,6 +80,10 @@ module Puppet # :nodoc:
|
|
74
80
|
end
|
75
81
|
end
|
76
82
|
|
83
|
+
def Log.destinations
|
84
|
+
return @destinations.keys
|
85
|
+
end
|
86
|
+
|
77
87
|
# Yield each valid level in turn
|
78
88
|
def Log.eachlevel
|
79
89
|
@levels.each { |level| yield level }
|
@@ -153,12 +163,15 @@ module Puppet # :nodoc:
|
|
153
163
|
end
|
154
164
|
end
|
155
165
|
|
156
|
-
# Route the actual message. FIXME There are lots of things this method
|
157
|
-
# do, like caching, storing messages when there are not yet
|
158
|
-
# a bit more.
|
159
|
-
#
|
160
|
-
#
|
166
|
+
# Route the actual message. FIXME There are lots of things this method
|
167
|
+
# should do, like caching, storing messages when there are not yet
|
168
|
+
# destinations, a bit more. It's worth noting that there's a potential
|
169
|
+
# for a loop here, if the machine somehow gets the destination set as
|
170
|
+
# itself.
|
161
171
|
def Log.newmessage(msg)
|
172
|
+
if @levels.index(msg.level) < @loglevel
|
173
|
+
return
|
174
|
+
end
|
162
175
|
@destinations.each { |type, dest|
|
163
176
|
case dest
|
164
177
|
when Module # This is the Syslog module
|
@@ -170,7 +183,9 @@ module Puppet # :nodoc:
|
|
170
183
|
dest.send(msg.level, msg.to_s.gsub("%", '%%'))
|
171
184
|
else
|
172
185
|
dest.send(msg.level, "(%s) %s" %
|
173
|
-
[msg.source.to_s.gsub("%", ""),
|
186
|
+
[msg.source.to_s.gsub("%", ""),
|
187
|
+
msg.to_s.gsub("%", '%%')
|
188
|
+
]
|
174
189
|
)
|
175
190
|
end
|
176
191
|
when File:
|
@@ -207,9 +222,9 @@ module Puppet # :nodoc:
|
|
207
222
|
begin
|
208
223
|
#puts "would have sent %s" % msg
|
209
224
|
#puts "would have sent %s" %
|
210
|
-
# CGI.escape(
|
225
|
+
# CGI.escape(YAML.dump(msg))
|
211
226
|
begin
|
212
|
-
tmp = CGI.escape(
|
227
|
+
tmp = CGI.escape(YAML.dump(msg))
|
213
228
|
rescue => detail
|
214
229
|
puts "Could not dump: %s" % detail.to_s
|
215
230
|
return
|
@@ -230,6 +245,10 @@ module Puppet # :nodoc:
|
|
230
245
|
}
|
231
246
|
end
|
232
247
|
|
248
|
+
def Log.sendlevel?(level)
|
249
|
+
@levels.index(level) >= @loglevel
|
250
|
+
end
|
251
|
+
|
233
252
|
# Reopen all of our logs.
|
234
253
|
def Log.reopen
|
235
254
|
types = @destinations.keys
|
@@ -273,6 +292,10 @@ module Puppet # :nodoc:
|
|
273
292
|
raise Puppet::DevError,
|
274
293
|
"Level is not a string or symbol: #{args[:level].class}"
|
275
294
|
end
|
295
|
+
|
296
|
+
# Just return unless we're actually at a level we should send
|
297
|
+
#return unless self.class.sendlevel?(@level)
|
298
|
+
|
276
299
|
@message = args[:message].to_s
|
277
300
|
@time = Time.now
|
278
301
|
# this should include the host name, and probly lots of other
|
@@ -318,4 +341,4 @@ module Puppet # :nodoc:
|
|
318
341
|
end
|
319
342
|
end
|
320
343
|
|
321
|
-
# $Id: log.rb
|
344
|
+
# $Id: log.rb 873 2006-02-07 23:12:33Z luke $
|
data/lib/puppet/metric.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# included so we can test object types
|
2
2
|
require 'puppet'
|
3
3
|
|
4
|
-
module Puppet
|
4
|
+
module Puppet
|
5
5
|
# A class for handling metrics. This is currently ridiculously hackish.
|
6
6
|
class Metric
|
7
7
|
def Metric.init
|
@@ -247,4 +247,4 @@ module Puppet # :nodoc:
|
|
247
247
|
end
|
248
248
|
end
|
249
249
|
|
250
|
-
# $Id: metric.rb
|
250
|
+
# $Id: metric.rb 846 2006-01-20 20:38:01Z luke $
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'puppet'
|
2
|
+
require 'puppet/sslcertificates'
|
3
|
+
require 'puppet/type'
|
4
|
+
require 'facter'
|
5
|
+
require 'openssl'
|
6
|
+
require 'puppet/transaction'
|
7
|
+
require 'puppet/transportable'
|
8
|
+
require 'puppet/metric'
|
9
|
+
require 'puppet/daemon'
|
10
|
+
require 'puppet/server'
|
11
|
+
require 'puppet/base64'
|
12
|
+
|
13
|
+
$noclientnetworking = false
|
14
|
+
begin
|
15
|
+
require 'webrick'
|
16
|
+
require 'cgi'
|
17
|
+
require 'xmlrpc/client'
|
18
|
+
require 'xmlrpc/server'
|
19
|
+
require 'yaml'
|
20
|
+
rescue LoadError => detail
|
21
|
+
$noclientnetworking = detail
|
22
|
+
raise Puppet::Error, "You must have the Ruby XMLRPC, CGI, and Webrick libraries installed"
|
23
|
+
end
|
24
|
+
|
25
|
+
module Puppet
|
26
|
+
class NetworkClientError < RuntimeError; end
|
27
|
+
class ClientError < RuntimeError; end
|
28
|
+
#---------------------------------------------------------------
|
29
|
+
if $noclientnetworking
|
30
|
+
Puppet.err "Could not load client network libs: %s" % $noclientnetworking
|
31
|
+
else
|
32
|
+
class NetworkClient < XMLRPC::Client
|
33
|
+
#include Puppet::Daemon
|
34
|
+
|
35
|
+
# add the methods associated with each namespace
|
36
|
+
Puppet::Server::Handler.each { |handler|
|
37
|
+
interface = handler.interface
|
38
|
+
namespace = interface.prefix
|
39
|
+
|
40
|
+
interface.methods.each { |ary|
|
41
|
+
method = ary[0]
|
42
|
+
Puppet.info "Defining %s.%s" % [namespace, method]
|
43
|
+
self.send(:define_method,method) { |*args|
|
44
|
+
#Puppet.info "Calling %s" % method
|
45
|
+
#Puppet.info "peer cert is %s" % @http.peer_cert
|
46
|
+
#Puppet.info "cert is %s" % @http.cert
|
47
|
+
begin
|
48
|
+
call("%s.%s" % [namespace, method.to_s],*args)
|
49
|
+
rescue OpenSSL::SSL::SSLError => detail
|
50
|
+
#Puppet.err "Could not call %s.%s: Untrusted certificates" %
|
51
|
+
# [namespace, method]
|
52
|
+
raise NetworkClientError,
|
53
|
+
"Certificates were not trusted"
|
54
|
+
rescue XMLRPC::FaultException => detail
|
55
|
+
#Puppet.err "Could not call %s.%s: %s" %
|
56
|
+
# [namespace, method, detail.faultString]
|
57
|
+
#raise NetworkClientError,
|
58
|
+
# "XMLRPC Error: %s" % detail.faultString
|
59
|
+
raise NetworkClientError, detail.faultString
|
60
|
+
rescue Errno::ECONNREFUSED => detail
|
61
|
+
msg = "Could not connect to %s on port %s" % [@host, @port]
|
62
|
+
#Puppet.err msg
|
63
|
+
raise NetworkClientError, msg
|
64
|
+
rescue SocketError => detail
|
65
|
+
Puppet.err "Could not find server %s" % @puppetserver
|
66
|
+
exit(12)
|
67
|
+
rescue => detail
|
68
|
+
Puppet.err "Could not call %s.%s: %s" %
|
69
|
+
[namespace, method, detail.inspect]
|
70
|
+
#raise NetworkClientError.new(detail.to_s)
|
71
|
+
raise
|
72
|
+
end
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
def ca_file=(cafile)
|
78
|
+
@http.ca_file = cafile
|
79
|
+
store = OpenSSL::X509::Store.new
|
80
|
+
cacert = OpenSSL::X509::Certificate.new(
|
81
|
+
File.read(cafile)
|
82
|
+
)
|
83
|
+
store.add_cert(cacert)
|
84
|
+
store.purpose = OpenSSL::X509::PURPOSE_SSL_CLIENT
|
85
|
+
@http.cert_store = store
|
86
|
+
end
|
87
|
+
|
88
|
+
def cert=(cert)
|
89
|
+
#Puppet.debug "Adding certificate"
|
90
|
+
@http.cert = cert
|
91
|
+
@http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
92
|
+
end
|
93
|
+
|
94
|
+
def key=(key)
|
95
|
+
@http.key = key
|
96
|
+
end
|
97
|
+
|
98
|
+
def initialize(hash)
|
99
|
+
hash[:Path] ||= "/RPC2"
|
100
|
+
hash[:Server] ||= "localhost"
|
101
|
+
hash[:Port] ||= Puppet[:masterport]
|
102
|
+
|
103
|
+
@puppetserver = hash[:Server]
|
104
|
+
|
105
|
+
super(
|
106
|
+
hash[:Server],
|
107
|
+
hash[:Path],
|
108
|
+
hash[:Port],
|
109
|
+
nil, # proxy_host
|
110
|
+
nil, # proxy_port
|
111
|
+
nil, # user
|
112
|
+
nil, # password
|
113
|
+
true # use_ssl
|
114
|
+
)
|
115
|
+
|
116
|
+
if hash[:Certificate]
|
117
|
+
self.cert = hash[:Certificate]
|
118
|
+
else
|
119
|
+
Puppet.err "No certificate; running with reduced functionality."
|
120
|
+
end
|
121
|
+
|
122
|
+
if hash[:Key]
|
123
|
+
self.key = hash[:Key]
|
124
|
+
end
|
125
|
+
|
126
|
+
if hash[:CAFile]
|
127
|
+
self.ca_file = hash[:CAFile]
|
128
|
+
end
|
129
|
+
|
130
|
+
# from here, i need to add the key, cert, and ca cert
|
131
|
+
# and reorgize how i start the client
|
132
|
+
end
|
133
|
+
|
134
|
+
def local
|
135
|
+
false
|
136
|
+
end
|
137
|
+
|
138
|
+
def local?
|
139
|
+
false
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# $Id: networkclient.rb 856 2006-01-30 16:18:24Z luke $
|