puppet 0.9.2
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 +0 -0
- data/COPYING +340 -0
- data/LICENSE +17 -0
- data/README +24 -0
- data/Rakefile +294 -0
- data/TODO +4 -0
- data/bin/cf2puppet +186 -0
- data/bin/puppet +176 -0
- data/bin/puppetca +213 -0
- data/bin/puppetd +246 -0
- data/bin/puppetdoc +184 -0
- data/bin/puppetmasterd +258 -0
- data/examples/code/allatonce +13 -0
- data/examples/code/assignments +11 -0
- data/examples/code/classing +35 -0
- data/examples/code/components +73 -0
- data/examples/code/execs +16 -0
- data/examples/code/failers/badclassnoparam +10 -0
- data/examples/code/failers/badclassparam +10 -0
- data/examples/code/failers/badcompnoparam +9 -0
- data/examples/code/failers/badcompparam +9 -0
- data/examples/code/failers/badtypeparam +3 -0
- data/examples/code/file.bl +11 -0
- data/examples/code/filedefaults +10 -0
- data/examples/code/fileparsing +116 -0
- data/examples/code/filerecursion +15 -0
- data/examples/code/functions +3 -0
- data/examples/code/groups +7 -0
- data/examples/code/head +30 -0
- data/examples/code/importing +8 -0
- data/examples/code/nodes +20 -0
- data/examples/code/one +8 -0
- data/examples/code/relationships +34 -0
- data/examples/code/selectors +28 -0
- data/examples/code/simpletests +11 -0
- data/examples/code/snippets/argumentdefaults +14 -0
- data/examples/code/snippets/casestatement +39 -0
- data/examples/code/snippets/classheirarchy.pp +15 -0
- data/examples/code/snippets/classincludes.pp +17 -0
- data/examples/code/snippets/classpathtest +11 -0
- data/examples/code/snippets/dirchmod +19 -0
- data/examples/code/snippets/failmissingexecpath.pp +13 -0
- data/examples/code/snippets/falsevalues.pp +3 -0
- data/examples/code/snippets/filecreate +11 -0
- data/examples/code/snippets/implicititeration +15 -0
- data/examples/code/snippets/multipleinstances +7 -0
- data/examples/code/snippets/namevartest +9 -0
- data/examples/code/snippets/scopetest +13 -0
- data/examples/code/snippets/selectorvalues.pp +22 -0
- data/examples/code/snippets/simpledefaults +5 -0
- data/examples/code/snippets/simpleselector +38 -0
- data/examples/code/svncommit +13 -0
- data/examples/root/bin/sleeper +69 -0
- data/examples/root/etc/configfile +0 -0
- data/examples/root/etc/debian-passwd +29 -0
- data/examples/root/etc/debian-syslog.conf +71 -0
- data/examples/root/etc/init.d/sleeper +65 -0
- data/examples/root/etc/otherfile +0 -0
- data/examples/root/etc/puppet/fileserver.conf +3 -0
- data/examples/root/etc/puppet/puppetmasterd.conf +10 -0
- data/ext/module:puppet +195 -0
- data/install.rb +270 -0
- data/lib/puppet.rb +249 -0
- data/lib/puppet/base64.rb +19 -0
- data/lib/puppet/client.rb +519 -0
- data/lib/puppet/config.rb +49 -0
- data/lib/puppet/daemon.rb +208 -0
- data/lib/puppet/element.rb +71 -0
- data/lib/puppet/event.rb +259 -0
- data/lib/puppet/log.rb +321 -0
- data/lib/puppet/metric.rb +250 -0
- data/lib/puppet/parsedfile.rb +38 -0
- data/lib/puppet/parser/ast.rb +1560 -0
- data/lib/puppet/parser/interpreter.rb +150 -0
- data/lib/puppet/parser/lexer.rb +226 -0
- data/lib/puppet/parser/parser.rb +1354 -0
- data/lib/puppet/parser/scope.rb +755 -0
- data/lib/puppet/server.rb +170 -0
- data/lib/puppet/server/authstore.rb +227 -0
- data/lib/puppet/server/ca.rb +140 -0
- data/lib/puppet/server/filebucket.rb +147 -0
- data/lib/puppet/server/fileserver.rb +477 -0
- data/lib/puppet/server/logger.rb +43 -0
- data/lib/puppet/server/master.rb +103 -0
- data/lib/puppet/server/servlet.rb +247 -0
- data/lib/puppet/sslcertificates.rb +737 -0
- data/lib/puppet/statechange.rb +150 -0
- data/lib/puppet/storage.rb +95 -0
- data/lib/puppet/transaction.rb +179 -0
- data/lib/puppet/transportable.rb +151 -0
- data/lib/puppet/type.rb +1354 -0
- data/lib/puppet/type/component.rb +141 -0
- data/lib/puppet/type/cron.rb +543 -0
- data/lib/puppet/type/exec.rb +316 -0
- data/lib/puppet/type/group.rb +152 -0
- data/lib/puppet/type/nameservice.rb +3 -0
- data/lib/puppet/type/nameservice/netinfo.rb +173 -0
- data/lib/puppet/type/nameservice/objectadd.rb +146 -0
- data/lib/puppet/type/nameservice/posix.rb +200 -0
- data/lib/puppet/type/package.rb +420 -0
- data/lib/puppet/type/package/apt.rb +70 -0
- data/lib/puppet/type/package/dpkg.rb +108 -0
- data/lib/puppet/type/package/rpm.rb +81 -0
- data/lib/puppet/type/package/sun.rb +117 -0
- data/lib/puppet/type/package/yum.rb +58 -0
- data/lib/puppet/type/pfile.rb +569 -0
- data/lib/puppet/type/pfile/checksum.rb +219 -0
- data/lib/puppet/type/pfile/create.rb +108 -0
- data/lib/puppet/type/pfile/group.rb +129 -0
- data/lib/puppet/type/pfile/mode.rb +131 -0
- data/lib/puppet/type/pfile/source.rb +264 -0
- data/lib/puppet/type/pfile/type.rb +31 -0
- data/lib/puppet/type/pfile/uid.rb +166 -0
- data/lib/puppet/type/pfilebucket.rb +80 -0
- data/lib/puppet/type/pprocess.rb +97 -0
- data/lib/puppet/type/service.rb +347 -0
- data/lib/puppet/type/service/base.rb +17 -0
- data/lib/puppet/type/service/debian.rb +50 -0
- data/lib/puppet/type/service/init.rb +145 -0
- data/lib/puppet/type/service/smf.rb +29 -0
- data/lib/puppet/type/state.rb +182 -0
- data/lib/puppet/type/symlink.rb +183 -0
- data/lib/puppet/type/tidy.rb +183 -0
- data/lib/puppet/type/typegen.rb +149 -0
- data/lib/puppet/type/typegen/filerecord.rb +243 -0
- data/lib/puppet/type/typegen/filetype.rb +316 -0
- data/lib/puppet/type/user.rb +290 -0
- data/lib/puppet/util.rb +138 -0
- data/test/certmgr/certmgr.rb +265 -0
- data/test/client/client.rb +203 -0
- data/test/executables/puppetbin.rb +53 -0
- data/test/executables/puppetca.rb +79 -0
- data/test/executables/puppetd.rb +71 -0
- data/test/executables/puppetmasterd.rb +153 -0
- data/test/executables/puppetmodule.rb +60 -0
- data/test/language/ast.rb +412 -0
- data/test/language/interpreter.rb +71 -0
- data/test/language/scope.rb +412 -0
- data/test/language/snippets.rb +445 -0
- data/test/other/events.rb +111 -0
- data/test/other/log.rb +195 -0
- data/test/other/metrics.rb +92 -0
- data/test/other/overrides.rb +115 -0
- data/test/other/parsedfile.rb +31 -0
- data/test/other/relationships.rb +113 -0
- data/test/other/state.rb +106 -0
- data/test/other/storage.rb +39 -0
- data/test/other/transactions.rb +235 -0
- data/test/parser/lexer.rb +120 -0
- data/test/parser/parser.rb +180 -0
- data/test/puppet/conffiles.rb +104 -0
- data/test/puppet/defaults.rb +100 -0
- data/test/puppet/error.rb +23 -0
- data/test/puppet/utiltest.rb +120 -0
- data/test/puppettest.rb +774 -0
- data/test/server/authstore.rb +209 -0
- data/test/server/bucket.rb +227 -0
- data/test/server/ca.rb +201 -0
- data/test/server/fileserver.rb +710 -0
- data/test/server/logger.rb +175 -0
- data/test/server/master.rb +150 -0
- data/test/server/server.rb +130 -0
- data/test/tagging/tagging.rb +80 -0
- data/test/test +51 -0
- data/test/types/basic.rb +119 -0
- data/test/types/component.rb +272 -0
- data/test/types/cron.rb +261 -0
- data/test/types/exec.rb +273 -0
- data/test/types/file.rb +616 -0
- data/test/types/filebucket.rb +167 -0
- data/test/types/fileignoresource.rb +287 -0
- data/test/types/filesources.rb +587 -0
- data/test/types/filetype.rb +162 -0
- data/test/types/group.rb +271 -0
- data/test/types/package.rb +205 -0
- data/test/types/query.rb +101 -0
- data/test/types/service.rb +100 -0
- data/test/types/symlink.rb +93 -0
- data/test/types/tidy.rb +124 -0
- data/test/types/type.rb +135 -0
- data/test/types/user.rb +371 -0
- metadata +243 -0
@@ -0,0 +1,219 @@
|
|
1
|
+
# Keep a copy of the file checksums, and notify when they change.
|
2
|
+
|
3
|
+
# This state never actually modifies the system, it only notices when the system
|
4
|
+
# changes on its own.
|
5
|
+
module Puppet
|
6
|
+
class State
|
7
|
+
class PFileChecksum < Puppet::State
|
8
|
+
@doc = "How to check whether a file has changed. **md5**/*lite-md5*/
|
9
|
+
*time*/*mtime*"
|
10
|
+
@name = :checksum
|
11
|
+
@event = :file_modified
|
12
|
+
|
13
|
+
@unmanaged = true
|
14
|
+
|
15
|
+
@validtypes = %w{md5 md5lite timestamp mtime time}
|
16
|
+
|
17
|
+
def self.validtype?(type)
|
18
|
+
@validtypes.include?(type)
|
19
|
+
end
|
20
|
+
|
21
|
+
def checktype
|
22
|
+
@checktypes[0]
|
23
|
+
end
|
24
|
+
|
25
|
+
def getsum(checktype)
|
26
|
+
sum = ""
|
27
|
+
case checktype
|
28
|
+
when "md5", "md5lite":
|
29
|
+
unless FileTest.file?(@parent[:path])
|
30
|
+
#@parent.info "Cannot MD5 sum directory %s" %
|
31
|
+
# @parent[:path]
|
32
|
+
|
33
|
+
# because we cannot sum directories, just delete ourselves
|
34
|
+
# from the file so we won't sync
|
35
|
+
@parent.delete(self.name)
|
36
|
+
return
|
37
|
+
else
|
38
|
+
begin
|
39
|
+
File.open(@parent[:path]) { |file|
|
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
|
68
|
+
else
|
69
|
+
raise Puppet::Error, "Invalid sum type %s" % checktype
|
70
|
+
end
|
71
|
+
|
72
|
+
return sum
|
73
|
+
end
|
74
|
+
|
75
|
+
# Convert from the sum type to the stored checksum.
|
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
|
83
|
+
|
84
|
+
@checktypes << value
|
85
|
+
state = Puppet::Storage.state(self)
|
86
|
+
if hash = state[@parent[:path]]
|
87
|
+
if hash.include?(value)
|
88
|
+
return hash[value]
|
89
|
+
#@parent.debug "Found checksum %s for %s" %
|
90
|
+
# [self.should,@parent[:path]]
|
91
|
+
else
|
92
|
+
#@parent.debug "Found checksum for %s but not of type %s" %
|
93
|
+
# [@parent[:path],@checktype]
|
94
|
+
return :nosum
|
95
|
+
end
|
96
|
+
else
|
97
|
+
# We can't use :notfound here, because then it'll match on
|
98
|
+
# non-existent files
|
99
|
+
return :nosum
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Even though they can specify multiple checksums, the insync?
|
104
|
+
# mechanism can really only test against one, so we'll just retrieve
|
105
|
+
# the first specified sum type.
|
106
|
+
def retrieve
|
107
|
+
unless defined? @checktypes
|
108
|
+
@checktypes = ["md5"]
|
109
|
+
end
|
110
|
+
|
111
|
+
unless FileTest.exists?(@parent.name)
|
112
|
+
self.is = :notfound
|
113
|
+
return
|
114
|
+
end
|
115
|
+
|
116
|
+
# Just use the first allowed check type
|
117
|
+
@is = getsum(@checktypes[0])
|
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
|
128
|
+
|
129
|
+
#@parent.debug "checksum state is %s" % self.is
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
# At this point, we don't actually modify the system, we modify
|
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
|
141
|
+
|
142
|
+
if @is == :notfound
|
143
|
+
self.retrieve
|
144
|
+
|
145
|
+
if self.insync?
|
146
|
+
self.debug "Checksum is already in sync"
|
147
|
+
return nil
|
148
|
+
end
|
149
|
+
#@parent.debug "%s(%s): after refresh, is '%s'" %
|
150
|
+
# [self.class.name,@parent.name,@is]
|
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
|
166
|
+
|
167
|
+
# If the sums are different, then return an event.
|
168
|
+
if self.updatesum
|
169
|
+
return :file_modified
|
170
|
+
else
|
171
|
+
return nil
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Store the new sum to the state db.
|
176
|
+
def updatesum
|
177
|
+
result = false
|
178
|
+
state = Puppet::Storage.state(self)
|
179
|
+
unless state.include?(@parent.name)
|
180
|
+
self.debug "Initializing state hash"
|
181
|
+
|
182
|
+
state[@parent.name] = Hash.new
|
183
|
+
end
|
184
|
+
|
185
|
+
if @is.is_a?(Symbol)
|
186
|
+
error = Puppet::Error.new("%s has invalid checksum" %
|
187
|
+
@parent.name)
|
188
|
+
raise error
|
189
|
+
#elsif @should == :notfound
|
190
|
+
# error = Puppet::Error.new("%s has invalid 'should' checksum" %
|
191
|
+
# @parent.name)
|
192
|
+
# raise error
|
193
|
+
end
|
194
|
+
|
195
|
+
# if we're replacing, vs. updating
|
196
|
+
if state[@parent.name].include?(@checktypes[0])
|
197
|
+
unless defined? @should
|
198
|
+
raise Puppet::Error.new(
|
199
|
+
("@should is not initialized for %s, even though we " +
|
200
|
+
"found a checksum") % @parent[:path]
|
201
|
+
)
|
202
|
+
end
|
203
|
+
self.debug "Replacing %s checksum %s with %s" %
|
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
|
211
|
+
end
|
212
|
+
state[@parent.name][@checktypes[0]] = @is
|
213
|
+
return result
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# $Id: checksum.rb 731 2005-10-26 04:44:25Z luke $
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module Puppet
|
2
|
+
class State
|
3
|
+
class PFileCreate < Puppet::State
|
4
|
+
require 'etc'
|
5
|
+
@doc = "Whether to create files that don't currently exist.
|
6
|
+
**false**/*true*/*file*/*directory*"
|
7
|
+
@name = :create
|
8
|
+
@event = :file_created
|
9
|
+
|
10
|
+
def shouldprocess(value)
|
11
|
+
# default to just about anything meaning 'true'
|
12
|
+
case value
|
13
|
+
when "false", false, nil:
|
14
|
+
return false
|
15
|
+
when "true", true, "file", "plain", /^f/:
|
16
|
+
return "file"
|
17
|
+
when "directory", /^d/:
|
18
|
+
return "directory"
|
19
|
+
when :notfound:
|
20
|
+
# this is where a creation is being rolled back
|
21
|
+
return :notfound
|
22
|
+
else
|
23
|
+
raise Puppet::Error, "Cannot create files of type %s" % value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def retrieve
|
28
|
+
if stat = @parent.stat(true)
|
29
|
+
@is = stat.ftype
|
30
|
+
else
|
31
|
+
@is = :notfound
|
32
|
+
end
|
33
|
+
|
34
|
+
#self.debug "'exists' state is %s" % self.is
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def sync
|
39
|
+
event = nil
|
40
|
+
mode = @parent.should(:mode)
|
41
|
+
|
42
|
+
# First, determine if a user has been specified and if so if
|
43
|
+
# that user has write access to the parent dir
|
44
|
+
asuser = nil
|
45
|
+
if @parent.should(:owner) and ! @parent.should(:owner).is_a?(Symbol)
|
46
|
+
writeable = Puppet::Util.asuser(@parent.should(:owner)) {
|
47
|
+
FileTest.writable?(File.dirname(@parent[:path]))
|
48
|
+
}
|
49
|
+
|
50
|
+
# If the parent directory is writeable, then we execute
|
51
|
+
# as the user in question. Otherwise we'll rely on
|
52
|
+
# the 'owner' state to do things.
|
53
|
+
if writeable
|
54
|
+
asuser = @parent.should(:owner)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
begin
|
58
|
+
case self.should
|
59
|
+
when "file":
|
60
|
+
# just create an empty file
|
61
|
+
Puppet::Util.asuser(asuser, @parent.should(:group)) {
|
62
|
+
if mode
|
63
|
+
File.open(@parent[:path],"w", mode) {
|
64
|
+
}
|
65
|
+
else
|
66
|
+
File.open(@parent[:path],"w") {
|
67
|
+
}
|
68
|
+
end
|
69
|
+
}
|
70
|
+
event = :file_created
|
71
|
+
when "directory":
|
72
|
+
Puppet::Util.asuser(asuser) {
|
73
|
+
if mode
|
74
|
+
Dir.mkdir(@parent.name,mode)
|
75
|
+
else
|
76
|
+
Dir.mkdir(@parent.name)
|
77
|
+
end
|
78
|
+
}
|
79
|
+
event = :directory_created
|
80
|
+
when :notfound:
|
81
|
+
# this is where the file should be deleted...
|
82
|
+
|
83
|
+
# This value is only valid when we're rolling back a creation,
|
84
|
+
# so we verify that the file has not been modified since then.
|
85
|
+
unless FileTest.size(@parent.name) == 0
|
86
|
+
raise Puppet::Error.new(
|
87
|
+
"Created file %s has since been modified; cannot roll back."
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
File.unlink(@parent.name)
|
92
|
+
else
|
93
|
+
error = Puppet::Error.new(
|
94
|
+
"Somehow got told to create a %s file" % self.should)
|
95
|
+
raise error
|
96
|
+
end
|
97
|
+
rescue => detail
|
98
|
+
raise Puppet::Error.new("Could not create %s: %s" %
|
99
|
+
[self.should, detail]
|
100
|
+
)
|
101
|
+
end
|
102
|
+
return event
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# $Id: create.rb 731 2005-10-26 04:44:25Z luke $
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# Manage file group ownership.
|
2
|
+
module Puppet
|
3
|
+
class State
|
4
|
+
class PFileGroup < Puppet::State
|
5
|
+
require 'etc'
|
6
|
+
@doc = "Which group should own the file. Argument can be either group
|
7
|
+
name or group ID."
|
8
|
+
@name = :group
|
9
|
+
@event = :inode_changed
|
10
|
+
|
11
|
+
def id2name(id)
|
12
|
+
begin
|
13
|
+
group = Etc.getgrgid(id)
|
14
|
+
rescue ArgumentError
|
15
|
+
return nil
|
16
|
+
end
|
17
|
+
if group.gid == ""
|
18
|
+
return nil
|
19
|
+
else
|
20
|
+
return group.name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# We want to print names, not numbers
|
25
|
+
def is_to_s
|
26
|
+
id2name(@is) || @is
|
27
|
+
end
|
28
|
+
|
29
|
+
def should_to_s
|
30
|
+
id2name(self.should) || self.should
|
31
|
+
end
|
32
|
+
|
33
|
+
def retrieve
|
34
|
+
stat = @parent.stat(true)
|
35
|
+
|
36
|
+
self.is = stat.gid
|
37
|
+
end
|
38
|
+
|
39
|
+
def shouldprocess(value)
|
40
|
+
method = nil
|
41
|
+
gid = nil
|
42
|
+
gname = nil
|
43
|
+
|
44
|
+
if value.is_a?(Integer)
|
45
|
+
method = :getgrgid
|
46
|
+
else
|
47
|
+
method = :getgrnam
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
group = Etc.send(method,value)
|
52
|
+
|
53
|
+
# at one time, os x was putting the gid into the passwd
|
54
|
+
# field of the group struct, but that appears to not
|
55
|
+
# be the case any more
|
56
|
+
#os = Puppet::Fact["Operatingsystem"]
|
57
|
+
#case os
|
58
|
+
#when "Darwin":
|
59
|
+
# #gid = group.passwd
|
60
|
+
# gid = group.gid
|
61
|
+
#else
|
62
|
+
#end
|
63
|
+
|
64
|
+
gid = group.gid
|
65
|
+
gname = group.name
|
66
|
+
|
67
|
+
rescue ArgumentError => detail
|
68
|
+
raise Puppet::Error.new(
|
69
|
+
"Could not find group %s" % value)
|
70
|
+
rescue => detail
|
71
|
+
raise Puppet::Error.new(
|
72
|
+
"Could not find group %s: %s" % [self.should,detail])
|
73
|
+
end
|
74
|
+
if gid.nil?
|
75
|
+
raise Puppet::Error.new(
|
76
|
+
"Could not retrieve gid for %s" % @parent.name)
|
77
|
+
end
|
78
|
+
|
79
|
+
#unless Process.uid == 0
|
80
|
+
# groups = %x{groups}.chomp.split(/\s/)
|
81
|
+
# unless groups.include?(gname)
|
82
|
+
# self.notice "Cannot chgrp: not in group %s" % gname
|
83
|
+
# raise Puppet::Error.new(
|
84
|
+
# "Cannot chgrp: not in group %s" % gname)
|
85
|
+
# end
|
86
|
+
#end
|
87
|
+
|
88
|
+
if gid.nil?
|
89
|
+
raise Puppet::Error.new(
|
90
|
+
"Nil gid for %s" % @parent.name)
|
91
|
+
else
|
92
|
+
return gid
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Normal users will only be able to manage certain groups. Right now,
|
97
|
+
# we'll just let it fail, but we should probably set things up so
|
98
|
+
# that users get warned if they try to change to an unacceptable group.
|
99
|
+
def sync
|
100
|
+
if @is == :notfound
|
101
|
+
@parent.stat(true)
|
102
|
+
self.retrieve
|
103
|
+
|
104
|
+
if @is == :notfound
|
105
|
+
self.err "File '%s' does not exist; cannot chgrp" %
|
106
|
+
@parent[:path]
|
107
|
+
return nil
|
108
|
+
end
|
109
|
+
|
110
|
+
if self.insync?
|
111
|
+
return nil
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
begin
|
116
|
+
# set owner to nil so it's ignored
|
117
|
+
File.chown(nil,self.should,@parent[:path])
|
118
|
+
rescue => detail
|
119
|
+
error = Puppet::Error.new( "failed to chgrp %s to %s: %s" %
|
120
|
+
[@parent[:path], self.should, detail.message])
|
121
|
+
raise error
|
122
|
+
end
|
123
|
+
return :inode_changed
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# $Id: group.rb 731 2005-10-26 04:44:25Z luke $
|