puppet 2.7.13 → 2.7.14
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 +144 -1
- data/conf/osx/preflight +1 -1
- data/conf/redhat/puppet.spec +9 -5
- data/conf/suse/puppet.spec +4 -1
- data/conf/windows/eventlog/Rakefile +32 -0
- data/conf/windows/eventlog/puppetres.dll +0 -0
- data/conf/windows/eventlog/puppetres.mc +18 -0
- data/ext/rack/files/apache2.conf +3 -0
- data/install.rb +23 -1
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +1 -14
- data/lib/puppet/application/kick.rb +1 -1
- data/lib/puppet/application/module.rb +11 -0
- data/lib/puppet/daemon.rb +74 -3
- data/lib/puppet/defaults.rb +1 -1
- data/lib/puppet/face/certificate.rb +1 -1
- data/lib/puppet/face/help/man.erb +1 -1
- data/lib/puppet/face/module.rb +17 -0
- data/lib/puppet/face/module/build.rb +10 -4
- data/lib/puppet/face/module/changes.rb +5 -5
- data/lib/puppet/face/module/generate.rb +6 -4
- data/lib/puppet/face/module/install.rb +122 -32
- data/lib/puppet/face/module/list.rb +234 -33
- data/lib/puppet/face/module/search.rb +56 -23
- data/lib/puppet/face/module/uninstall.rb +33 -38
- data/lib/puppet/face/module/upgrade.rb +84 -0
- data/lib/puppet/feature/eventlog.rb +6 -0
- data/lib/puppet/forge.rb +67 -122
- data/lib/puppet/forge/cache.rb +1 -1
- data/lib/puppet/forge/repository.rb +6 -25
- data/lib/puppet/indirector/facts/network_device.rb +1 -1
- data/lib/puppet/interface/action.rb +1 -1
- data/lib/puppet/module.rb +79 -28
- data/lib/puppet/module_tool.rb +72 -34
- data/lib/puppet/module_tool/applications.rb +12 -14
- data/lib/puppet/module_tool/applications/application.rb +21 -19
- data/lib/puppet/module_tool/applications/builder.rb +4 -4
- data/lib/puppet/module_tool/applications/checksummer.rb +12 -3
- data/lib/puppet/module_tool/applications/generator.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +163 -34
- data/lib/puppet/module_tool/applications/searcher.rb +2 -3
- data/lib/puppet/module_tool/applications/uninstaller.rb +84 -36
- data/lib/puppet/module_tool/applications/unpacker.rb +4 -26
- data/lib/puppet/module_tool/applications/upgrader.rb +109 -0
- data/lib/puppet/module_tool/checksums.rb +2 -2
- data/lib/puppet/module_tool/contents_description.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +2 -2
- data/lib/puppet/module_tool/errors.rb +9 -0
- data/lib/puppet/module_tool/errors/base.rb +15 -0
- data/lib/puppet/module_tool/errors/installer.rb +90 -0
- data/lib/puppet/module_tool/errors/shared.rb +115 -0
- data/lib/puppet/module_tool/errors/uninstaller.rb +45 -0
- data/lib/puppet/module_tool/errors/upgrader.rb +72 -0
- data/lib/puppet/module_tool/metadata.rb +2 -2
- data/lib/puppet/module_tool/modulefile.rb +7 -7
- data/lib/puppet/module_tool/shared_behaviors.rb +161 -0
- data/lib/puppet/module_tool/skeleton.rb +1 -1
- data/lib/puppet/node/environment.rb +4 -2
- data/lib/puppet/parser/ast/leaf.rb +1 -1
- data/lib/puppet/parser/functions/create_resources.rb +3 -2
- data/lib/puppet/parser/scope.rb +44 -9
- data/lib/puppet/provider/augeas/augeas.rb +2 -2
- data/lib/puppet/provider/exec.rb +8 -3
- data/lib/puppet/provider/exec/shell.rb +1 -2
- data/lib/puppet/provider/nameservice/directoryservice.rb +10 -4
- data/lib/puppet/provider/package/gem.rb +1 -1
- data/lib/puppet/provider/package/pkg.rb +10 -21
- data/lib/puppet/provider/selmodule/semodule.rb +1 -2
- data/lib/puppet/provider/service/upstart.rb +33 -17
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
- data/lib/puppet/rails/inventory_node.rb +7 -7
- data/lib/puppet/reports/http.rb +4 -1
- data/lib/puppet/reports/tagmail.rb +8 -1
- data/lib/puppet/resource/type.rb +1 -1
- data/lib/puppet/test/test_helper.rb +138 -0
- data/lib/puppet/type.rb +9 -1
- data/lib/puppet/type/file.rb +18 -10
- data/lib/puppet/type/package.rb +13 -9
- data/lib/puppet/type/resources.rb +1 -1
- data/lib/puppet/type/ssh_authorized_key.rb +3 -4
- data/lib/puppet/type/sshkey.rb +4 -4
- data/lib/puppet/type/user.rb +1 -0
- data/lib/puppet/type/vlan.rb +1 -1
- data/lib/puppet/util.rb +31 -14
- data/lib/puppet/util/autoload.rb +1 -1
- data/lib/puppet/util/command_line.rb +2 -6
- data/lib/puppet/util/instrumentation/indirection_probe.rb +1 -1
- data/lib/puppet/util/instrumentation/instrumentable.rb +1 -1
- data/lib/puppet/util/instrumentation/listeners/log.rb +1 -1
- data/lib/puppet/util/instrumentation/listeners/performance.rb +1 -1
- data/lib/puppet/util/log.rb +3 -1
- data/lib/puppet/util/log/destinations.rb +38 -0
- data/lib/puppet/util/monkey_patches.rb +45 -0
- data/lib/puppet/util/network_device/base.rb +1 -1
- data/lib/puppet/util/network_device/cisco.rb +1 -1
- data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/lib/puppet/util/network_device/cisco/interface.rb +1 -1
- data/lib/puppet/util/network_device/config.rb +1 -1
- data/lib/puppet/util/network_device/ipcalc.rb +1 -1
- data/lib/puppet/util/network_device/transport.rb +1 -1
- data/lib/puppet/util/network_device/transport/base.rb +1 -1
- data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
- data/lib/puppet/util/settings.rb +2 -11
- data/lib/puppet/util/settings/file_setting.rb +3 -5
- data/lib/puppet/util/terminal.rb +16 -0
- data/lib/puppet/util/zaml.rb +3 -1
- data/lib/semver.rb +15 -7
- data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -1
- data/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp +1 -1
- data/spec/fixtures/unit/provider/package/pkg/dummy +1 -0
- data/spec/fixtures/unit/provider/package/pkg/incomplete +1 -0
- data/spec/fixtures/unit/provider/package/pkg/publisher +2 -0
- data/spec/fixtures/unit/provider/package/pkg/simple +4 -0
- data/spec/fixtures/unit/reports/tagmail/tagmail_email.conf +2 -0
- data/spec/fixtures/yaml/report0.25.x.yaml +1 -1
- data/spec/fixtures/yaml/report2.6.x.yaml +1 -1
- data/spec/integration/faces/documentation_spec.rb +1 -1
- data/spec/integration/network/rest_authconfig_spec.rb +1 -1
- data/spec/lib/puppet_spec/compiler.rb +6 -0
- data/spec/lib/puppet_spec/database.rb +30 -0
- data/spec/lib/puppet_spec/files.rb +4 -2
- data/spec/shared_behaviours/path_parameters.rb +2 -29
- data/spec/shared_contexts/platform.rb +43 -0
- data/spec/spec_helper.rb +36 -65
- data/spec/unit/agent_spec.rb +0 -32
- data/spec/unit/application/kick_spec.rb +2 -2
- data/spec/unit/daemon_spec.rb +1 -17
- data/spec/unit/face/module/install_spec.rb +158 -0
- data/spec/unit/face/module/list_spec.rb +182 -0
- data/spec/unit/face/module/search_spec.rb +163 -0
- data/spec/unit/face/module/uninstall_spec.rb +77 -0
- data/spec/unit/face/module/upgrade_spec.rb +26 -0
- data/spec/unit/forge/repository_spec.rb +0 -30
- data/spec/unit/forge_spec.rb +28 -86
- data/spec/unit/indirector/catalog/active_record_spec.rb +45 -65
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -18
- data/spec/unit/indirector/resource/active_record_spec.rb +2 -11
- data/spec/unit/indirector/resource/ral_spec.rb +7 -2
- data/spec/unit/module_spec.rb +240 -107
- data/spec/unit/module_tool/application_spec.rb +3 -5
- data/spec/unit/module_tool/applications/application_spec.rb +19 -0
- data/spec/unit/module_tool/applications/installer_spec.rb +205 -0
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +206 -0
- data/spec/unit/module_tool/applications/upgrader_spec.rb +37 -0
- data/spec/unit/module_tool/metadata_spec.rb +2 -2
- data/spec/unit/module_tool_spec.rb +109 -1
- data/spec/unit/node/environment_spec.rb +16 -1
- data/spec/unit/parser/ast/leaf_spec.rb +16 -1
- data/spec/unit/parser/collector_spec.rb +2 -12
- data/spec/unit/parser/functions/create_resources_spec.rb +135 -86
- data/spec/unit/parser/functions/generate_spec.rb +2 -10
- data/spec/unit/parser/scope_spec.rb +345 -16
- data/spec/unit/provider/augeas/augeas_spec.rb +19 -0
- data/spec/unit/provider/exec/shell_spec.rb +17 -14
- data/spec/unit/provider/exec/windows_spec.rb +1 -7
- data/spec/unit/provider/exec_spec.rb +35 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +10 -0
- data/spec/unit/provider/package/dpkg_spec.rb +2 -1
- data/spec/unit/provider/package/gem_spec.rb +15 -0
- data/spec/unit/provider/package/openbsd_spec.rb +5 -4
- data/spec/unit/provider/package/pacman_spec.rb +3 -2
- data/spec/unit/provider/package/pkg_spec.rb +56 -33
- data/spec/unit/provider/selmodule_spec.rb +11 -4
- data/spec/unit/provider/service/redhat_spec.rb +1 -3
- data/spec/unit/provider/service/smf_spec.rb +1 -3
- data/spec/unit/provider/service/upstart_spec.rb +38 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +28 -0
- data/spec/unit/rails/host_spec.rb +6 -12
- data/spec/unit/rails/param_value_spec.rb +3 -8
- data/spec/unit/rails/resource_spec.rb +2 -8
- data/spec/unit/reports/http_spec.rb +47 -31
- data/spec/unit/reports/tagmail_spec.rb +77 -0
- data/spec/unit/resource/type_spec.rb +2 -2
- data/spec/unit/resource_spec.rb +18 -20
- data/spec/unit/semver_spec.rb +31 -13
- data/spec/unit/type/exec_spec.rb +8 -15
- data/spec/unit/type/group_spec.rb +0 -9
- data/spec/unit/type/package_spec.rb +10 -0
- data/spec/unit/type/resources_spec.rb +4 -5
- data/spec/unit/type/ssh_authorized_key_spec.rb +4 -15
- data/spec/unit/type/sshkey_spec.rb +9 -11
- data/spec/unit/type/user_spec.rb +123 -127
- data/spec/unit/type_spec.rb +20 -0
- data/spec/unit/util/command_line_spec.rb +2 -2
- data/spec/unit/util/instrumentation/data_spec.rb +1 -1
- data/spec/unit/util/instrumentation/indirection_probe_spec.rb +1 -1
- data/spec/unit/util/instrumentation/instrumentable_spec.rb +1 -1
- data/spec/unit/util/instrumentation/listener_spec.rb +1 -1
- data/spec/unit/util/instrumentation/listeners/log_spec.rb +1 -1
- data/spec/unit/util/instrumentation/listeners/performance_spec.rb +1 -1
- data/spec/unit/util/instrumentation_spec.rb +1 -1
- data/spec/unit/util/log/destinations_spec.rb +4 -8
- data/spec/unit/util/log_spec.rb +47 -0
- data/spec/unit/util/reference_spec.rb +1 -1
- data/spec/unit/util/settings/file_setting_spec.rb +9 -0
- data/spec/unit/util/settings_spec.rb +0 -53
- data/spec/unit/util/terminal_spec.rb +42 -0
- data/spec/unit/util/zaml_spec.rb +7 -0
- data/spec/unit/util_spec.rb +63 -20
- data/tasks/rake/manpages.rake +1 -1
- data/test/data/snippets/arithmetic_expression.pp +1 -1
- data/test/other/puppet.rb +0 -1
- data/test/util/log.rb +6 -6
- metadata +41 -16
- data/lib/puppet/external/event-loop.rb +0 -1
- data/lib/puppet/external/event-loop/better-definers.rb +0 -367
- data/lib/puppet/external/event-loop/event-loop.rb +0 -355
- data/lib/puppet/external/event-loop/signal-system.rb +0 -218
- data/lib/puppet/face/module/clean.rb +0 -30
- data/lib/puppet/module_tool/applications/cleaner.rb +0 -16
- data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json +0 -12
- data/lib/puppet/module_tool/utils.rb +0 -5
- data/lib/puppet/module_tool/utils/interrogation.rb +0 -25
- data/spec/integration/module_tool_spec.rb +0 -475
- data/spec/unit/module_tool/uninstaller_spec.rb +0 -124
data/lib/puppet/type.rb
CHANGED
@@ -123,6 +123,13 @@ class Type
|
|
123
123
|
}
|
124
124
|
end
|
125
125
|
|
126
|
+
# These `apply_to` methods are horrible. They should really be implemented
|
127
|
+
# as part of the usual system of constraints that apply to a type and
|
128
|
+
# provider pair, but were implemented as a separate shadow system.
|
129
|
+
#
|
130
|
+
# We should rip them out in favour of a real constraint pattern around the
|
131
|
+
# target device - whatever that looks like - and not have this additional
|
132
|
+
# magic here. --daniel 2012-03-08
|
126
133
|
def self.apply_to_device
|
127
134
|
@apply_to = :device
|
128
135
|
end
|
@@ -905,9 +912,10 @@ class Type
|
|
905
912
|
|
906
913
|
# Return a list of one suitable provider per source, with the default provider first.
|
907
914
|
def self.providers_by_source
|
908
|
-
# Put the default provider first, then the rest of the suitable providers.
|
915
|
+
# Put the default provider first (can be nil), then the rest of the suitable providers.
|
909
916
|
sources = []
|
910
917
|
[defaultprovider, suitableprovider].flatten.uniq.collect do |provider|
|
918
|
+
next if provider.nil?
|
911
919
|
next if sources.include?(provider.source)
|
912
920
|
|
913
921
|
sources << provider.source
|
data/lib/puppet/type/file.rb
CHANGED
@@ -210,8 +210,12 @@ Puppet::Type.newtype(:file) do
|
|
210
210
|
end
|
211
211
|
|
212
212
|
newparam(:force, :boolean => true) do
|
213
|
-
desc "
|
214
|
-
|
213
|
+
desc "Perform the file operation even if it will destroy one or more directories.
|
214
|
+
You must use `force` in order to:
|
215
|
+
|
216
|
+
* `purge` subdirectories
|
217
|
+
* Replace directories with files or links
|
218
|
+
* Remove a directory when `ensure => absent`"
|
215
219
|
newvalues(:true, :false)
|
216
220
|
defaultto false
|
217
221
|
end
|
@@ -244,14 +248,18 @@ Puppet::Type.newtype(:file) do
|
|
244
248
|
end
|
245
249
|
|
246
250
|
newparam(:purge, :boolean => true) do
|
247
|
-
desc "Whether unmanaged files should be purged.
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
251
|
+
desc "Whether unmanaged files should be purged. This option only makes
|
252
|
+
sense when managing directories with `recurse => true`.
|
253
|
+
|
254
|
+
* When recursively duplicating an entire directory with the `source`
|
255
|
+
attribute, `purge => true` will automatically purge any files
|
256
|
+
that are not in the source directory.
|
257
|
+
* When managing files in a directory as individual resources,
|
258
|
+
setting `purge => true` will purge any files that aren't being
|
259
|
+
specifically managed.
|
260
|
+
|
261
|
+
If you have a filebucket configured, the purged files will be uploaded,
|
262
|
+
but if you do not, this will destroy data."
|
255
263
|
|
256
264
|
defaultto :false
|
257
265
|
|
data/lib/puppet/type/package.rb
CHANGED
@@ -141,16 +141,20 @@ module Puppet
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
case
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
144
|
+
case
|
145
|
+
when is.is_a?(Array) && is.include?(@latest)
|
146
|
+
return true
|
147
|
+
when is == @latest
|
148
|
+
return true
|
149
|
+
when is == :present
|
150
|
+
# This will only happen on retarded packaging systems
|
151
|
+
# that can't query versions.
|
152
|
+
return true
|
153
|
+
else
|
154
|
+
self.debug "#{@resource.name} #{is.inspect} is installed, latest is #{@latest.inspect}"
|
153
155
|
end
|
156
|
+
|
157
|
+
|
154
158
|
when :absent
|
155
159
|
return true if is == :absent or is == :purged
|
156
160
|
when :purged
|
@@ -118,10 +118,10 @@ Puppet::Type.newtype(:resources) do
|
|
118
118
|
return true unless self[:unless_system_user]
|
119
119
|
|
120
120
|
resource[:audit] = :uid
|
121
|
-
current_values = resource.retrieve_resource
|
122
121
|
|
123
122
|
return false if system_users.include?(resource[:name])
|
124
123
|
|
124
|
+
current_values = resource.retrieve_resource
|
125
125
|
current_values[resource.property(:uid)] > self[:unless_system_user]
|
126
126
|
end
|
127
127
|
|
@@ -20,11 +20,10 @@ module Puppet
|
|
20
20
|
newproperty(:type) do
|
21
21
|
desc "The encryption type used: ssh-dss or ssh-rsa."
|
22
22
|
|
23
|
-
|
24
|
-
newvalue("ssh-rsa")
|
23
|
+
newvalues :'ssh-dss', :'ssh-rsa', :'ecdsa-sha2-nistp256', :'ecdsa-sha2-nistp384', :'ecdsa-sha2-nistp521'
|
25
24
|
|
26
|
-
aliasvalue(:dsa,
|
27
|
-
aliasvalue(:rsa,
|
25
|
+
aliasvalue(:dsa, :'ssh-dss')
|
26
|
+
aliasvalue(:rsa, :'ssh-rsa')
|
28
27
|
end
|
29
28
|
|
30
29
|
newproperty(:key) do
|
data/lib/puppet/type/sshkey.rb
CHANGED
@@ -9,10 +9,10 @@ module Puppet
|
|
9
9
|
newproperty(:type) do
|
10
10
|
desc "The encryption type used. Probably ssh-dss or ssh-rsa."
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
aliasvalue(:dsa,
|
15
|
-
aliasvalue(:rsa,
|
12
|
+
newvalues :'ssh-dss', :'ssh-rsa', :'ecdsa-sha2-nistp256', :'ecdsa-sha2-nistp384', :'ecdsa-sha2-nistp521'
|
13
|
+
|
14
|
+
aliasvalue(:dsa, :'ssh-dss')
|
15
|
+
aliasvalue(:rsa, :'ssh-rsa')
|
16
16
|
end
|
17
17
|
|
18
18
|
newproperty(:key) do
|
data/lib/puppet/type/user.rb
CHANGED
@@ -250,6 +250,7 @@ module Puppet
|
|
250
250
|
raise ArgumentError, "Group names must be provided, not GID numbers."
|
251
251
|
end
|
252
252
|
raise ArgumentError, "Group names must be provided as an array, not a comma-separated list." if value.include?(",")
|
253
|
+
raise ArgumentError, "Group names must not be empty. If you want to specify \"no groups\" pass an empty array" if value.empty?
|
253
254
|
end
|
254
255
|
end
|
255
256
|
|
data/lib/puppet/type/vlan.rb
CHANGED
data/lib/puppet/util.rb
CHANGED
@@ -196,8 +196,17 @@ module Util
|
|
196
196
|
:windows => %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i,
|
197
197
|
:posix => %r!^/!,
|
198
198
|
}
|
199
|
+
|
200
|
+
# Due to weird load order issues, I was unable to remove this require.
|
201
|
+
# This is fixed in Telly so it can be removed there.
|
199
202
|
require 'puppet'
|
200
|
-
|
203
|
+
|
204
|
+
# Ruby only sets File::ALT_SEPARATOR on Windows and the Ruby standard
|
205
|
+
# library uses that to test what platform it's on. Normally in Puppet we
|
206
|
+
# would use Puppet.features.microsoft_windows?, but this method needs to
|
207
|
+
# be called during the initialization of features so it can't depend on
|
208
|
+
# that.
|
209
|
+
platform ||= File::ALT_SEPARATOR ? :windows : :posix
|
201
210
|
|
202
211
|
!! (path =~ regexes[platform])
|
203
212
|
end
|
@@ -292,7 +301,7 @@ module Util
|
|
292
301
|
end
|
293
302
|
|
294
303
|
def execute_posix(command, arguments, stdin, stdout, stderr)
|
295
|
-
child_pid =
|
304
|
+
child_pid = safe_posix_fork(stdin, stdout, stderr) do
|
296
305
|
# We can't just call Array(command), and rely on it returning
|
297
306
|
# things like ['foo'], when passed ['foo'], because
|
298
307
|
# Array(command) will call command.to_a internally, which when
|
@@ -301,12 +310,6 @@ module Util
|
|
301
310
|
command = [command].flatten
|
302
311
|
Process.setsid
|
303
312
|
begin
|
304
|
-
$stdin.reopen(stdin)
|
305
|
-
$stdout.reopen(stdout)
|
306
|
-
$stderr.reopen(stderr)
|
307
|
-
|
308
|
-
3.upto(256){|fd| IO::new(fd).close rescue nil}
|
309
|
-
|
310
313
|
Puppet::Util::SUIDManager.change_privileges(arguments[:uid], arguments[:gid], true)
|
311
314
|
|
312
315
|
ENV['LANG'] = ENV['LC_ALL'] = ENV['LC_MESSAGES'] = ENV['LANGUAGE'] = 'C'
|
@@ -320,6 +323,20 @@ module Util
|
|
320
323
|
end
|
321
324
|
module_function :execute_posix
|
322
325
|
|
326
|
+
def safe_posix_fork(stdin=$stdin, stdout=$stdout, stderr=$stderr, &block)
|
327
|
+
child_pid = Kernel.fork do
|
328
|
+
$stdin.reopen(stdin)
|
329
|
+
$stdout.reopen(stdout)
|
330
|
+
$stderr.reopen(stderr)
|
331
|
+
|
332
|
+
3.upto(256){|fd| IO::new(fd).close rescue nil}
|
333
|
+
|
334
|
+
block.call if block
|
335
|
+
end
|
336
|
+
child_pid
|
337
|
+
end
|
338
|
+
module_function :safe_posix_fork
|
339
|
+
|
323
340
|
def execute_windows(command, arguments, stdin, stdout, stderr)
|
324
341
|
command = command.map do |part|
|
325
342
|
part.include?(' ') ? %Q["#{part.gsub(/"/, '\"')}"] : part
|
@@ -447,15 +464,15 @@ module Util
|
|
447
464
|
newhash[name] = val
|
448
465
|
end
|
449
466
|
end
|
467
|
+
newhash
|
450
468
|
end
|
451
469
|
|
452
470
|
def symbolizehash!(hash)
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
end
|
471
|
+
# this is not the most memory-friendly way to accomplish this, but the
|
472
|
+
# code re-use and clarity seems worthwhile.
|
473
|
+
newhash = symbolizehash(hash)
|
474
|
+
hash.clear
|
475
|
+
hash.merge!(newhash)
|
459
476
|
|
460
477
|
hash
|
461
478
|
end
|
data/lib/puppet/util/autoload.rb
CHANGED
@@ -48,7 +48,7 @@ class Puppet::Util::Autoload
|
|
48
48
|
|
49
49
|
def initialize(obj, path, options = {})
|
50
50
|
@path = path.to_s
|
51
|
-
raise ArgumentError, "Autoload paths cannot be fully qualified" if @path
|
51
|
+
raise ArgumentError, "Autoload paths cannot be fully qualified" if absolute_path?(@path)
|
52
52
|
@object = obj
|
53
53
|
|
54
54
|
self.class[obj] = self
|
@@ -67,10 +67,7 @@ module Puppet
|
|
67
67
|
end
|
68
68
|
|
69
69
|
app.run
|
70
|
-
elsif execute_external_subcommand then
|
71
|
-
# Logically, we shouldn't get here, but we do, so whatever. We just
|
72
|
-
# return to the caller. How strange we are. --daniel 2011-04-11
|
73
|
-
else
|
70
|
+
elsif ! execute_external_subcommand then
|
74
71
|
unless subcommand_name.nil? then
|
75
72
|
puts "Error: Unknown Puppet subcommand '#{subcommand_name}'"
|
76
73
|
end
|
@@ -85,8 +82,7 @@ module Puppet
|
|
85
82
|
path_to_subcommand = Puppet::Util.which(external_command)
|
86
83
|
return false unless path_to_subcommand
|
87
84
|
|
88
|
-
|
89
|
-
true
|
85
|
+
exec(path_to_subcommand, *args)
|
90
86
|
end
|
91
87
|
|
92
88
|
def legacy_executable_name
|
data/lib/puppet/util/log.rb
CHANGED
@@ -196,7 +196,9 @@ class Puppet::Util::Log
|
|
196
196
|
end
|
197
197
|
|
198
198
|
def self.setup_default
|
199
|
-
Log.newdestination(
|
199
|
+
Log.newdestination(
|
200
|
+
(Puppet.features.syslog? ? :syslog :
|
201
|
+
(Puppet.features.eventlog? ? :eventlog : Puppet[:puppetdlog])))
|
200
202
|
end
|
201
203
|
|
202
204
|
# Is the passed level a valid log level?
|
@@ -228,3 +228,41 @@ Puppet::Util::Log.newdesttype :array do
|
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
231
|
+
Puppet::Util::Log.newdesttype :eventlog do
|
232
|
+
def self.suitable?(obj)
|
233
|
+
Puppet.features.eventlog?
|
234
|
+
end
|
235
|
+
|
236
|
+
def initialize
|
237
|
+
@eventlog = Win32::EventLog.open("Application")
|
238
|
+
end
|
239
|
+
|
240
|
+
def to_native(level)
|
241
|
+
case level
|
242
|
+
when :debug,:info,:notice
|
243
|
+
[Win32::EventLog::INFO, 0x01]
|
244
|
+
when :warning
|
245
|
+
[Win32::EventLog::WARN, 0x02]
|
246
|
+
when :err,:alert,:emerg,:crit
|
247
|
+
[Win32::EventLog::ERROR, 0x03]
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
def handle(msg)
|
252
|
+
native_type, native_id = to_native(msg.level)
|
253
|
+
|
254
|
+
@eventlog.report_event(
|
255
|
+
:source => "Puppet",
|
256
|
+
:event_type => native_type,
|
257
|
+
:event_id => native_id,
|
258
|
+
:data => (msg.source and msg.source != 'Puppet' ? "#{msg.source}: " : '') + msg.to_s
|
259
|
+
)
|
260
|
+
end
|
261
|
+
|
262
|
+
def close
|
263
|
+
if @eventlog
|
264
|
+
@eventlog.close
|
265
|
+
@eventlog = nil
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
@@ -170,3 +170,48 @@ module Kernel
|
|
170
170
|
self
|
171
171
|
end unless method_defined?(:tap)
|
172
172
|
end
|
173
|
+
|
174
|
+
# The mv method in Ruby 1.8.5 can't mv directories across devices
|
175
|
+
# File.rename causes "Invalid cross-device link", which is rescued, but in Ruby
|
176
|
+
# 1.8.5 it tries to recover with a copy and unlink, but the unlink causes the
|
177
|
+
# error "Is a directory". In newer Rubies remove_entry is used
|
178
|
+
# The implementation below is what's used in Ruby 1.8.7 and Ruby 1.9
|
179
|
+
if RUBY_VERSION == '1.8.5'
|
180
|
+
require 'fileutils'
|
181
|
+
|
182
|
+
module FileUtils
|
183
|
+
def mv(src, dest, options = {})
|
184
|
+
fu_check_options options, OPT_TABLE['mv']
|
185
|
+
fu_output_message "mv#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
|
186
|
+
return if options[:noop]
|
187
|
+
fu_each_src_dest(src, dest) do |s, d|
|
188
|
+
destent = Entry_.new(d, nil, true)
|
189
|
+
begin
|
190
|
+
if destent.exist?
|
191
|
+
if destent.directory?
|
192
|
+
raise Errno::EEXIST, dest
|
193
|
+
else
|
194
|
+
destent.remove_file if rename_cannot_overwrite_file?
|
195
|
+
end
|
196
|
+
end
|
197
|
+
begin
|
198
|
+
File.rename s, d
|
199
|
+
rescue Errno::EXDEV
|
200
|
+
copy_entry s, d, true
|
201
|
+
if options[:secure]
|
202
|
+
remove_entry_secure s, options[:force]
|
203
|
+
else
|
204
|
+
remove_entry s, options[:force]
|
205
|
+
end
|
206
|
+
end
|
207
|
+
rescue SystemCallError
|
208
|
+
raise unless options[:force]
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
module_function :mv
|
213
|
+
|
214
|
+
alias move mv
|
215
|
+
module_function :move
|
216
|
+
end
|
217
|
+
end
|