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/type/tidy.rb
CHANGED
@@ -1,16 +1,92 @@
|
|
1
|
-
#!/usr/local/bin/ruby -w
|
2
|
-
|
3
|
-
# $Id: tidy.rb 731 2005-10-26 04:44:25Z luke $
|
4
1
|
|
5
2
|
require 'etc'
|
6
3
|
require 'puppet/type/state'
|
7
4
|
require 'puppet/type/pfile'
|
8
5
|
|
9
6
|
module Puppet
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
newtype(:tidy, Puppet.type(:file)) do
|
8
|
+
@doc = "Remove unwanted files based on specific criteria."
|
9
|
+
|
10
|
+
newparam(:path) do
|
11
|
+
desc "The path to the file or directory to manage. Must be fully
|
12
|
+
qualified."
|
13
|
+
isnamevar
|
14
|
+
end
|
15
|
+
|
16
|
+
copyparam(Puppet.type(:file), :backup)
|
17
|
+
|
18
|
+
newparam(:age) do
|
19
|
+
desc "Tidy files whose age is equal to or greater than
|
20
|
+
the specified number of days."
|
21
|
+
|
22
|
+
munge do |age|
|
23
|
+
case age
|
24
|
+
when /^[0-9]+$/, /^[0-9]+[dD]/:
|
25
|
+
Integer(age.gsub(/[^0-9]+/,'')) *
|
26
|
+
60 * 60 * 24
|
27
|
+
when /^[0-9]+$/, /^[0-9]+[hH]/:
|
28
|
+
Integer(age.gsub(/[^0-9]+/,'')) * 60 * 60
|
29
|
+
when /^[0-9]+[mM]/:
|
30
|
+
Integer(age.gsub(/[^0-9]+/,'')) * 60
|
31
|
+
when /^[0-9]+[sS]/:
|
32
|
+
Integer(age.gsub(/[^0-9]+/,''))
|
33
|
+
else
|
34
|
+
self.fail "Invalid tidy age %s" % age
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
newparam(:size) do
|
40
|
+
desc "Tidy files whose size is equal to or greater than
|
41
|
+
the specified size. Unqualified values are in kilobytes, but
|
42
|
+
*b*, *k*, and *m* can be appended to specify *bytes*, *kilobytes*,
|
43
|
+
and *megabytes*, respectively. Only the first character is
|
44
|
+
significant, so the full word can also be used."
|
45
|
+
|
46
|
+
munge do |size|
|
47
|
+
if FileTest.directory?(@parent[:path])
|
48
|
+
# don't do size comparisons for directories
|
49
|
+
return
|
50
|
+
end
|
51
|
+
case size
|
52
|
+
when /^[0-9]+$/, /^[0-9]+[kK]/:
|
53
|
+
Integer(size.gsub(/[^0-9]+/,'')) * 1024
|
54
|
+
when /^[0-9]+[bB]/:
|
55
|
+
Integer(size.gsub(/[^0-9]+/,''))
|
56
|
+
when /^[0-9]+[mM]/:
|
57
|
+
Integer(size.gsub(/[^0-9]+/,'')) *
|
58
|
+
1024 * 1024
|
59
|
+
else
|
60
|
+
self.fail "Invalid tidy size %s" % size
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
newparam(:type) do
|
66
|
+
desc "Set the mechanism for determining age.
|
67
|
+
**atime**/*mtime*/*ctime*."
|
68
|
+
|
69
|
+
munge do |type|
|
70
|
+
case type
|
71
|
+
when "atime", "mtime", "ctime":
|
72
|
+
type.intern
|
73
|
+
else
|
74
|
+
self.fail "Invalid tidy type %s" % type
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
newparam(:recurse) do
|
80
|
+
desc "If target is a directory, recursively descend
|
81
|
+
into the directory looking for files to tidy."
|
82
|
+
end
|
83
|
+
|
84
|
+
newparam(:rmdirs) do
|
85
|
+
desc "Tidy directories in addition to files; that is, remove
|
86
|
+
directories whose age is older than the specified criteria."
|
87
|
+
end
|
88
|
+
|
89
|
+
newstate(:tidyup) do
|
14
90
|
require 'etc'
|
15
91
|
|
16
92
|
@nodoc = true
|
@@ -69,115 +145,42 @@ module Puppet
|
|
69
145
|
File.unlink(file)
|
70
146
|
when "symlink": File.unlink(file)
|
71
147
|
else
|
72
|
-
|
148
|
+
self.fail "Cannot tidy files of type %s" %
|
73
149
|
File.lstat(file).ftype
|
74
150
|
end
|
75
151
|
|
76
152
|
return :file_tidied
|
77
153
|
end
|
78
154
|
end
|
79
|
-
end
|
80
|
-
|
81
|
-
class Type
|
82
|
-
class Tidy < PFile
|
83
|
-
|
84
|
-
# class instance variable
|
85
|
-
@states = [
|
86
|
-
Puppet::State::TidyUp
|
87
|
-
]
|
88
|
-
|
89
|
-
@parameters = [
|
90
|
-
:path,
|
91
|
-
:age,
|
92
|
-
:size,
|
93
|
-
:type,
|
94
|
-
:backup,
|
95
|
-
:rmdirs,
|
96
|
-
:recurse
|
97
|
-
]
|
98
|
-
|
99
|
-
@paramdoc[:age] = "Tidy files whose age is equal to or greater than
|
100
|
-
the specified number of days."
|
101
|
-
@paramdoc[:size] = "Tidy files whose size is equal to or greater than
|
102
|
-
the specified size. Unqualified values are in kilobytes, but
|
103
|
-
*b*, *k*, and *m* can be appended to specify *bytes*, *kilobytes*,
|
104
|
-
and *megabytes*, respectively. Only the first character is
|
105
|
-
significant, so the full word can also be used."
|
106
|
-
@paramdoc[:type] = "Set the mechanism for determining age. Access
|
107
|
-
time is the default mechanism, but modification."
|
108
|
-
@paramdoc[:recurse] = "If target is a directory, recursively descend
|
109
|
-
into the directory looking for files to tidy."
|
110
|
-
@paramdoc[:rmdirs] = "Tidy directories in addition to files."
|
111
|
-
@doc = "Remove unwanted files based on specific criteria."
|
112
|
-
@name = :tidy
|
113
|
-
@namevar = :path
|
114
155
|
|
115
|
-
|
156
|
+
# Erase PFile's validate method
|
157
|
+
validate do
|
158
|
+
end
|
116
159
|
|
117
|
-
|
118
|
-
super
|
160
|
+
@depthfirst = true
|
119
161
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
# don't do size comparisons for directories
|
124
|
-
raise Puppet::Error, "Tidy must specify size, age, or both"
|
125
|
-
end
|
126
|
-
end
|
162
|
+
def initialize(hash)
|
163
|
+
super
|
164
|
+
#self.setdefaults
|
127
165
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
132
|
-
self[:tidyup] = [:age, :size].collect { |param|
|
133
|
-
@parameters[param]
|
134
|
-
}.reject { |p| p == false }
|
135
|
-
end
|
136
|
-
|
137
|
-
def paramage=(age)
|
138
|
-
@parameters[:age] = age
|
139
|
-
case age
|
140
|
-
when /^[0-9]+$/, /^[0-9]+[dD]/:
|
141
|
-
@parameters[:age] = Integer(age.gsub(/[^0-9]+/,'')) *
|
142
|
-
60 * 60 * 24
|
143
|
-
when /^[0-9]+$/, /^[0-9]+[hH]/:
|
144
|
-
@parameters[:age] = Integer(age.gsub(/[^0-9]+/,'')) * 60 * 60
|
145
|
-
when /^[0-9]+[mM]/:
|
146
|
-
@parameters[:age] = Integer(age.gsub(/[^0-9]+/,'')) * 60
|
147
|
-
when /^[0-9]+[sS]/:
|
148
|
-
@parameters[:age] = Integer(age.gsub(/[^0-9]+/,''))
|
149
|
-
else
|
150
|
-
raise Puppet::Error.new("Invalid tidy age %s" % age)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def paramsize=(size)
|
155
|
-
if FileTest.directory?(self[:path])
|
166
|
+
unless @parameters.include?(:age) or
|
167
|
+
@parameters.include?(:size)
|
168
|
+
unless FileTest.directory?(self[:path])
|
156
169
|
# don't do size comparisons for directories
|
157
|
-
|
158
|
-
end
|
159
|
-
case size
|
160
|
-
when /^[0-9]+$/, /^[0-9]+[kK]/:
|
161
|
-
@parameters[:size] = Integer(size.gsub(/[^0-9]+/,'')) * 1024
|
162
|
-
when /^[0-9]+[bB]/:
|
163
|
-
@parameters[:size] = Integer(size.gsub(/[^0-9]+/,''))
|
164
|
-
when /^[0-9]+[mM]/:
|
165
|
-
@parameters[:size] = Integer(size.gsub(/[^0-9]+/,'')) *
|
166
|
-
1024 * 1024
|
167
|
-
else
|
168
|
-
raise Puppet::Error.new("Invalid tidy size %s" % size)
|
170
|
+
self.fail "Tidy must specify size, age, or both"
|
169
171
|
end
|
170
172
|
end
|
171
173
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
@parameters[:type] = type.intern
|
176
|
-
else
|
177
|
-
raise Puppet::Error.new("Invalid tidy type %s" % type)
|
178
|
-
end
|
174
|
+
# only allow backing up into filebuckets
|
175
|
+
unless self[:backup].is_a? Puppet::Client::Dipper
|
176
|
+
self[:backup] = false
|
179
177
|
end
|
178
|
+
self[:tidyup] = [:age, :size].collect { |param|
|
179
|
+
self[param]
|
180
|
+
}.reject { |p| p == false }
|
181
|
+
end
|
180
182
|
|
181
|
-
|
182
|
-
end # Puppet::Type
|
183
|
+
end
|
183
184
|
end
|
185
|
+
|
186
|
+
# $Id: tidy.rb 841 2006-01-18 17:24:15Z luke $
|
data/lib/puppet/type/user.rb
CHANGED
@@ -4,19 +4,27 @@ require 'puppet/type/state'
|
|
4
4
|
require 'puppet/type/nameservice'
|
5
5
|
|
6
6
|
module Puppet
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
newtype(:user, Puppet::Type::NSSType) do
|
8
|
+
case Facter["operatingsystem"].value
|
9
|
+
when "Darwin":
|
10
|
+
@parentstate = Puppet::NameService::NetInfo::NetInfoState
|
11
|
+
@parentmodule = Puppet::NameService::NetInfo
|
12
|
+
else
|
13
|
+
@parentstate = Puppet::NameService::ObjectAdd::ObjectAddUser
|
14
|
+
@parentmodule = Puppet::NameService::ObjectAdd
|
15
|
+
end
|
16
|
+
|
17
|
+
# The 'create' and 'destroy' methods are defined in type/nameservice.rb
|
18
|
+
self.ensurable()
|
19
|
+
|
20
|
+
newstate(:uid, @parentstate) do
|
21
|
+
desc "The user ID. Must be specified numerically. For new users
|
11
22
|
being created, if no user ID is specified then one will be
|
12
23
|
chosen automatically, which will likely result in the same user
|
13
24
|
having different IDs on different systems, which is not
|
14
25
|
recommended."
|
15
|
-
end
|
16
26
|
|
17
|
-
|
18
|
-
:uid
|
19
|
-
end
|
27
|
+
isautogen
|
20
28
|
|
21
29
|
def autogen
|
22
30
|
highest = 0
|
@@ -31,15 +39,15 @@ module Puppet
|
|
31
39
|
return highest + 1
|
32
40
|
end
|
33
41
|
|
34
|
-
|
42
|
+
munge do |value|
|
35
43
|
case value
|
36
44
|
when String
|
37
45
|
if value =~ /^[-0-9]+$/
|
38
46
|
value = Integer(value)
|
39
47
|
end
|
40
48
|
when Symbol
|
41
|
-
unless value == :
|
42
|
-
|
49
|
+
unless value == :absent or value == :auto
|
50
|
+
self.devfail "Invalid UID %s" % value
|
43
51
|
end
|
44
52
|
|
45
53
|
if value == :auto
|
@@ -51,17 +59,13 @@ module Puppet
|
|
51
59
|
end
|
52
60
|
end
|
53
61
|
|
54
|
-
|
55
|
-
|
56
|
-
"The user's primary group. Can be specified numerically or
|
62
|
+
newstate(:gid, @parentstate) do
|
63
|
+
desc "The user's primary group. Can be specified numerically or
|
57
64
|
by name."
|
58
|
-
end
|
59
65
|
|
60
|
-
|
61
|
-
:gid
|
62
|
-
end
|
66
|
+
isautogen
|
63
67
|
|
64
|
-
|
68
|
+
munge do |gid|
|
65
69
|
method = :getgrgid
|
66
70
|
case gid
|
67
71
|
when String
|
@@ -71,8 +75,8 @@ module Puppet
|
|
71
75
|
method = :getgrnam
|
72
76
|
end
|
73
77
|
when Symbol
|
74
|
-
unless gid == :auto or gid == :
|
75
|
-
|
78
|
+
unless gid == :auto or gid == :absent
|
79
|
+
self.devfail "Invalid GID %s" % gid
|
76
80
|
end
|
77
81
|
# these are treated specially by sync()
|
78
82
|
return gid
|
@@ -84,7 +88,7 @@ module Puppet
|
|
84
88
|
begin
|
85
89
|
ginfo = Etc.send(method, gid)
|
86
90
|
rescue ArgumentError => detail
|
87
|
-
|
91
|
+
self.fail "Could not find group %s: %s" %
|
88
92
|
[gid, detail]
|
89
93
|
end
|
90
94
|
|
@@ -93,198 +97,132 @@ module Puppet
|
|
93
97
|
end
|
94
98
|
end
|
95
99
|
|
96
|
-
|
97
|
-
|
98
|
-
"A description of the user. Generally is a user's full name."
|
99
|
-
end
|
100
|
-
|
101
|
-
def self.name
|
102
|
-
:comment
|
103
|
-
end
|
100
|
+
newstate(:comment, @parentstate) do
|
101
|
+
desc "A description of the user. Generally is a user's full name."
|
104
102
|
|
105
|
-
|
106
|
-
true
|
107
|
-
end
|
103
|
+
isoptional
|
108
104
|
|
109
|
-
|
110
|
-
:gecos
|
111
|
-
end
|
105
|
+
@posixmethod = :gecos
|
112
106
|
end
|
113
107
|
|
114
|
-
|
115
|
-
|
116
|
-
"The home directory of the user. The directory must be created
|
108
|
+
newstate(:home, @parentstate) do
|
109
|
+
desc "The home directory of the user. The directory must be created
|
117
110
|
separately and is not currently checked for existence."
|
118
|
-
end
|
119
111
|
|
120
|
-
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
def self.posixmethod
|
125
|
-
:dir
|
126
|
-
end
|
112
|
+
isautogen
|
113
|
+
@posixmethod = :dir
|
127
114
|
end
|
128
115
|
|
129
|
-
|
130
|
-
|
131
|
-
"The user's login shell. The shell must exist and be
|
116
|
+
newstate(:shell, @parentstate) do
|
117
|
+
desc "The user's login shell. The shell must exist and be
|
132
118
|
executable."
|
133
|
-
|
134
|
-
|
135
|
-
def self.name
|
136
|
-
:shell
|
137
|
-
end
|
119
|
+
isautogen
|
138
120
|
end
|
139
121
|
|
140
122
|
# these three states are all implemented differently on each platform,
|
141
123
|
# so i'm disabling them for now
|
142
124
|
|
143
125
|
# FIXME Puppet::State::UserLocked is currently non-functional
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
149
|
-
|
150
|
-
def self.name
|
151
|
-
:locked
|
152
|
-
end
|
153
|
-
end
|
126
|
+
#newstate(:locked, @parentstate) do
|
127
|
+
# desc "The expected return code. An error will be returned if the
|
128
|
+
# executed command returns something else."
|
129
|
+
#end
|
154
130
|
|
155
131
|
# FIXME Puppet::State::UserExpire is currently non-functional
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
def self.name; :expire; end
|
163
|
-
end
|
132
|
+
#newstate(:expire, @parentstate) do
|
133
|
+
# desc "The expected return code. An error will be returned if the
|
134
|
+
# executed command returns something else."
|
135
|
+
# @objectaddflag = "-e"
|
136
|
+
# isautogen
|
137
|
+
#end
|
164
138
|
|
165
139
|
# FIXME Puppet::State::UserInactive is currently non-functional
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
140
|
+
#newstate(:inactive, @parentstate) do
|
141
|
+
# desc "The expected return code. An error will be returned if the
|
142
|
+
# executed command returns something else."
|
143
|
+
# @objectaddflag = "-f"
|
144
|
+
# isautogen
|
145
|
+
#end
|
146
|
+
|
147
|
+
newparam(:name) do
|
148
|
+
desc "User name. While limitations are determined for
|
149
|
+
each operating system, it is generally a good idea to keep to
|
150
|
+
the degenerate 8 characters, beginning with a letter."
|
151
|
+
isnamevar
|
173
152
|
end
|
174
153
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
class << self
|
195
|
-
attr_accessor :netinfodir
|
196
|
-
attr_accessor :statemodule
|
197
|
-
end
|
198
|
-
|
199
|
-
@states = []
|
154
|
+
@doc = "Manage users. Currently can create and modify users, but
|
155
|
+
cannot delete them. Theoretically all of the parameters are
|
156
|
+
optional, but if no parameters are specified the comment will
|
157
|
+
be set to the user name in order to make the internals work out
|
158
|
+
correctly.
|
159
|
+
|
160
|
+
This element type uses the prescribed native tools for creating
|
161
|
+
groups and generally uses POSIX APIs for retrieving information
|
162
|
+
about them. It does not directly modify /etc/passwd or anything.
|
163
|
+
|
164
|
+
For most platforms, the tools used are ``useradd`` and its ilk;
|
165
|
+
for Mac OS X, NetInfo is used. This is currently unconfigurable,
|
166
|
+
but if you desperately need it to be so, please contact us."
|
167
|
+
|
168
|
+
@netinfodir = "users"
|
169
|
+
|
170
|
+
def exists?
|
171
|
+
self.class.parentmodule.exists?(self)
|
172
|
+
end
|
200
173
|
|
201
|
-
|
202
|
-
|
174
|
+
def getinfo(refresh = false)
|
175
|
+
if @userinfo.nil? or refresh == true
|
203
176
|
begin
|
204
|
-
|
205
|
-
rescue
|
206
|
-
|
207
|
-
fullname
|
208
|
-
end
|
209
|
-
}.each { |klass|
|
210
|
-
klass.complete
|
211
|
-
}
|
212
|
-
|
213
|
-
@parameters = [
|
214
|
-
:name
|
215
|
-
]
|
216
|
-
|
217
|
-
@paramdoc[:name] = "User name. While limitations are determined for
|
218
|
-
each operating system, it is generally a good idea to keep to the
|
219
|
-
degenerate 8 characters, beginning with a letter."
|
220
|
-
|
221
|
-
@doc = "Manage users. Currently can create and modify users, but
|
222
|
-
cannot delete them. Theoretically all of the parameters are
|
223
|
-
optional, but if no parameters are specified the comment will
|
224
|
-
be set to the user name in order to make the internals work out
|
225
|
-
correctly."
|
226
|
-
@name = :user
|
227
|
-
@namevar = :name
|
228
|
-
|
229
|
-
@netinfodir = "users"
|
230
|
-
|
231
|
-
def exists?
|
232
|
-
self.class.statemodule.exists?(self)
|
233
|
-
end
|
234
|
-
|
235
|
-
def getinfo(refresh = false)
|
236
|
-
if @userinfo.nil? or refresh == true
|
237
|
-
begin
|
238
|
-
@userinfo = Etc.getpwnam(self[:name])
|
239
|
-
rescue ArgumentError => detail
|
240
|
-
@userinfo = nil
|
241
|
-
end
|
177
|
+
@userinfo = Etc.getpwnam(self[:name])
|
178
|
+
rescue ArgumentError => detail
|
179
|
+
@userinfo = nil
|
242
180
|
end
|
243
|
-
|
244
|
-
@userinfo
|
245
181
|
end
|
246
182
|
|
247
|
-
|
248
|
-
|
249
|
-
super
|
183
|
+
@userinfo
|
184
|
+
end
|
250
185
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
186
|
+
def initialize(hash)
|
187
|
+
@userinfo = nil
|
188
|
+
super
|
189
|
+
|
190
|
+
# Verify that they have provided everything necessary, if we
|
191
|
+
# are trying to manage the user
|
192
|
+
if self.managed?
|
193
|
+
self.class.states.each { |state|
|
194
|
+
next if @states.include?(state.name)
|
195
|
+
next if state.name == :ensure
|
196
|
+
|
197
|
+
unless state.autogen? or state.isoptional?
|
198
|
+
if state.method_defined?(:autogen)
|
199
|
+
self[state.name] = :auto
|
200
|
+
else
|
201
|
+
self.fail "Users require a value for %s" % state.name
|
264
202
|
end
|
265
|
-
}
|
266
|
-
|
267
|
-
if @states.empty?
|
268
|
-
self[:comment] = self[:name]
|
269
203
|
end
|
204
|
+
}
|
205
|
+
|
206
|
+
if @states.empty?
|
207
|
+
self[:comment] = self[:name]
|
270
208
|
end
|
271
209
|
end
|
210
|
+
end
|
272
211
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
end
|
212
|
+
def retrieve
|
213
|
+
info = self.getinfo(true)
|
214
|
+
|
215
|
+
if info.nil?
|
216
|
+
# the user does not exist
|
217
|
+
@states.each { |name, state|
|
218
|
+
state.is = :absent
|
219
|
+
}
|
220
|
+
return
|
221
|
+
else
|
222
|
+
super
|
285
223
|
end
|
286
224
|
end
|
287
225
|
end
|
288
226
|
end
|
289
227
|
|
290
|
-
# $Id: user.rb
|
228
|
+
# $Id: user.rb 841 2006-01-18 17:24:15Z luke $
|