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.

Files changed (215) hide show
  1. data/CHANGELOG +144 -1
  2. data/conf/osx/preflight +1 -1
  3. data/conf/redhat/puppet.spec +9 -5
  4. data/conf/suse/puppet.spec +4 -1
  5. data/conf/windows/eventlog/Rakefile +32 -0
  6. data/conf/windows/eventlog/puppetres.dll +0 -0
  7. data/conf/windows/eventlog/puppetres.mc +18 -0
  8. data/ext/rack/files/apache2.conf +3 -0
  9. data/install.rb +23 -1
  10. data/lib/puppet.rb +1 -1
  11. data/lib/puppet/agent.rb +1 -14
  12. data/lib/puppet/application/kick.rb +1 -1
  13. data/lib/puppet/application/module.rb +11 -0
  14. data/lib/puppet/daemon.rb +74 -3
  15. data/lib/puppet/defaults.rb +1 -1
  16. data/lib/puppet/face/certificate.rb +1 -1
  17. data/lib/puppet/face/help/man.erb +1 -1
  18. data/lib/puppet/face/module.rb +17 -0
  19. data/lib/puppet/face/module/build.rb +10 -4
  20. data/lib/puppet/face/module/changes.rb +5 -5
  21. data/lib/puppet/face/module/generate.rb +6 -4
  22. data/lib/puppet/face/module/install.rb +122 -32
  23. data/lib/puppet/face/module/list.rb +234 -33
  24. data/lib/puppet/face/module/search.rb +56 -23
  25. data/lib/puppet/face/module/uninstall.rb +33 -38
  26. data/lib/puppet/face/module/upgrade.rb +84 -0
  27. data/lib/puppet/feature/eventlog.rb +6 -0
  28. data/lib/puppet/forge.rb +67 -122
  29. data/lib/puppet/forge/cache.rb +1 -1
  30. data/lib/puppet/forge/repository.rb +6 -25
  31. data/lib/puppet/indirector/facts/network_device.rb +1 -1
  32. data/lib/puppet/interface/action.rb +1 -1
  33. data/lib/puppet/module.rb +79 -28
  34. data/lib/puppet/module_tool.rb +72 -34
  35. data/lib/puppet/module_tool/applications.rb +12 -14
  36. data/lib/puppet/module_tool/applications/application.rb +21 -19
  37. data/lib/puppet/module_tool/applications/builder.rb +4 -4
  38. data/lib/puppet/module_tool/applications/checksummer.rb +12 -3
  39. data/lib/puppet/module_tool/applications/generator.rb +1 -1
  40. data/lib/puppet/module_tool/applications/installer.rb +163 -34
  41. data/lib/puppet/module_tool/applications/searcher.rb +2 -3
  42. data/lib/puppet/module_tool/applications/uninstaller.rb +84 -36
  43. data/lib/puppet/module_tool/applications/unpacker.rb +4 -26
  44. data/lib/puppet/module_tool/applications/upgrader.rb +109 -0
  45. data/lib/puppet/module_tool/checksums.rb +2 -2
  46. data/lib/puppet/module_tool/contents_description.rb +1 -1
  47. data/lib/puppet/module_tool/dependency.rb +2 -2
  48. data/lib/puppet/module_tool/errors.rb +9 -0
  49. data/lib/puppet/module_tool/errors/base.rb +15 -0
  50. data/lib/puppet/module_tool/errors/installer.rb +90 -0
  51. data/lib/puppet/module_tool/errors/shared.rb +115 -0
  52. data/lib/puppet/module_tool/errors/uninstaller.rb +45 -0
  53. data/lib/puppet/module_tool/errors/upgrader.rb +72 -0
  54. data/lib/puppet/module_tool/metadata.rb +2 -2
  55. data/lib/puppet/module_tool/modulefile.rb +7 -7
  56. data/lib/puppet/module_tool/shared_behaviors.rb +161 -0
  57. data/lib/puppet/module_tool/skeleton.rb +1 -1
  58. data/lib/puppet/node/environment.rb +4 -2
  59. data/lib/puppet/parser/ast/leaf.rb +1 -1
  60. data/lib/puppet/parser/functions/create_resources.rb +3 -2
  61. data/lib/puppet/parser/scope.rb +44 -9
  62. data/lib/puppet/provider/augeas/augeas.rb +2 -2
  63. data/lib/puppet/provider/exec.rb +8 -3
  64. data/lib/puppet/provider/exec/shell.rb +1 -2
  65. data/lib/puppet/provider/nameservice/directoryservice.rb +10 -4
  66. data/lib/puppet/provider/package/gem.rb +1 -1
  67. data/lib/puppet/provider/package/pkg.rb +10 -21
  68. data/lib/puppet/provider/selmodule/semodule.rb +1 -2
  69. data/lib/puppet/provider/service/upstart.rb +33 -17
  70. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  71. data/lib/puppet/rails/inventory_node.rb +7 -7
  72. data/lib/puppet/reports/http.rb +4 -1
  73. data/lib/puppet/reports/tagmail.rb +8 -1
  74. data/lib/puppet/resource/type.rb +1 -1
  75. data/lib/puppet/test/test_helper.rb +138 -0
  76. data/lib/puppet/type.rb +9 -1
  77. data/lib/puppet/type/file.rb +18 -10
  78. data/lib/puppet/type/package.rb +13 -9
  79. data/lib/puppet/type/resources.rb +1 -1
  80. data/lib/puppet/type/ssh_authorized_key.rb +3 -4
  81. data/lib/puppet/type/sshkey.rb +4 -4
  82. data/lib/puppet/type/user.rb +1 -0
  83. data/lib/puppet/type/vlan.rb +1 -1
  84. data/lib/puppet/util.rb +31 -14
  85. data/lib/puppet/util/autoload.rb +1 -1
  86. data/lib/puppet/util/command_line.rb +2 -6
  87. data/lib/puppet/util/instrumentation/indirection_probe.rb +1 -1
  88. data/lib/puppet/util/instrumentation/instrumentable.rb +1 -1
  89. data/lib/puppet/util/instrumentation/listeners/log.rb +1 -1
  90. data/lib/puppet/util/instrumentation/listeners/performance.rb +1 -1
  91. data/lib/puppet/util/log.rb +3 -1
  92. data/lib/puppet/util/log/destinations.rb +38 -0
  93. data/lib/puppet/util/monkey_patches.rb +45 -0
  94. data/lib/puppet/util/network_device/base.rb +1 -1
  95. data/lib/puppet/util/network_device/cisco.rb +1 -1
  96. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  97. data/lib/puppet/util/network_device/cisco/interface.rb +1 -1
  98. data/lib/puppet/util/network_device/config.rb +1 -1
  99. data/lib/puppet/util/network_device/ipcalc.rb +1 -1
  100. data/lib/puppet/util/network_device/transport.rb +1 -1
  101. data/lib/puppet/util/network_device/transport/base.rb +1 -1
  102. data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
  103. data/lib/puppet/util/settings.rb +2 -11
  104. data/lib/puppet/util/settings/file_setting.rb +3 -5
  105. data/lib/puppet/util/terminal.rb +16 -0
  106. data/lib/puppet/util/zaml.rb +3 -1
  107. data/lib/semver.rb +15 -7
  108. data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -1
  109. data/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp +1 -1
  110. data/spec/fixtures/unit/provider/package/pkg/dummy +1 -0
  111. data/spec/fixtures/unit/provider/package/pkg/incomplete +1 -0
  112. data/spec/fixtures/unit/provider/package/pkg/publisher +2 -0
  113. data/spec/fixtures/unit/provider/package/pkg/simple +4 -0
  114. data/spec/fixtures/unit/reports/tagmail/tagmail_email.conf +2 -0
  115. data/spec/fixtures/yaml/report0.25.x.yaml +1 -1
  116. data/spec/fixtures/yaml/report2.6.x.yaml +1 -1
  117. data/spec/integration/faces/documentation_spec.rb +1 -1
  118. data/spec/integration/network/rest_authconfig_spec.rb +1 -1
  119. data/spec/lib/puppet_spec/compiler.rb +6 -0
  120. data/spec/lib/puppet_spec/database.rb +30 -0
  121. data/spec/lib/puppet_spec/files.rb +4 -2
  122. data/spec/shared_behaviours/path_parameters.rb +2 -29
  123. data/spec/shared_contexts/platform.rb +43 -0
  124. data/spec/spec_helper.rb +36 -65
  125. data/spec/unit/agent_spec.rb +0 -32
  126. data/spec/unit/application/kick_spec.rb +2 -2
  127. data/spec/unit/daemon_spec.rb +1 -17
  128. data/spec/unit/face/module/install_spec.rb +158 -0
  129. data/spec/unit/face/module/list_spec.rb +182 -0
  130. data/spec/unit/face/module/search_spec.rb +163 -0
  131. data/spec/unit/face/module/uninstall_spec.rb +77 -0
  132. data/spec/unit/face/module/upgrade_spec.rb +26 -0
  133. data/spec/unit/forge/repository_spec.rb +0 -30
  134. data/spec/unit/forge_spec.rb +28 -86
  135. data/spec/unit/indirector/catalog/active_record_spec.rb +45 -65
  136. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -18
  137. data/spec/unit/indirector/resource/active_record_spec.rb +2 -11
  138. data/spec/unit/indirector/resource/ral_spec.rb +7 -2
  139. data/spec/unit/module_spec.rb +240 -107
  140. data/spec/unit/module_tool/application_spec.rb +3 -5
  141. data/spec/unit/module_tool/applications/application_spec.rb +19 -0
  142. data/spec/unit/module_tool/applications/installer_spec.rb +205 -0
  143. data/spec/unit/module_tool/applications/uninstaller_spec.rb +206 -0
  144. data/spec/unit/module_tool/applications/upgrader_spec.rb +37 -0
  145. data/spec/unit/module_tool/metadata_spec.rb +2 -2
  146. data/spec/unit/module_tool_spec.rb +109 -1
  147. data/spec/unit/node/environment_spec.rb +16 -1
  148. data/spec/unit/parser/ast/leaf_spec.rb +16 -1
  149. data/spec/unit/parser/collector_spec.rb +2 -12
  150. data/spec/unit/parser/functions/create_resources_spec.rb +135 -86
  151. data/spec/unit/parser/functions/generate_spec.rb +2 -10
  152. data/spec/unit/parser/scope_spec.rb +345 -16
  153. data/spec/unit/provider/augeas/augeas_spec.rb +19 -0
  154. data/spec/unit/provider/exec/shell_spec.rb +17 -14
  155. data/spec/unit/provider/exec/windows_spec.rb +1 -7
  156. data/spec/unit/provider/exec_spec.rb +35 -0
  157. data/spec/unit/provider/nameservice/directoryservice_spec.rb +10 -0
  158. data/spec/unit/provider/package/dpkg_spec.rb +2 -1
  159. data/spec/unit/provider/package/gem_spec.rb +15 -0
  160. data/spec/unit/provider/package/openbsd_spec.rb +5 -4
  161. data/spec/unit/provider/package/pacman_spec.rb +3 -2
  162. data/spec/unit/provider/package/pkg_spec.rb +56 -33
  163. data/spec/unit/provider/selmodule_spec.rb +11 -4
  164. data/spec/unit/provider/service/redhat_spec.rb +1 -3
  165. data/spec/unit/provider/service/smf_spec.rb +1 -3
  166. data/spec/unit/provider/service/upstart_spec.rb +38 -0
  167. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +28 -0
  168. data/spec/unit/rails/host_spec.rb +6 -12
  169. data/spec/unit/rails/param_value_spec.rb +3 -8
  170. data/spec/unit/rails/resource_spec.rb +2 -8
  171. data/spec/unit/reports/http_spec.rb +47 -31
  172. data/spec/unit/reports/tagmail_spec.rb +77 -0
  173. data/spec/unit/resource/type_spec.rb +2 -2
  174. data/spec/unit/resource_spec.rb +18 -20
  175. data/spec/unit/semver_spec.rb +31 -13
  176. data/spec/unit/type/exec_spec.rb +8 -15
  177. data/spec/unit/type/group_spec.rb +0 -9
  178. data/spec/unit/type/package_spec.rb +10 -0
  179. data/spec/unit/type/resources_spec.rb +4 -5
  180. data/spec/unit/type/ssh_authorized_key_spec.rb +4 -15
  181. data/spec/unit/type/sshkey_spec.rb +9 -11
  182. data/spec/unit/type/user_spec.rb +123 -127
  183. data/spec/unit/type_spec.rb +20 -0
  184. data/spec/unit/util/command_line_spec.rb +2 -2
  185. data/spec/unit/util/instrumentation/data_spec.rb +1 -1
  186. data/spec/unit/util/instrumentation/indirection_probe_spec.rb +1 -1
  187. data/spec/unit/util/instrumentation/instrumentable_spec.rb +1 -1
  188. data/spec/unit/util/instrumentation/listener_spec.rb +1 -1
  189. data/spec/unit/util/instrumentation/listeners/log_spec.rb +1 -1
  190. data/spec/unit/util/instrumentation/listeners/performance_spec.rb +1 -1
  191. data/spec/unit/util/instrumentation_spec.rb +1 -1
  192. data/spec/unit/util/log/destinations_spec.rb +4 -8
  193. data/spec/unit/util/log_spec.rb +47 -0
  194. data/spec/unit/util/reference_spec.rb +1 -1
  195. data/spec/unit/util/settings/file_setting_spec.rb +9 -0
  196. data/spec/unit/util/settings_spec.rb +0 -53
  197. data/spec/unit/util/terminal_spec.rb +42 -0
  198. data/spec/unit/util/zaml_spec.rb +7 -0
  199. data/spec/unit/util_spec.rb +63 -20
  200. data/tasks/rake/manpages.rake +1 -1
  201. data/test/data/snippets/arithmetic_expression.pp +1 -1
  202. data/test/other/puppet.rb +0 -1
  203. data/test/util/log.rb +6 -6
  204. metadata +41 -16
  205. data/lib/puppet/external/event-loop.rb +0 -1
  206. data/lib/puppet/external/event-loop/better-definers.rb +0 -367
  207. data/lib/puppet/external/event-loop/event-loop.rb +0 -355
  208. data/lib/puppet/external/event-loop/signal-system.rb +0 -218
  209. data/lib/puppet/face/module/clean.rb +0 -30
  210. data/lib/puppet/module_tool/applications/cleaner.rb +0 -16
  211. data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json +0 -12
  212. data/lib/puppet/module_tool/utils.rb +0 -5
  213. data/lib/puppet/module_tool/utils/interrogation.rb +0 -25
  214. data/spec/integration/module_tool_spec.rb +0 -475
  215. data/spec/unit/module_tool/uninstaller_spec.rb +0 -124
@@ -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
@@ -210,8 +210,12 @@ Puppet::Type.newtype(:file) do
210
210
  end
211
211
 
212
212
  newparam(:force, :boolean => true) do
213
- desc "Force the file operation. Currently only used when replacing
214
- directories with links."
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. If you have a filebucket
248
- configured the purged files will be uploaded, but if you do not,
249
- this will destroy data. Only use this option for generated
250
- files unless you really know what you are doing. This option only
251
- makes sense when recursively managing directories.
252
-
253
- Note that when using `purge` with `source`, Puppet will purge any files
254
- that are not on the remote system."
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
 
@@ -141,16 +141,20 @@ module Puppet
141
141
  end
142
142
  end
143
143
 
144
- case is
145
- when @latest
146
- return true
147
- when :present
148
- # This will only happen on retarded packaging systems
149
- # that can't query versions.
150
- return true
151
- else
152
- self.debug "#{@resource.name} #{is.inspect} is installed, latest is #{@latest.inspect}"
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
- newvalue("ssh-dss")
24
- newvalue("ssh-rsa")
23
+ newvalues :'ssh-dss', :'ssh-rsa', :'ecdsa-sha2-nistp256', :'ecdsa-sha2-nistp384', :'ecdsa-sha2-nistp521'
25
24
 
26
- aliasvalue(:dsa, "ssh-dss")
27
- aliasvalue(:rsa, "ssh-rsa")
25
+ aliasvalue(:dsa, :'ssh-dss')
26
+ aliasvalue(:rsa, :'ssh-rsa')
28
27
  end
29
28
 
30
29
  newproperty(:key) do
@@ -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
- newvalue("ssh-dss")
13
- newvalue("ssh-rsa")
14
- aliasvalue(:dsa, "ssh-dss")
15
- aliasvalue(:rsa, "ssh-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
@@ -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
 
@@ -23,4 +23,4 @@ Puppet::Type.newtype(:vlan) do
23
23
  newparam(:device_url) do
24
24
  desc "The URL of the router or switch maintaining this VLAN."
25
25
  end
26
- end
26
+ end
@@ -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
- platform ||= Puppet.features.microsoft_windows? ? :windows : :posix
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 = Kernel.fork do
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
- hash.each do |name, val|
454
- if name.is_a? String
455
- hash[name.intern] = val
456
- hash.delete(name)
457
- end
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
@@ -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 !~ /^\w/
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
- system(path_to_subcommand, *args)
89
- true
85
+ exec(path_to_subcommand, *args)
90
86
  end
91
87
 
92
88
  def legacy_executable_name
@@ -26,4 +26,4 @@ class Puppet::Util::Instrumentation::IndirectionProbe
26
26
  def self.from_pson(data)
27
27
  self.new(data["name"])
28
28
  end
29
- end
29
+ end
@@ -140,4 +140,4 @@ module Puppet::Util::Instrumentation::Instrumentable
140
140
  }
141
141
  nil # do not leak our probes to the exterior world
142
142
  end
143
- end
143
+ end
@@ -26,4 +26,4 @@ Puppet::Util::Instrumentation.new_listener(:log) do
26
26
  @last_logs.dup
27
27
  }
28
28
  end
29
- end
29
+ end
@@ -27,4 +27,4 @@ Puppet::Util::Instrumentation.new_listener(:performance) do
27
27
  @samples.dup
28
28
  end
29
29
  end
30
- end
30
+ end
@@ -196,7 +196,9 @@ class Puppet::Util::Log
196
196
  end
197
197
 
198
198
  def self.setup_default
199
- Log.newdestination(Puppet.features.syslog? ? :syslog : Puppet[:puppetdlog])
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
@@ -24,4 +24,4 @@ class Puppet::Util::NetworkDevice::Base
24
24
  @transport.password = @url.password
25
25
  end
26
26
  end
27
- end
27
+ end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Puppet::Util::NetworkDevice::Cisco
3
3
 
4
- end
4
+ end
@@ -69,4 +69,4 @@ class Puppet::Util::NetworkDevice::Cisco::Facts
69
69
  end
70
70
  end
71
71
 
72
- end
72
+ end
@@ -79,4 +79,4 @@ class Puppet::Util::NetworkDevice::Cisco::Interface
79
79
  Puppet.err "Error while executing #{command}, device returned #{out}" if out =~ /^%/mo
80
80
  end
81
81
  end
82
- end
82
+ end
@@ -89,4 +89,4 @@ class Puppet::Util::NetworkDevice::Config < Puppet::Util::LoadedFile
89
89
  end
90
90
  end
91
91
 
92
- end
92
+ end
@@ -65,4 +65,4 @@ module Puppet::Util::NetworkDevice::IPCalc
65
65
  def linklocal?(ip)
66
66
  end
67
67
 
68
- end
68
+ end
@@ -1,3 +1,3 @@
1
1
  # stub
2
2
  module Puppet::Util::NetworkDevice::Transport
3
- end
3
+ end