puppet 0.16.0 → 0.18.4
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 +98 -0
- data/Rakefile +5 -1
- data/bin/puppet +1 -1
- data/bin/puppetca +25 -11
- data/bin/puppetd +189 -66
- data/bin/puppetdoc +79 -62
- data/bin/puppetmasterd +93 -49
- data/bin/puppetrun +385 -0
- data/conf/redhat/client.init +5 -2
- data/conf/redhat/fileserver.conf +1 -1
- data/conf/redhat/lsb-config.patch +51 -0
- data/conf/redhat/puppet.spec +45 -18
- data/conf/redhat/puppetd.conf +32 -4
- data/conf/redhat/server.init +5 -2
- data/conf/solaris/pkginfo +7 -0
- data/conf/solaris/smf/puppetd.xml +77 -0
- data/conf/solaris/smf/puppetmasterd.xml +77 -0
- data/conf/solaris/smf/svc-puppetd +66 -0
- data/conf/solaris/smf/svc-puppetmasterd +62 -0
- data/examples/code/failers/noobjectrvalue +1 -0
- data/examples/code/snippets/deepclassheirarchy.pp +23 -0
- data/examples/code/snippets/defineoverrides.pp +17 -0
- data/examples/code/snippets/emptyexec.pp +3 -0
- data/examples/code/snippets/selectorvalues.pp +6 -1
- data/examples/code/snippets/tagged.pp +35 -0
- data/ext/ldap/puppet.schema +2 -2
- data/install.rb +4 -2
- data/lib/puppet.rb +206 -15
- data/lib/puppet/client.rb +30 -20
- data/lib/puppet/client/ca.rb +2 -2
- data/lib/puppet/client/dipper.rb +5 -9
- data/lib/puppet/client/master.rb +224 -44
- data/lib/puppet/client/pelement.rb +54 -9
- data/lib/puppet/client/proxy.rb +3 -2
- data/lib/puppet/client/reporter.rb +34 -0
- data/lib/puppet/client/runner.rb +17 -0
- data/lib/puppet/config.rb +136 -55
- data/lib/puppet/daemon.rb +59 -37
- data/lib/puppet/element.rb +2 -1
- data/lib/puppet/event.rb +14 -3
- data/lib/puppet/filetype.rb +28 -19
- data/lib/puppet/log.rb +297 -132
- data/lib/puppet/metric.rb +31 -131
- data/lib/puppet/networkclient.rb +73 -46
- data/lib/puppet/parameter.rb +49 -1
- data/lib/puppet/parsedfile.rb +32 -12
- data/lib/puppet/parser/ast.rb +6 -1
- data/lib/puppet/parser/ast/astarray.rb +32 -6
- data/lib/puppet/parser/ast/collection.rb +91 -0
- data/lib/puppet/parser/ast/compdef.rb +2 -2
- data/lib/puppet/parser/ast/component.rb +24 -11
- data/lib/puppet/parser/ast/function.rb +50 -0
- data/lib/puppet/parser/ast/hostclass.rb +70 -22
- data/lib/puppet/parser/ast/node.rb +17 -8
- data/lib/puppet/parser/ast/nodedef.rb +1 -1
- data/lib/puppet/parser/ast/objectdef.rb +28 -10
- data/lib/puppet/parser/ast/selector.rb +4 -1
- data/lib/puppet/parser/functions.rb +145 -0
- data/lib/puppet/parser/interpreter.rb +243 -86
- data/lib/puppet/parser/lexer.rb +5 -4
- data/lib/puppet/parser/parser.rb +586 -505
- data/lib/puppet/parser/scope.rb +337 -187
- data/lib/puppet/rails.rb +115 -0
- data/lib/puppet/rails/database.rb +40 -0
- data/lib/puppet/rails/host.rb +83 -0
- data/lib/puppet/rails/rails_object.rb +42 -0
- data/lib/puppet/rails/rails_parameter.rb +5 -0
- data/lib/puppet/reports/rrdgraph.rb +20 -0
- data/lib/puppet/reports/tagmail.rb +94 -0
- data/lib/puppet/server.rb +20 -4
- data/lib/puppet/server/authconfig.rb +14 -3
- data/lib/puppet/server/authstore.rb +2 -2
- data/lib/puppet/server/ca.rb +23 -11
- data/lib/puppet/server/filebucket.rb +10 -10
- data/lib/puppet/server/fileserver.rb +4 -8
- data/lib/puppet/server/master.rb +19 -22
- data/lib/puppet/server/pelement.rb +28 -16
- data/lib/puppet/server/report.rb +184 -0
- data/lib/puppet/server/runner.rb +62 -0
- data/lib/puppet/server/servlet.rb +23 -9
- data/lib/puppet/sslcertificates/ca.rb +25 -1
- data/lib/puppet/statechange.rb +34 -53
- data/lib/puppet/storage.rb +1 -2
- data/lib/puppet/transaction.rb +305 -133
- data/lib/puppet/transaction/report.rb +42 -0
- data/lib/puppet/transportable.rb +57 -33
- data/lib/puppet/type.rb +260 -127
- data/lib/puppet/type/component.rb +9 -21
- data/lib/puppet/type/cron.rb +367 -116
- data/lib/puppet/type/exec.rb +15 -16
- data/lib/puppet/type/group.rb +9 -1
- data/lib/puppet/type/nameservice.rb +2 -5
- data/lib/puppet/type/nameservice/netinfo.rb +3 -0
- data/lib/puppet/type/nameservice/objectadd.rb +23 -10
- data/lib/puppet/type/nameservice/pw.rb +16 -3
- data/lib/puppet/type/package.rb +25 -75
- data/lib/puppet/type/package/apple.rb +15 -1
- data/lib/puppet/type/package/apt.rb +37 -2
- data/lib/puppet/type/package/blastwave.rb +136 -0
- data/lib/puppet/type/package/dpkg.rb +4 -4
- data/lib/puppet/type/package/gem.rb +119 -0
- data/lib/puppet/type/package/openbsd.rb +7 -6
- data/lib/puppet/type/package/ports.rb +7 -2
- data/lib/puppet/type/package/rpm.rb +1 -1
- data/lib/puppet/type/package/sun.rb +23 -9
- data/lib/puppet/type/package/sunfreeware.rb +7 -0
- data/lib/puppet/type/package/yum.rb +16 -9
- data/lib/puppet/type/parsedtype.rb +7 -5
- data/lib/puppet/type/parsedtype/mount.rb +55 -34
- data/lib/puppet/type/parsedtype/port.rb +7 -1
- data/lib/puppet/type/parsedtype/sshkey.rb +6 -16
- data/lib/puppet/type/pfile.rb +115 -23
- data/lib/puppet/type/pfile/checksum.rb +18 -5
- data/lib/puppet/type/pfile/content.rb +2 -2
- data/lib/puppet/type/pfile/ensure.rb +3 -3
- data/lib/puppet/type/pfile/group.rb +2 -2
- data/lib/puppet/type/pfile/source.rb +28 -17
- data/lib/puppet/type/pfile/target.rb +25 -17
- data/lib/puppet/type/pfilebucket.rb +25 -6
- data/lib/puppet/type/schedule.rb +6 -6
- data/lib/puppet/type/service.rb +24 -14
- data/lib/puppet/type/service/debian.rb +1 -1
- data/lib/puppet/type/service/redhat.rb +13 -10
- data/lib/puppet/type/service/smf.rb +3 -3
- data/lib/puppet/type/state.rb +1 -2
- data/lib/puppet/type/symlink.rb +3 -4
- data/lib/puppet/type/user.rb +22 -10
- data/lib/puppet/type/yumrepo.rb +6 -1
- data/lib/puppet/type/zone.rb +595 -0
- data/lib/puppet/util.rb +58 -12
- data/test/client/client.rb +2 -2
- data/test/client/master.rb +92 -3
- data/test/client/pelement.rb +99 -0
- data/test/executables/puppetbin.rb +3 -4
- data/test/executables/puppetca.rb +3 -3
- data/test/executables/puppetd.rb +3 -3
- data/test/executables/puppetmasterd.rb +1 -5
- data/test/executables/puppetmodule.rb +2 -2
- data/test/language/ast.rb +200 -11
- data/test/language/functions.rb +245 -0
- data/test/language/interpreter.rb +155 -6
- data/test/language/lexer.rb +35 -2
- data/test/language/node.rb +48 -1
- data/test/language/parser.rb +250 -1
- data/test/language/rails.rb +105 -0
- data/test/language/scope.rb +304 -10
- data/test/language/snippets.rb +54 -5
- data/test/language/transportable.rb +60 -28
- data/test/other/config.rb +214 -1
- data/test/other/events.rb +67 -9
- data/test/other/log.rb +31 -5
- data/test/other/metrics.rb +23 -21
- data/test/other/parsedfile.rb +29 -2
- data/test/other/puppet.rb +79 -0
- data/test/other/report.rb +106 -0
- data/test/other/storage.rb +2 -2
- data/test/other/transactions.rb +128 -2
- data/test/puppet/utiltest.rb +10 -5
- data/test/puppettest.rb +193 -21
- data/test/server/authstore.rb +13 -4
- data/test/server/bucket.rb +33 -8
- data/test/server/ca.rb +44 -6
- data/test/server/master.rb +6 -7
- data/test/server/pelement.rb +15 -5
- data/test/server/report.rb +93 -0
- data/test/server/runner.rb +107 -0
- data/test/server/server.rb +28 -1
- data/test/types/cron.rb +339 -31
- data/test/types/file.rb +256 -24
- data/test/types/filebucket.rb +6 -2
- data/test/types/filesources.rb +41 -92
- data/test/types/group.rb +31 -1
- data/test/types/host.rb +2 -1
- data/test/types/mount.rb +18 -1
- data/test/types/package.rb +200 -18
- data/test/types/service.rb +5 -1
- data/test/types/sshkey.rb +2 -1
- data/test/types/symlink.rb +3 -2
- data/test/types/type.rb +180 -1
- data/test/types/user.rb +65 -27
- data/test/types/yumrepo.rb +15 -0
- data/test/types/zone.rb +437 -0
- metadata +43 -4
- data/bin/cf2puppet +0 -186
- data/conf/redhat/puppetmasterd.conf +0 -5
@@ -1,25 +1,32 @@
|
|
1
1
|
module Puppet
|
2
2
|
Puppet.type(:package).newpkgtype(:yum, :rpm) do
|
3
|
+
include Puppet::Util
|
3
4
|
# Install a package using 'yum'.
|
4
5
|
def install
|
5
6
|
cmd = "yum -y install %s" % self[:name]
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
begin
|
9
|
+
output = execute(cmd)
|
10
|
+
rescue Puppet::ExecutionFailure => detail
|
11
|
+
raise Puppet::PackageError.new(detail)
|
12
|
+
end
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
@states[:ensure].retrieve
|
15
|
+
if @states[:ensure].is == :absent
|
16
|
+
raise Puppet::PackageError.new(
|
17
|
+
"Could not find package %s" % self.name
|
18
|
+
)
|
12
19
|
end
|
13
20
|
end
|
14
21
|
|
15
22
|
# What's the latest package version available?
|
16
23
|
def latest
|
17
24
|
cmd = "yum list available %s" % self[:name]
|
18
|
-
self.info "Executing %s" % cmd.inspect
|
19
|
-
output = %x{#{cmd} 2>&1}
|
20
25
|
|
21
|
-
|
22
|
-
|
26
|
+
begin
|
27
|
+
output = execute(cmd)
|
28
|
+
rescue Puppet::ExecutionFailure => detail
|
29
|
+
raise Puppet::PackageError.new(detail)
|
23
30
|
end
|
24
31
|
|
25
32
|
if output =~ /#{self[:name]}\S+\s+(\S+)\s/
|
@@ -42,4 +49,4 @@ module Puppet
|
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
45
|
-
# $Id: yum.rb
|
52
|
+
# $Id: yum.rb 1421 2006-07-21 23:12:51Z luke $
|
@@ -221,7 +221,7 @@ module Puppet
|
|
221
221
|
@fileobj ||= @filetype.new(@path)
|
222
222
|
text = @fileobj.read
|
223
223
|
if text.nil? or text == ""
|
224
|
-
# there is no
|
224
|
+
# there is no file
|
225
225
|
return nil
|
226
226
|
else
|
227
227
|
# First we mark all of our objects absent; any objects
|
@@ -278,7 +278,7 @@ module Puppet
|
|
278
278
|
end
|
279
279
|
end
|
280
280
|
|
281
|
-
# Return the last time the
|
281
|
+
# Return the last time the file was loaded. Could
|
282
282
|
# be used for reducing writes, but currently is not.
|
283
283
|
def self.loaded?(user)
|
284
284
|
@fileobj ||= @filetype.new(@path)
|
@@ -305,10 +305,12 @@ module Puppet
|
|
305
305
|
def retrieve
|
306
306
|
self.class.retrieve()
|
307
307
|
|
308
|
-
self.eachstate { |st|
|
308
|
+
self.eachstate { |st|
|
309
|
+
st.retrieve
|
310
|
+
}
|
309
311
|
end
|
310
312
|
|
311
|
-
# Write the entire
|
313
|
+
# Write the entire file out.
|
312
314
|
def store
|
313
315
|
self.class.store()
|
314
316
|
end
|
@@ -339,4 +341,4 @@ require 'puppet/type/parsedtype/port'
|
|
339
341
|
require 'puppet/type/parsedtype/mount'
|
340
342
|
require 'puppet/type/parsedtype/sshkey'
|
341
343
|
|
342
|
-
# $Id: parsedtype.rb
|
344
|
+
# $Id: parsedtype.rb 1223 2006-05-25 06:08:11Z luke $
|
@@ -6,7 +6,12 @@ require 'puppet/type/state'
|
|
6
6
|
module Puppet
|
7
7
|
newtype(:mount, Puppet::Type::ParsedType) do
|
8
8
|
ensurable do
|
9
|
-
desc "
|
9
|
+
desc "Control what to do with this mount. If the value is
|
10
|
+
``present``, the mount is entered into the mount table,
|
11
|
+
but not mounted, if it is ``absent``, the entry is removed
|
12
|
+
from the mount table and the filesystem is unmounted if
|
13
|
+
currently mounted, if it is ``mounted``, the filesystem
|
14
|
+
is entered into the mount table and mounted."
|
10
15
|
|
11
16
|
newvalue(:present) do
|
12
17
|
@parent.create()
|
@@ -101,39 +106,50 @@ module Puppet
|
|
101
106
|
end
|
102
107
|
|
103
108
|
@doc = "Manages mounted mounts, including putting mount
|
104
|
-
information into the mount table.
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
109
|
+
information into the mount table. The actual behavior depends
|
110
|
+
on the value of the 'ensure' parameter."
|
111
|
+
|
112
|
+
def self.init
|
113
|
+
@platform = Facter["operatingsystem"].value
|
114
|
+
case @platform
|
115
|
+
when "Solaris":
|
116
|
+
@path = "/etc/vfstab"
|
117
|
+
@fields = [:device, :blockdevice, :path, :fstype, :pass, :atboot,
|
118
|
+
:options]
|
119
|
+
@defaults = [ nil ] * @fields.size
|
120
|
+
when "Darwin":
|
121
|
+
@filetype = Puppet::FileType.filetype(:netinfo)
|
122
|
+
@filetype.format = "fstab"
|
123
|
+
@path = "mounts"
|
124
|
+
@fields = [:device, :path, :fstype, :options, :dump, :pass]
|
125
|
+
@defaults = [ nil ] * @fields.size
|
126
|
+
|
127
|
+
# How to map the dumped table to what we want
|
128
|
+
@fieldnames = {
|
129
|
+
"name" => :device,
|
130
|
+
"dir" => :path,
|
131
|
+
"dump_freq" => :dump,
|
132
|
+
"passno" => :pass,
|
133
|
+
"vfstype" => :fstype,
|
134
|
+
"opts" => :options
|
135
|
+
}
|
136
|
+
else
|
137
|
+
@path = "/etc/fstab"
|
138
|
+
@fields = [:device, :path, :fstype, :options, :dump, :pass]
|
139
|
+
@defaults = [ nil ] * 4 + [ "0", "2" ]
|
140
|
+
end
|
141
|
+
|
142
|
+
# Allow Darwin to override the default filetype
|
143
|
+
unless defined? @filetype
|
144
|
+
@filetype = Puppet::FileType.filetype(:flat)
|
145
|
+
end
|
132
146
|
end
|
133
147
|
|
134
|
-
|
135
|
-
|
136
|
-
|
148
|
+
init
|
149
|
+
|
150
|
+
def self.clear
|
151
|
+
init
|
152
|
+
super
|
137
153
|
end
|
138
154
|
|
139
155
|
# Parse a mount tab.
|
@@ -156,10 +172,15 @@ module Puppet
|
|
156
172
|
comment(line)
|
157
173
|
else
|
158
174
|
values = line.split(/\s+/)
|
159
|
-
|
175
|
+
if @fields.length < values.length
|
160
176
|
raise Puppet::Error, "Could not parse line %s" % line
|
161
177
|
end
|
162
178
|
|
179
|
+
values = @defaults.zip(values).collect { |d, v| v || d }
|
180
|
+
unless @fields.length == values.length
|
181
|
+
raise Puppet::Error, "Could not parse line %s" % line
|
182
|
+
end
|
183
|
+
|
163
184
|
@fields.zip(values).each do |field, value|
|
164
185
|
hash[field] = value
|
165
186
|
end
|
@@ -247,4 +268,4 @@ module Puppet
|
|
247
268
|
end
|
248
269
|
end
|
249
270
|
|
250
|
-
# $Id: mount.rb
|
271
|
+
# $Id: mount.rb 1380 2006-07-10 23:13:06Z lutter $
|
@@ -172,6 +172,12 @@ module Puppet
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
else
|
175
|
+
if line =~ /^\s+\d+/ and
|
176
|
+
Facter["operatingsystem"].value == "Darwin"
|
177
|
+
#Puppet.notice "Skipping wonky OS X port entry %s" %
|
178
|
+
# line.inspect
|
179
|
+
next
|
180
|
+
end
|
175
181
|
raise Puppet::Error, "Could not match '%s'" % line
|
176
182
|
end
|
177
183
|
|
@@ -252,4 +258,4 @@ module Puppet
|
|
252
258
|
end
|
253
259
|
end
|
254
260
|
|
255
|
-
# $Id: port.rb
|
261
|
+
# $Id: port.rb 1156 2006-05-01 01:07:47Z luke $
|
@@ -5,8 +5,6 @@ require 'puppet/type/state'
|
|
5
5
|
|
6
6
|
module Puppet
|
7
7
|
newtype(:sshkey, Puppet::Type::ParsedType) do
|
8
|
-
isaggregatable
|
9
|
-
|
10
8
|
newstate(:type) do
|
11
9
|
desc "The encryption type used. Probably ssh-dss or ssh-rsa."
|
12
10
|
end
|
@@ -21,8 +19,7 @@ module Puppet
|
|
21
19
|
desc "Any alias the host might have. Multiple values must be
|
22
20
|
specified as an array. Note that this state has the same name
|
23
21
|
as one of the metaparams; using this state to set aliases will
|
24
|
-
make those aliases available in your Puppet scripts
|
25
|
-
disk."
|
22
|
+
make those aliases available in your Puppet scripts."
|
26
23
|
|
27
24
|
# We actually want to return the whole array here, not just the first
|
28
25
|
# value.
|
@@ -57,12 +54,13 @@ module Puppet
|
|
57
54
|
isnamevar
|
58
55
|
end
|
59
56
|
|
60
|
-
@doc = "Installs and manages host
|
61
|
-
|
62
|
-
|
57
|
+
@doc = "Installs and manages ssh host keys. At this point, this type
|
58
|
+
only knows how to install keys into /etc/ssh/ssh_known_hosts, and
|
59
|
+
it cannot manage user authorized keys yet."
|
63
60
|
|
64
61
|
@instances = []
|
65
62
|
|
63
|
+
# FIXME This should be configurable.
|
66
64
|
@path = "/etc/ssh/ssh_known_hosts"
|
67
65
|
@fields = [:name, :type, :key]
|
68
66
|
|
@@ -99,14 +97,6 @@ module Puppet
|
|
99
97
|
hash[:alias] = names
|
100
98
|
end
|
101
99
|
|
102
|
-
#if match = /^(\S+)\s+(\S+)\s*(\S*)$/.match(line)
|
103
|
-
# fields().zip(match.captures).each { |param, value|
|
104
|
-
# hash[param] = value
|
105
|
-
# }
|
106
|
-
#else
|
107
|
-
# raise Puppet::Error, "Could not match '%s'" % line
|
108
|
-
#end
|
109
|
-
|
110
100
|
if hash[:alias] == ""
|
111
101
|
hash.delete(:alias)
|
112
102
|
end
|
@@ -130,4 +120,4 @@ module Puppet
|
|
130
120
|
end
|
131
121
|
end
|
132
122
|
|
133
|
-
# $Id: sshkey.rb
|
123
|
+
# $Id: sshkey.rb 1279 2006-06-14 15:30:25Z luke $
|
data/lib/puppet/type/pfile.rb
CHANGED
@@ -32,21 +32,22 @@ module Puppet
|
|
32
32
|
|
33
33
|
newparam(:backup) do
|
34
34
|
desc "Whether files should be backed up before
|
35
|
-
being replaced. If a
|
35
|
+
being replaced. If a filebucket is specified, files will be
|
36
36
|
backed up there; else, they will be backed up in the same directory
|
37
|
-
with a ``.puppet-bak`` extension
|
37
|
+
with a ``.puppet-bak`` extension,, and no backups
|
38
|
+
will be made if backup is ``false``.
|
38
39
|
|
39
40
|
To use filebuckets, you must first create a filebucket in your
|
40
|
-
configuration
|
41
|
+
configuration:
|
41
42
|
|
42
43
|
filebucket { main:
|
43
44
|
server => puppet
|
44
45
|
}
|
45
46
|
|
46
|
-
``puppetmasterd`` creates a filebucket by default,
|
47
|
-
usually back up to your main server with this
|
48
|
-
you've described the bucket in your
|
49
|
-
it in any file
|
47
|
+
The ``puppetmasterd`` daemon creates a filebucket by default,
|
48
|
+
so you can usually back up to your main server with this
|
49
|
+
configuration. Once you've described the bucket in your
|
50
|
+
configuration, you can use it in any file:
|
50
51
|
|
51
52
|
file { \"/my/file\":
|
52
53
|
source => \"/path/in/nfs/or/something\",
|
@@ -64,19 +65,20 @@ module Puppet
|
|
64
65
|
"
|
65
66
|
|
66
67
|
attr_reader :bucket
|
67
|
-
defaultto
|
68
|
+
defaultto ".puppet-bak"
|
68
69
|
|
69
70
|
munge do |value|
|
70
71
|
case value
|
71
|
-
when false, "false":
|
72
|
+
when false, "false", :false:
|
72
73
|
false
|
73
|
-
when true, "true", ".puppet-bak":
|
74
|
+
when true, "true", ".puppet-bak", :true:
|
74
75
|
".puppet-bak"
|
75
76
|
when String:
|
76
77
|
# We can't depend on looking this up right now,
|
77
78
|
# we have to do it after all of the objects
|
78
79
|
# have been instantiated.
|
79
80
|
@bucket = value
|
81
|
+
value
|
80
82
|
else
|
81
83
|
self.fail "Invalid backup type %s" %
|
82
84
|
value.inspect
|
@@ -97,10 +99,17 @@ module Puppet
|
|
97
99
|
|
98
100
|
newparam(:recurse) do
|
99
101
|
desc "Whether and how deeply to do recursive
|
100
|
-
management.
|
102
|
+
management."
|
101
103
|
|
104
|
+
newvalues(:true, :false, :inf, /^[0-9]+$/)
|
102
105
|
munge do |value|
|
103
|
-
value
|
106
|
+
newval = super(value)
|
107
|
+
case newval
|
108
|
+
when :true, :inf: true
|
109
|
+
when :false: false
|
110
|
+
else
|
111
|
+
newval
|
112
|
+
end
|
104
113
|
end
|
105
114
|
end
|
106
115
|
|
@@ -216,7 +225,8 @@ module Puppet
|
|
216
225
|
if @parameters.include?(:backup) and bucket = @parameters[:backup].bucket
|
217
226
|
case bucket
|
218
227
|
when String:
|
219
|
-
if obj = @@filebuckets
|
228
|
+
if obj = @@filebuckets[bucket]
|
229
|
+
# This sets the @value on :backup, too
|
220
230
|
@parameters[:backup].bucket = obj
|
221
231
|
elsif obj = Puppet.type(:filebucket).bucket(bucket)
|
222
232
|
@@filebuckets[bucket] = obj
|
@@ -248,9 +258,57 @@ module Puppet
|
|
248
258
|
|
249
259
|
case File.stat(file).ftype
|
250
260
|
when "directory":
|
251
|
-
self
|
252
|
-
|
253
|
-
|
261
|
+
if self[:recurse]
|
262
|
+
# we don't need to backup directories when recurse is on
|
263
|
+
return true
|
264
|
+
else
|
265
|
+
backup = self[:backup]
|
266
|
+
case backup
|
267
|
+
when Puppet::Client::Dipper:
|
268
|
+
notice "Recursively backing up to filebucket"
|
269
|
+
require 'find'
|
270
|
+
Find.find(self[:path]) do |f|
|
271
|
+
if File.file?(f)
|
272
|
+
sum = backup.backup(f)
|
273
|
+
self.info "Filebucketed %s to %s with sum %s" %
|
274
|
+
[f, backup.name, sum]
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
require 'fileutils'
|
279
|
+
FileUtils.rmtree(self[:path])
|
280
|
+
return true
|
281
|
+
when String:
|
282
|
+
newfile = file + backup
|
283
|
+
# Just move it, since it's a directory.
|
284
|
+
if FileTest.exists?(newfile)
|
285
|
+
begin
|
286
|
+
File.unlink(newfile)
|
287
|
+
rescue => detail
|
288
|
+
puts detail.backtrace
|
289
|
+
self.err "Could not remove old backup: %s" %
|
290
|
+
detail
|
291
|
+
return false
|
292
|
+
end
|
293
|
+
end
|
294
|
+
begin
|
295
|
+
bfile = file + backup
|
296
|
+
|
297
|
+
# Ruby 1.8.1 requires the 'preserve' addition, but
|
298
|
+
# later versions do not appear to require it.
|
299
|
+
FileUtils.cp_r(file, bfile, :preserve => true)
|
300
|
+
return true
|
301
|
+
rescue => detail
|
302
|
+
# since they said they want a backup, let's error out
|
303
|
+
# if we couldn't make one
|
304
|
+
self.fail "Could not back %s up: %s" %
|
305
|
+
[file, detail.message]
|
306
|
+
end
|
307
|
+
else
|
308
|
+
self.err "Invalid backup type %s" % backup.inspect
|
309
|
+
return false
|
310
|
+
end
|
311
|
+
end
|
254
312
|
when "file":
|
255
313
|
backup = self[:backup]
|
256
314
|
case backup
|
@@ -271,8 +329,13 @@ module Puppet
|
|
271
329
|
end
|
272
330
|
end
|
273
331
|
begin
|
274
|
-
|
275
|
-
|
332
|
+
# FIXME Shouldn't this just use a Puppet object with
|
333
|
+
# 'source' specified?
|
334
|
+
bfile = file + backup
|
335
|
+
|
336
|
+
# Ruby 1.8.1 requires the 'preserve' addition, but
|
337
|
+
# later versions do not appear to require it.
|
338
|
+
FileUtils.cp(file, bfile, :preserve => true)
|
276
339
|
return true
|
277
340
|
rescue => detail
|
278
341
|
# since they said they want a backup, let's error out
|
@@ -281,7 +344,7 @@ module Puppet
|
|
281
344
|
[file, detail.message]
|
282
345
|
end
|
283
346
|
else
|
284
|
-
self.err "Invalid backup type %s" % backup
|
347
|
+
self.err "Invalid backup type %s" % backup.inspect
|
285
348
|
return false
|
286
349
|
end
|
287
350
|
else
|
@@ -662,6 +725,9 @@ module Puppet
|
|
662
725
|
unless @states.include?(:checksum)
|
663
726
|
self[:checksum] = "md5"
|
664
727
|
end
|
728
|
+
|
729
|
+
# We have to retrieve the source info before the recursion happens,
|
730
|
+
# although I'm not exactly clear on why.
|
665
731
|
@states[:source].retrieve
|
666
732
|
end
|
667
733
|
|
@@ -678,10 +744,19 @@ module Puppet
|
|
678
744
|
next if name == :source
|
679
745
|
state.is = :absent
|
680
746
|
}
|
747
|
+
|
681
748
|
return
|
682
749
|
end
|
683
750
|
|
684
|
-
|
751
|
+
states().each { |state|
|
752
|
+
# We don't want to call 'describe()' twice, so only do a local
|
753
|
+
# retrieve on the source.
|
754
|
+
if state.name == :source
|
755
|
+
state.retrieve(false)
|
756
|
+
else
|
757
|
+
state.retrieve
|
758
|
+
end
|
759
|
+
}
|
685
760
|
end
|
686
761
|
|
687
762
|
# Set the checksum, from another state. There are multiple states that
|
@@ -710,6 +785,12 @@ module Puppet
|
|
710
785
|
if self.class.name == :file and self[:links] != :follow
|
711
786
|
method = :lstat
|
712
787
|
end
|
788
|
+
path = self[:path]
|
789
|
+
# Just skip them when they don't exist at all.
|
790
|
+
unless FileTest.exists?(path) or FileTest.symlink?(path)
|
791
|
+
@stat = nil
|
792
|
+
return @stat
|
793
|
+
end
|
713
794
|
if @stat.nil? or refresh == true
|
714
795
|
begin
|
715
796
|
@stat = File.send(method, self[:path])
|
@@ -727,8 +808,11 @@ module Puppet
|
|
727
808
|
def uri2obj(source)
|
728
809
|
sourceobj = FileSource.new
|
729
810
|
path = nil
|
811
|
+
unless source
|
812
|
+
devfail "Got a nil source"
|
813
|
+
end
|
730
814
|
if source =~ /^\//
|
731
|
-
source = "file://localhost/%s" % source
|
815
|
+
source = "file://localhost/%s" % URI.escape(source)
|
732
816
|
sourceobj.mount = "localhost"
|
733
817
|
sourceobj.local = true
|
734
818
|
end
|
@@ -785,9 +869,15 @@ module Puppet
|
|
785
869
|
def write(usetmp = true)
|
786
870
|
mode = self.should(:mode)
|
787
871
|
|
788
|
-
if FileTest.exists?(self[:path])
|
872
|
+
#if FileTest.exists?(self[:path])
|
873
|
+
if s = stat(false)
|
789
874
|
# this makes sure we have a copy for posterity
|
790
875
|
@backed = self.handlebackup
|
876
|
+
|
877
|
+
if s.ftype == "link" and self[:links] != :follow
|
878
|
+
# Remove existing links, since we're writing out a file
|
879
|
+
File.unlink(self[:path])
|
880
|
+
end
|
791
881
|
end
|
792
882
|
|
793
883
|
# The temporary file
|
@@ -834,6 +924,8 @@ module Puppet
|
|
834
924
|
end
|
835
925
|
|
836
926
|
# And then update our checksum, so the next run doesn't find it.
|
927
|
+
# FIXME This is extra work, because it's going to read the whole
|
928
|
+
# file back in again.
|
837
929
|
self.setchecksum
|
838
930
|
end
|
839
931
|
end # Puppet.type(:pfile)
|
@@ -857,4 +949,4 @@ module Puppet
|
|
857
949
|
require 'puppet/type/pfile/mode'
|
858
950
|
require 'puppet/type/pfile/type'
|
859
951
|
end
|
860
|
-
# $Id: pfile.rb
|
952
|
+
# $Id: pfile.rb 1355 2006-07-03 23:15:15Z luke $
|