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
@@ -3,217 +3,273 @@
|
|
3
3
|
# This state never actually modifies the system, it only notices when the system
|
4
4
|
# changes on its own.
|
5
5
|
module Puppet
|
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
|
-
text = nil
|
41
|
-
if checktype == "md5"
|
42
|
-
text = file.read
|
43
|
-
else
|
44
|
-
text = file.read(512)
|
45
|
-
end
|
46
|
-
if text.nil?
|
47
|
-
self.info "Not checksumming empty file %s" %
|
48
|
-
@parent.name
|
49
|
-
sum = 0
|
50
|
-
else
|
51
|
-
sum = Digest::MD5.hexdigest(text)
|
52
|
-
end
|
53
|
-
}
|
54
|
-
rescue Errno::EACCES => detail
|
55
|
-
self.notice "Cannot checksum %s: permission denied" %
|
56
|
-
@parent.name
|
57
|
-
@parent.delete(self.class.name)
|
58
|
-
rescue => detail
|
59
|
-
self.notice "Cannot checksum %s: %s" %
|
60
|
-
detail
|
61
|
-
@parent.delete(self.class.name)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
when "timestamp","mtime":
|
65
|
-
sum = File.stat(@parent[:path]).mtime.to_s
|
66
|
-
when "time":
|
67
|
-
sum = File.stat(@parent[:path]).ctime.to_s
|
6
|
+
Puppet.type(:file).newstate(:checksum) do
|
7
|
+
desc "How to check whether a file has changed. **md5**/*lite-md5*/
|
8
|
+
*time*/*mtime*"
|
9
|
+
@event = :file_changed
|
10
|
+
|
11
|
+
@unmanaged = true
|
12
|
+
|
13
|
+
@validtypes = %w{md5 md5lite timestamp mtime time}
|
14
|
+
|
15
|
+
def self.validtype?(type)
|
16
|
+
@validtypes.include?(type)
|
17
|
+
end
|
18
|
+
|
19
|
+
def checktype
|
20
|
+
@checktypes[0]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Because source and content and whomever else need to set the checksum
|
24
|
+
# and do the updating, we provide a simple mechanism for doing so.
|
25
|
+
def checksum=(value)
|
26
|
+
@is = value
|
27
|
+
@should = [value]
|
28
|
+
self.updatesum
|
29
|
+
end
|
30
|
+
|
31
|
+
# Checksums need to invert how changes are printed.
|
32
|
+
def change_to_s
|
33
|
+
begin
|
34
|
+
if @is == :absent
|
35
|
+
return "defined '%s' as '%s'" %
|
36
|
+
[self.name, self.should_to_s]
|
37
|
+
elsif self.should == :absent
|
38
|
+
return "undefined %s from '%s'" %
|
39
|
+
[self.name, self.is_to_s]
|
68
40
|
else
|
69
|
-
|
41
|
+
return "%s changed '%s' to '%s'" %
|
42
|
+
[self.name, self.should_to_s, self.is_to_s]
|
70
43
|
end
|
44
|
+
rescue Puppet::Error, Puppet::DevError
|
45
|
+
raise
|
46
|
+
rescue => detail
|
47
|
+
raise Puppet::DevError, "Could not convert change %s to string: %s" %
|
48
|
+
[self.name, detail]
|
49
|
+
end
|
50
|
+
end
|
71
51
|
|
72
|
-
|
52
|
+
# Retrieve the cached sum
|
53
|
+
def getcachedsum
|
54
|
+
hash = nil
|
55
|
+
unless hash = @parent.cached(:checksums)
|
56
|
+
hash = {}
|
57
|
+
@parent.cache(:checksums, hash)
|
73
58
|
end
|
74
59
|
|
75
|
-
|
76
|
-
def shouldprocess(value)
|
77
|
-
unless defined? @checktypes
|
78
|
-
@checktypes = []
|
79
|
-
end
|
80
|
-
unless self.class.validtype?(value)
|
81
|
-
raise Puppet::Error, "Invalid checksum type '%s'" % value
|
82
|
-
end
|
60
|
+
sumtype = @checktypes[0]
|
83
61
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
return :nosum
|
100
|
-
end
|
62
|
+
#unless state
|
63
|
+
# self.devfail "Did not get state back from Storage"
|
64
|
+
#end
|
65
|
+
|
66
|
+
if hash.include?(sumtype)
|
67
|
+
#self.notice "Found checksum %s for %s" %
|
68
|
+
# [hash[sumtype] ,@parent[:path]]
|
69
|
+
return hash[sumtype]
|
70
|
+
elsif hash.empty?
|
71
|
+
#self.notice "Could not find sum of type %s" % sumtype
|
72
|
+
return :nosum
|
73
|
+
else
|
74
|
+
#self.notice "Found checksum for %s but not of type %s" %
|
75
|
+
# [@parent[:path],sumtype]
|
76
|
+
return :nosum
|
101
77
|
end
|
78
|
+
end
|
102
79
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
80
|
+
# Calculate the sum from disk.
|
81
|
+
def getsum(checktype)
|
82
|
+
sum = ""
|
83
|
+
case checktype
|
84
|
+
when "md5", "md5lite":
|
85
|
+
unless FileTest.file?(@parent[:path])
|
86
|
+
@parent.info "Cannot MD5 sum directory %s" %
|
87
|
+
@parent[:path]
|
110
88
|
|
111
|
-
|
112
|
-
|
89
|
+
# because we cannot sum directories, just delete ourselves
|
90
|
+
# from the file so we won't sync
|
91
|
+
@parent.delete(self.name)
|
113
92
|
return
|
93
|
+
else
|
94
|
+
begin
|
95
|
+
File.open(@parent[:path]) { |file|
|
96
|
+
text = nil
|
97
|
+
if checktype == "md5"
|
98
|
+
text = file.read
|
99
|
+
else
|
100
|
+
text = file.read(512)
|
101
|
+
end
|
102
|
+
if text.nil?
|
103
|
+
self.info "Not checksumming empty file %s" %
|
104
|
+
@parent.name
|
105
|
+
sum = 0
|
106
|
+
else
|
107
|
+
sum = Digest::MD5.hexdigest(text)
|
108
|
+
end
|
109
|
+
}
|
110
|
+
rescue Errno::EACCES => detail
|
111
|
+
self.notice "Cannot checksum %s: permission denied" %
|
112
|
+
@parent.name
|
113
|
+
@parent.delete(self.class.name)
|
114
|
+
rescue => detail
|
115
|
+
self.notice "Cannot checksum %s: %s" %
|
116
|
+
detail
|
117
|
+
@parent.delete(self.class.name)
|
118
|
+
end
|
114
119
|
end
|
120
|
+
when "timestamp","mtime":
|
121
|
+
sum = @parent.stat.mtime.to_s
|
122
|
+
#sum = File.stat(@parent[:path]).mtime.to_s
|
123
|
+
when "time":
|
124
|
+
sum = @parent.stat.ctime.to_s
|
125
|
+
#sum = File.stat(@parent[:path]).ctime.to_s
|
126
|
+
else
|
127
|
+
raise Puppet::Error, "Invalid sum type %s" % checktype
|
128
|
+
end
|
115
129
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
# If there is no should defined, then store the current value
|
120
|
-
# into the 'should' value, so that we're not marked as being
|
121
|
-
# out of sync. We don't want to generate an event the first
|
122
|
-
# time we get a sum.
|
123
|
-
if ! defined? @should or @should == [:nosum]
|
124
|
-
@should = [@is]
|
125
|
-
# FIXME we should support an updatechecksums-like mechanism
|
126
|
-
self.updatesum
|
127
|
-
end
|
130
|
+
return sum
|
131
|
+
end
|
128
132
|
|
129
|
-
|
133
|
+
# Convert from the sum type to the stored checksum.
|
134
|
+
munge do |value|
|
135
|
+
unless defined? @checktypes
|
136
|
+
@checktypes = []
|
137
|
+
end
|
138
|
+
unless self.class.validtype?(value)
|
139
|
+
self.fail "Invalid checksum type '%s'" % value
|
130
140
|
end
|
131
141
|
|
142
|
+
if FileTest.directory?(@parent.name)
|
143
|
+
self.info "Reverting directory sum type to timestamp"
|
144
|
+
value = "time"
|
145
|
+
end
|
132
146
|
|
133
|
-
|
134
|
-
# the stored state to reflect the current state, and then kick
|
135
|
-
# off an event to mark any changes.
|
136
|
-
def sync
|
137
|
-
if @is.nil?
|
138
|
-
raise Puppet::Error, "Checksum state for %s is somehow nil" %
|
139
|
-
@parent.name
|
140
|
-
end
|
147
|
+
@checktypes << value
|
141
148
|
|
142
|
-
|
143
|
-
|
149
|
+
return getcachedsum()
|
150
|
+
end
|
144
151
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
# If we still can't retrieve a checksum, it means that
|
153
|
-
# the file still doesn't exist
|
154
|
-
if @is == :notfound
|
155
|
-
# if they're copying, then we won't worry about the file
|
156
|
-
# not existing yet
|
157
|
-
unless @parent.state(:source)
|
158
|
-
self.warning(
|
159
|
-
"File %s does not exist -- cannot checksum" %
|
160
|
-
@parent.name
|
161
|
-
)
|
162
|
-
end
|
163
|
-
return nil
|
164
|
-
end
|
165
|
-
end
|
152
|
+
# Even though they can specify multiple checksums, the insync?
|
153
|
+
# mechanism can really only test against one, so we'll just retrieve
|
154
|
+
# the first specified sum type.
|
155
|
+
def retrieve
|
156
|
+
unless defined? @checktypes
|
157
|
+
@checktypes = ["md5"]
|
158
|
+
end
|
166
159
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
else
|
171
|
-
return nil
|
172
|
-
end
|
160
|
+
unless FileTest.exists?(@parent.name)
|
161
|
+
self.is = :absent
|
162
|
+
return
|
173
163
|
end
|
174
164
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
unless state.include?(@parent.name)
|
180
|
-
self.debug "Initializing state hash"
|
165
|
+
if FileTest.directory?(@parent.name) and @checktypes[0] =~ /md5/
|
166
|
+
self.info "Using timestamp on directory"
|
167
|
+
@checktypes = ["time"]
|
168
|
+
end
|
181
169
|
|
182
|
-
|
183
|
-
|
170
|
+
# Just use the first allowed check type
|
171
|
+
@is = getsum(@checktypes[0])
|
172
|
+
|
173
|
+
# @should should always be set, so if it's not set at all, we
|
174
|
+
# know we haven't looked in the cache yet.
|
175
|
+
unless defined? @should and ! @should.nil?
|
176
|
+
@should = [getcachedsum()]
|
177
|
+
end
|
178
|
+
|
179
|
+
# If there is no should defined, then store the current value
|
180
|
+
# into the 'should' value, so that we're not marked as being
|
181
|
+
# out of sync. We don't want to generate an event the first
|
182
|
+
# time we get a sum.
|
183
|
+
if @should == [:nosum]
|
184
|
+
self.warning "updatingness from %s" % @should.inspect
|
185
|
+
@should = [@is]
|
186
|
+
# FIXME we should support an updatechecksums-like mechanism
|
187
|
+
self.updatesum
|
188
|
+
end
|
189
|
+
|
190
|
+
#@parent.debug "checksum state is %s" % self.is
|
191
|
+
end
|
192
|
+
|
193
|
+
|
194
|
+
# At this point, we don't actually modify the system, we modify
|
195
|
+
# the stored state to reflect the current state, and then kick
|
196
|
+
# off an event to mark any changes.
|
197
|
+
def sync
|
198
|
+
if @is.nil?
|
199
|
+
raise Puppet::Error, "Checksum state for %s is somehow nil" %
|
200
|
+
@parent.name
|
201
|
+
end
|
184
202
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
# @parent.name)
|
192
|
-
# raise error
|
203
|
+
if @is == :absent
|
204
|
+
self.retrieve
|
205
|
+
|
206
|
+
if self.insync?
|
207
|
+
self.debug "Checksum is already in sync"
|
208
|
+
return nil
|
193
209
|
end
|
210
|
+
#@parent.debug "%s(%s): after refresh, is '%s'" %
|
211
|
+
# [self.class.name,@parent.name,@is]
|
194
212
|
|
195
|
-
#
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
213
|
+
# If we still can't retrieve a checksum, it means that
|
214
|
+
# the file still doesn't exist
|
215
|
+
if @is == :absent
|
216
|
+
# if they're copying, then we won't worry about the file
|
217
|
+
# not existing yet
|
218
|
+
unless @parent.state(:source)
|
219
|
+
self.warning(
|
220
|
+
"File %s does not exist -- cannot checksum" %
|
221
|
+
@parent.name
|
201
222
|
)
|
202
223
|
end
|
203
|
-
|
204
|
-
[@parent.name, state[@parent.name][@checktypes[0]],@is]
|
205
|
-
#@parent.debug "@is: %s; @should: %s" % [@is,@should]
|
206
|
-
result = true
|
207
|
-
else
|
208
|
-
@parent.debug "Creating checksum %s of type %s" %
|
209
|
-
[@is,@checktypes[0]]
|
210
|
-
result = false
|
224
|
+
return nil
|
211
225
|
end
|
212
|
-
state[@parent.name][@checktypes[0]] = @is
|
213
|
-
return result
|
214
226
|
end
|
227
|
+
|
228
|
+
# If the sums are different, then return an event.
|
229
|
+
if self.updatesum
|
230
|
+
return :file_changed
|
231
|
+
else
|
232
|
+
return nil
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
# Store the new sum to the state db.
|
237
|
+
def updatesum
|
238
|
+
result = false
|
239
|
+
state = nil
|
240
|
+
unless state = @parent.cached(:checksums)
|
241
|
+
self.debug "Initializing checksum hash for %s" % @parent.name
|
242
|
+
state = {}
|
243
|
+
@parent.cache(:checksums, state)
|
244
|
+
end
|
245
|
+
|
246
|
+
if @is.is_a?(Symbol)
|
247
|
+
error = Puppet::Error.new("%s has invalid checksum" %
|
248
|
+
@parent.name)
|
249
|
+
raise error
|
250
|
+
end
|
251
|
+
|
252
|
+
# if we're replacing, vs. updating
|
253
|
+
if state.include?(@checktypes[0])
|
254
|
+
unless defined? @should
|
255
|
+
raise Puppet::Error.new(
|
256
|
+
("@should is not initialized for %s, even though we " +
|
257
|
+
"found a checksum") % @parent[:path]
|
258
|
+
)
|
259
|
+
end
|
260
|
+
self.debug "Replacing %s checksum %s with %s" %
|
261
|
+
[@parent.name, state[@checktypes[0]],@is]
|
262
|
+
#@parent.debug "@is: %s; @should: %s" % [@is,@should]
|
263
|
+
result = true
|
264
|
+
else
|
265
|
+
@parent.debug "Creating checksum %s of type %s" %
|
266
|
+
[@is,@checktypes[0]]
|
267
|
+
result = false
|
268
|
+
end
|
269
|
+
state[@checktypes[0]] = @is
|
270
|
+
return result
|
215
271
|
end
|
216
272
|
end
|
217
273
|
end
|
218
274
|
|
219
|
-
# $Id: checksum.rb
|
275
|
+
# $Id: checksum.rb 885 2006-02-08 17:44:44Z luke $
|