puppet 2.7.11 → 2.7.12

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 (220) hide show
  1. data/CHANGELOG +188 -0
  2. data/conf/osx/createpackage.sh +1 -0
  3. data/conf/redhat/puppet.spec +12 -9
  4. data/conf/suse/puppet.spec +4 -1
  5. data/install.rb +9 -22
  6. data/lib/puppet.rb +1 -31
  7. data/lib/puppet/agent.rb +3 -5
  8. data/lib/puppet/agent/locker.rb +15 -1
  9. data/lib/puppet/application.rb +7 -4
  10. data/lib/puppet/application/agent.rb +4 -25
  11. data/lib/puppet/application/apply.rb +3 -3
  12. data/lib/puppet/application/device.rb +2 -16
  13. data/lib/puppet/application/doc.rb +2 -2
  14. data/lib/puppet/application/face_base.rb +22 -5
  15. data/lib/puppet/application/filebucket.rb +2 -0
  16. data/lib/puppet/application/inspect.rb +2 -1
  17. data/lib/puppet/application/kick.rb +25 -9
  18. data/lib/puppet/application/queue.rb +0 -23
  19. data/lib/puppet/configurer.rb +1 -0
  20. data/lib/puppet/configurer/downloader.rb +7 -3
  21. data/lib/puppet/defaults.rb +34 -29
  22. data/lib/puppet/face/ca.rb +1 -1
  23. data/lib/puppet/face/catalog.rb +1 -0
  24. data/lib/puppet/face/file/store.rb +1 -1
  25. data/lib/puppet/face/module/list.rb +23 -3
  26. data/lib/puppet/face/module/search.rb +21 -32
  27. data/lib/puppet/face/module/uninstall.rb +56 -15
  28. data/lib/puppet/file_bucket/dipper.rb +2 -2
  29. data/lib/puppet/file_serving/base.rb +6 -5
  30. data/lib/puppet/file_serving/configuration/parser.rb +1 -1
  31. data/lib/puppet/file_serving/content.rb +1 -1
  32. data/lib/puppet/forge.rb +153 -0
  33. data/lib/puppet/{module_tool → forge}/cache.rb +1 -2
  34. data/lib/puppet/{module_tool → forge}/repository.rb +46 -4
  35. data/lib/puppet/indirector/exec.rb +1 -1
  36. data/lib/puppet/indirector/file_bucket_file/file.rb +3 -3
  37. data/lib/puppet/interface/action.rb +6 -2
  38. data/lib/puppet/module.rb +70 -10
  39. data/lib/puppet/module_tool.rb +2 -38
  40. data/lib/puppet/module_tool/applications.rb +15 -11
  41. data/lib/puppet/module_tool/applications/application.rb +2 -5
  42. data/lib/puppet/module_tool/applications/cleaner.rb +1 -1
  43. data/lib/puppet/module_tool/applications/installer.rb +10 -45
  44. data/lib/puppet/module_tool/applications/searcher.rb +2 -26
  45. data/lib/puppet/module_tool/applications/uninstaller.rb +39 -13
  46. data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
  47. data/lib/puppet/module_tool/dependency.rb +1 -1
  48. data/lib/puppet/network/authconfig.rb +1 -1
  49. data/lib/puppet/network/handler/fileserver.rb +1 -1
  50. data/lib/puppet/network/http/handler.rb +4 -1
  51. data/lib/puppet/network/http/webrick.rb +4 -2
  52. data/lib/puppet/node/environment.rb +32 -6
  53. data/lib/puppet/parameter/path.rb +0 -4
  54. data/lib/puppet/parser/ast/relationship.rb +3 -16
  55. data/lib/puppet/parser/collector.rb +5 -3
  56. data/lib/puppet/parser/compiler.rb +2 -1
  57. data/lib/puppet/parser/functions/file.rb +1 -1
  58. data/lib/puppet/parser/functions/generate.rb +8 -2
  59. data/lib/puppet/parser/grammar.ra +16 -15
  60. data/lib/puppet/parser/parser.rb +959 -881
  61. data/lib/puppet/parser/relationship.rb +32 -15
  62. data/lib/puppet/parser/resource.rb +0 -1
  63. data/lib/puppet/parser/type_loader.rb +1 -2
  64. data/lib/puppet/provider/augeas/augeas.rb +17 -29
  65. data/lib/puppet/provider/exec/windows.rb +25 -3
  66. data/lib/puppet/provider/file/posix.rb +1 -1
  67. data/lib/puppet/provider/file/windows.rb +1 -1
  68. data/lib/puppet/provider/group/windows_adsi.rb +1 -1
  69. data/lib/puppet/provider/package/aix.rb +1 -1
  70. data/lib/puppet/provider/package/appdmg.rb +1 -1
  71. data/lib/puppet/provider/package/dpkg.rb +1 -1
  72. data/lib/puppet/provider/package/gem.rb +21 -23
  73. data/lib/puppet/provider/package/macports.rb +1 -1
  74. data/lib/puppet/provider/package/msi.rb +7 -1
  75. data/lib/puppet/provider/package/openbsd.rb +13 -16
  76. data/lib/puppet/provider/package/pacman.rb +1 -1
  77. data/lib/puppet/provider/package/pip.rb +3 -0
  78. data/lib/puppet/provider/package/pkg.rb +1 -1
  79. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  80. data/lib/puppet/provider/package/pkgutil.rb +1 -1
  81. data/lib/puppet/provider/package/portage.rb +2 -2
  82. data/lib/puppet/provider/package/rpm.rb +1 -1
  83. data/lib/puppet/provider/package/sun.rb +1 -1
  84. data/lib/puppet/provider/package/zypper.rb +35 -3
  85. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +6 -2
  86. data/lib/puppet/provider/selmodule/semodule.rb +2 -2
  87. data/lib/puppet/provider/service/base.rb +1 -1
  88. data/lib/puppet/provider/service/launchd.rb +4 -0
  89. data/lib/puppet/provider/service/src.rb +2 -2
  90. data/lib/puppet/provider/service/upstart.rb +1 -1
  91. data/lib/puppet/provider/service/windows.rb +5 -4
  92. data/lib/puppet/provider/user/aix.rb +3 -3
  93. data/lib/puppet/provider/user/pw.rb +6 -0
  94. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  95. data/lib/puppet/resource/catalog.rb +6 -6
  96. data/lib/puppet/resource/type.rb +2 -0
  97. data/lib/puppet/ssl/certificate_request.rb +0 -70
  98. data/lib/puppet/transaction.rb +1 -1
  99. data/lib/puppet/transaction/report.rb +3 -2
  100. data/lib/puppet/type.rb +1 -1
  101. data/lib/puppet/type/cron.rb +5 -2
  102. data/lib/puppet/type/exec.rb +8 -0
  103. data/lib/puppet/type/file.rb +27 -18
  104. data/lib/puppet/type/file/checksum.rb +2 -2
  105. data/lib/puppet/type/file/content.rb +14 -9
  106. data/lib/puppet/type/file/ensure.rb +5 -4
  107. data/lib/puppet/type/file/group.rb +10 -2
  108. data/lib/puppet/type/file/mode.rb +46 -18
  109. data/lib/puppet/type/file/owner.rb +10 -2
  110. data/lib/puppet/type/file/source.rb +27 -40
  111. data/lib/puppet/type/file/target.rb +6 -6
  112. data/lib/puppet/type/group.rb +13 -9
  113. data/lib/puppet/type/k5login.rb +1 -1
  114. data/lib/puppet/type/package.rb +24 -8
  115. data/lib/puppet/type/scheduled_task.rb +77 -131
  116. data/lib/puppet/type/service.rb +22 -8
  117. data/lib/puppet/type/user.rb +29 -9
  118. data/lib/puppet/util.rb +24 -33
  119. data/lib/puppet/util/colors.rb +98 -0
  120. data/lib/puppet/util/diff.rb +3 -1
  121. data/lib/puppet/util/log.rb +5 -1
  122. data/lib/puppet/util/log/destinations.rb +37 -44
  123. data/lib/puppet/util/monkey_patches.rb +32 -0
  124. data/lib/puppet/util/pidlock.rb +70 -21
  125. data/lib/puppet/util/rdoc/parser.rb +4 -2
  126. data/lib/puppet/util/selinux.rb +1 -1
  127. data/lib/puppet/util/suidmanager.rb +2 -12
  128. data/lib/puppet/util/windows.rb +2 -0
  129. data/lib/puppet/util/windows/process.rb +33 -0
  130. data/lib/puppet/util/windows/security.rb +6 -4
  131. data/lib/puppet/util/windows/user.rb +44 -0
  132. data/lib/semver.rb +55 -4
  133. data/spec/fixtures/unit/provider/package/openbsd/pkginfo.detail +19 -0
  134. data/spec/fixtures/unit/provider/package/openbsd/pkginfo.list +10 -0
  135. data/spec/fixtures/unit/provider/package/openbsd/pkginfo.query +1 -0
  136. data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out +369 -0
  137. data/spec/integration/defaults_spec.rb +10 -0
  138. data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
  139. data/spec/integration/module_tool_spec.rb +10 -12
  140. data/spec/integration/parser/compiler_spec.rb +147 -0
  141. data/spec/integration/type/file_spec.rb +1 -1
  142. data/spec/integration/util/windows/user_spec.rb +59 -0
  143. data/spec/lib/puppet/face/basetest.rb +5 -0
  144. data/spec/lib/puppet_spec/modules.rb +26 -0
  145. data/spec/spec_helper.rb +25 -0
  146. data/spec/unit/agent/locker_spec.rb +12 -0
  147. data/spec/unit/agent_backward_compatibility_spec.rb +152 -0
  148. data/spec/unit/agent_spec.rb +28 -8
  149. data/spec/unit/application/agent_spec.rb +4 -36
  150. data/spec/unit/application/device_spec.rb +55 -10
  151. data/spec/unit/application/face_base_spec.rb +32 -10
  152. data/spec/unit/application/filebucket_spec.rb +5 -0
  153. data/spec/unit/application/kick_spec.rb +6 -0
  154. data/spec/unit/application_spec.rb +8 -1
  155. data/spec/unit/configurer/downloader_spec.rb +4 -5
  156. data/spec/unit/face/ca_spec.rb +15 -4
  157. data/spec/unit/file_bucket/dipper_spec.rb +1 -1
  158. data/spec/unit/file_serving/base_spec.rb +60 -42
  159. data/spec/unit/file_serving/configuration/parser_spec.rb +5 -3
  160. data/spec/unit/file_serving/content_spec.rb +26 -27
  161. data/spec/unit/file_serving/metadata_spec.rb +22 -21
  162. data/spec/unit/forge/repository_spec.rb +86 -0
  163. data/spec/unit/forge_spec.rb +114 -0
  164. data/spec/unit/indirector/exec_spec.rb +8 -6
  165. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +0 -1
  166. data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
  167. data/spec/unit/indirector/node/exec_spec.rb +1 -1
  168. data/spec/unit/indirector/resource/active_record_spec.rb +0 -4
  169. data/spec/unit/interface/action_builder_spec.rb +7 -5
  170. data/spec/unit/module_spec.rb +228 -9
  171. data/spec/unit/module_tool/application_spec.rb +3 -3
  172. data/spec/unit/module_tool/uninstaller_spec.rb +107 -27
  173. data/spec/unit/module_tool_spec.rb +0 -33
  174. data/spec/unit/network/authconfig_spec.rb +22 -21
  175. data/spec/unit/network/http/webrick_spec.rb +13 -9
  176. data/spec/unit/node/environment_spec.rb +159 -66
  177. data/spec/unit/parser/collector_spec.rb +16 -8
  178. data/spec/unit/parser/functions/generate_spec.rb +60 -18
  179. data/spec/unit/parser/resource_spec.rb +44 -0
  180. data/spec/unit/provider/augeas/augeas_spec.rb +160 -179
  181. data/spec/unit/provider/confine/feature_spec.rb +3 -5
  182. data/spec/unit/provider/package/dpkg_spec.rb +4 -2
  183. data/spec/unit/provider/package/gem_spec.rb +59 -43
  184. data/spec/unit/provider/package/openbsd_spec.rb +114 -0
  185. data/spec/unit/provider/package/pacman_spec.rb +1 -1
  186. data/spec/unit/provider/package/pip_spec.rb +10 -4
  187. data/spec/unit/provider/package/zypper_spec.rb +56 -14
  188. data/spec/unit/provider/selmodule_spec.rb +3 -3
  189. data/spec/unit/provider/service/launchd_spec.rb +22 -21
  190. data/spec/unit/provider/service/{upstart.rb → upstart_spec.rb} +7 -3
  191. data/spec/unit/provider/user/pw_spec.rb +19 -0
  192. data/spec/unit/resource/catalog_spec.rb +3 -3
  193. data/spec/unit/semver_spec.rb +117 -24
  194. data/spec/unit/transaction/report_spec.rb +11 -1
  195. data/spec/unit/type/cron_spec.rb +200 -213
  196. data/spec/unit/type/exec_spec.rb +7 -0
  197. data/spec/unit/type/file/content_spec.rb +2 -2
  198. data/spec/unit/type/file_spec.rb +12 -9
  199. data/spec/unit/type/package_spec.rb +25 -0
  200. data/spec/unit/type/schedule_spec.rb +31 -31
  201. data/spec/unit/util/diff_spec.rb +30 -0
  202. data/spec/unit/util/execution_stub_spec.rb +1 -2
  203. data/spec/unit/util/log/destinations_spec.rb +51 -0
  204. data/spec/unit/util/log_spec.rb +17 -1
  205. data/spec/unit/util/monkey_patches_spec.rb +119 -0
  206. data/spec/unit/util/rdoc/parser_spec.rb +25 -1
  207. data/spec/unit/util/selinux_spec.rb +2 -2
  208. data/spec/unit/util/suidmanager_spec.rb +6 -51
  209. data/spec/unit/util_spec.rb +82 -24
  210. data/test/lib/puppettest/certificates.rb +16 -0
  211. data/test/lib/puppettest/servertest.rb +4 -0
  212. data/test/util/pidlock.rb +125 -0
  213. metadata +23 -14
  214. data/ext/puppetstoredconfigclean.rb +0 -103
  215. data/lib/puppet/agent/disabler.rb +0 -27
  216. data/lib/puppet/util/anonymous_filelock.rb +0 -36
  217. data/spec/unit/agent/disabler_spec.rb +0 -60
  218. data/spec/unit/module_tool/repository_spec.rb +0 -52
  219. data/spec/unit/util/anonymous_filelock_spec.rb +0 -78
  220. data/spec/unit/util/pidlock_spec.rb +0 -208
@@ -3,19 +3,20 @@ class Puppet::Parser::Relationship
3
3
 
4
4
  PARAM_MAP = {:relationship => :before, :subscription => :notify}
5
5
 
6
- def evaluate(catalog)
7
- if source.is_a?(Puppet::Parser::Collector)
8
- sources = source.collected.values
9
- else
10
- sources = [source]
11
- end
12
- if target.is_a?(Puppet::Parser::Collector)
13
- targets = target.collected.values
6
+ def arrayify(resources)
7
+ case resources
8
+ when Puppet::Parser::Collector
9
+ resources.collected.values
10
+ when Array
11
+ resources
14
12
  else
15
- targets = [target]
13
+ [resources]
16
14
  end
17
- sources.each do |s|
18
- targets.each do |t|
15
+ end
16
+
17
+ def evaluate(catalog)
18
+ arrayify(source).each do |s|
19
+ arrayify(target).each do |t|
19
20
  mk_relationship(s, t, catalog)
20
21
  end
21
22
  end
@@ -30,14 +31,30 @@ class Puppet::Parser::Relationship
30
31
  end
31
32
 
32
33
  def mk_relationship(source, target, catalog)
33
- unless source_resource = catalog.resource(source.to_s)
34
+ # REVISIT: In Ruby 1.8 we applied `to_s` to source and target, rather than
35
+ # `join` without an argument. In 1.9 the behaviour of Array#to_s changed,
36
+ # and it gives a different representation than just concat the stringified
37
+ # elements.
38
+ #
39
+ # This restores the behaviour, but doesn't address the underlying question
40
+ # of what would happen when more than one item was passed in that array.
41
+ # (Hint: this will not end well.)
42
+ #
43
+ # See http://projects.puppetlabs.com/issues/12076 for the ticket tracking
44
+ # the fact that we should dig out the sane version of this behaviour, then
45
+ # implement it - where we don't risk breaking a stable release series.
46
+ # --daniel 2012-01-21
47
+ source = source.is_a?(Array) ? source.join : source.to_s
48
+ target = target.is_a?(Array) ? target.join : target.to_s
49
+
50
+ unless source_resource = catalog.resource(source)
34
51
  raise ArgumentError, "Could not find resource '#{source}' for relationship on '#{target}'"
35
52
  end
36
- unless target_resource = catalog.resource(target.to_s)
53
+ unless target_resource = catalog.resource(target)
37
54
  raise ArgumentError, "Could not find resource '#{target}' for relationship from '#{source}'"
38
55
  end
39
- Puppet.debug "Adding relationship from #{source.to_s} to #{target.to_s} with '#{param_name}'"
56
+ Puppet.debug "Adding relationship from #{source} to #{target} with '#{param_name}'"
40
57
  source_resource[param_name] ||= []
41
- source_resource[param_name] << target.to_s
58
+ source_resource[param_name] << target
42
59
  end
43
60
  end
@@ -83,7 +83,6 @@ class Puppet::Parser::Resource < Puppet::Resource
83
83
  if klass = resource_type and ! builtin_type?
84
84
  finish
85
85
  evaluated_code = klass.evaluate_code(self)
86
- add_edge_to_stage
87
86
 
88
87
  return evaluated_code
89
88
  elsif builtin?
@@ -80,8 +80,7 @@ class Puppet::Parser::TypeLoader
80
80
 
81
81
  loaded_asts = []
82
82
  files.each do |file|
83
- regex = Puppet.features.microsoft_windows? ? /^[A-Za-z]:#{File::SEPARATOR}/ : /^#{File::SEPARATOR}/
84
- unless file =~ regex
83
+ unless Puppet::Util.absolute_path?(file)
85
84
  file = File.join(dir, file)
86
85
  end
87
86
  @loading_helper.do_once(file) do
@@ -285,10 +285,10 @@ Puppet::Type.type(:augeas).provide(:augeas) do
285
285
 
286
286
  unless force
287
287
  # If we have a verison of augeas which is at least 0.3.6 then we
288
- # can make the changes now, see if changes were made, and
289
- # actually do the save.
288
+ # can make the changes now and see if changes were made.
290
289
  if return_value and versioncmp(get_augeas_version, "0.3.6") >= 0
291
290
  debug("Will attempt to save and only run if files changed")
291
+ # Execute in NEWFILE mode so we can show a diff
292
292
  set_augeas_save_mode(SAVE_NEWFILE)
293
293
  do_execute_changes
294
294
  save_result = @aug.save
@@ -298,13 +298,11 @@ Puppet::Type.type(:augeas).provide(:augeas) do
298
298
  if saved_files.size > 0
299
299
  root = resource[:root].sub(/^\/$/, "")
300
300
  saved_files.each do |key|
301
- saved_file = @aug.get(key).to_s.sub(/^\/files/, root)
301
+ saved_file = @aug.get(key).sub(/^\/files/, root)
302
302
  if Puppet[:show_diff]
303
303
  notice "\n" + diff(saved_file, saved_file + ".augnew")
304
304
  end
305
- if resource.noop?
306
- File.delete(saved_file + ".augnew")
307
- end
305
+ File.delete(saved_file + ".augnew")
308
306
  end
309
307
  debug("Files changed, should execute")
310
308
  return_value = true
@@ -323,32 +321,22 @@ Puppet::Type.type(:augeas).provide(:augeas) do
323
321
  end
324
322
 
325
323
  def execute_changes
326
- # Re-connect to augeas, and re-execute the changes
327
- begin
328
- open_augeas
329
- saved_files = @aug.match("/augeas/events/saved")
330
- unless saved_files.empty?
331
- saved_files.each do |key|
332
- root = resource[:root].sub(/^\/$/, "")
333
- saved_file = @aug.get(key).to_s.sub(/^\/files/, root)
334
- if File.exists?(saved_file + ".augnew")
335
- success = File.rename(saved_file + ".augnew", saved_file)
336
- debug(saved_file + ".augnew moved to " + saved_file)
337
- fail("Rename failed with return code #{success}") if success != 0
338
- end
339
- end
340
- else
341
- debug("No saved files, re-executing augeas")
342
- set_augeas_save_mode(SAVE_OVERWRITE) if versioncmp(get_augeas_version, "0.3.6") >= 0
343
- do_execute_changes
344
- success = @aug.save
345
- fail("Save failed with return code #{success}") if success != true
346
- end
347
- ensure
348
- close_augeas
324
+ # Workaround Augeas bug where changing the save mode doesn't trigger a
325
+ # reload of the previously saved file(s) when we call Augeas#load
326
+ @aug.match("/augeas/events/saved").each do |file|
327
+ @aug.rm("/augeas#{@aug.get(file)}/mtime")
349
328
  end
350
329
 
330
+ # Reload augeas, and execute the changes for real
331
+ set_augeas_save_mode(SAVE_OVERWRITE) if versioncmp(get_augeas_version, "0.3.6") >= 0
332
+ @aug.load
333
+ do_execute_changes
334
+ success = @aug.save
335
+ fail("Save failed with return code #{success}") if success != true
336
+
351
337
  :executed
338
+ ensure
339
+ close_augeas
352
340
  end
353
341
 
354
342
  # Actually execute the augeas changes.
@@ -6,9 +6,31 @@ Puppet::Type.type(:exec).provide :windows, :parent => Puppet::Provider::Exec do
6
6
  confine :operatingsystem => :windows
7
7
  defaultfor :operatingsystem => :windows
8
8
 
9
- desc "Execute external binaries directly, on Windows systems.
10
- This does not pass through a shell, or perform any interpolation, but
11
- only directly calls the command with the arguments given."
9
+ desc <<-EOT
10
+ Execute external binaries on Windows systems. As with the `posix`
11
+ provider, this provider directly calls the command with the arguments
12
+ given, without passing it through a shell or performing any interpolation.
13
+ To use shell built-ins --- that is, to emulate the `shell` provider on
14
+ Windows --- a command must explicitly invoke the shell:
15
+
16
+ exec {'echo foo':
17
+ command => 'cmd.exe /c echo "foo"',
18
+ }
19
+
20
+ If no extension is specified for a command, Windows will use the `PATHEXT`
21
+ environment variable to locate the executable.
22
+
23
+ **Note on PowerShell scripts:** PowerShell's default `restricted`
24
+ execution policy doesn't allow it to run saved scripts. To run PowerShell
25
+ scripts, specify the `remotesigned` execution policy as part of the
26
+ command:
27
+
28
+ exec { 'test':
29
+ path => 'C:/Windows/System32/WindowsPowerShell/v1.0',
30
+ command => 'powershell -executionpolicy remotesigned -file C:/test.ps1',
31
+ }
32
+
33
+ EOT
12
34
 
13
35
  # Verify that we have the executable
14
36
  def checkexe(command)
@@ -1,5 +1,5 @@
1
1
  Puppet::Type.type(:file).provide :posix do
2
- desc "Uses POSIX functionality to manage file's users and rights."
2
+ desc "Uses POSIX functionality to manage file ownership and permissions."
3
3
 
4
4
  confine :feature => :posix
5
5
 
@@ -1,5 +1,5 @@
1
1
  Puppet::Type.type(:file).provide :windows do
2
- desc "Uses Microsoft Windows functionality to manage file's users and rights."
2
+ desc "Uses Microsoft Windows functionality to manage file ownership and permissions."
3
3
 
4
4
  confine :operatingsystem => :windows
5
5
 
@@ -1,7 +1,7 @@
1
1
  require 'puppet/util/adsi'
2
2
 
3
3
  Puppet::Type.type(:group).provide :windows_adsi do
4
- desc "Group management for Windows"
4
+ desc "Local group management for Windows. Nested groups are not supported."
5
5
 
6
6
  defaultfor :operatingsystem => :windows
7
7
  confine :operatingsystem => :windows
@@ -30,7 +30,7 @@ Puppet::Type.type(:package).provide :aix, :parent => Puppet::Provider::Package d
30
30
 
31
31
  updates = {}
32
32
  sources.each do |source|
33
- execute(self.srclistcmd(source)).each do |line|
33
+ execute(self.srclistcmd(source)).each_line do |line|
34
34
  if line =~ /^[^#][^:]*:([^:]*):([^:]*)/
35
35
  current = {}
36
36
  current[:name] = $1
@@ -58,7 +58,7 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Packag
58
58
  if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source
59
59
  cached_source = "/tmp/#{name}"
60
60
  begin
61
- curl "-o", cached_source, "-C", "-", "-k", "-s", "--url", source
61
+ curl "-o", cached_source, "-C", "-", "-k", "-L", "-s", "--url", source
62
62
  Puppet.debug "Success: curl transfered [#{name}]"
63
63
  rescue Puppet::ExecutionFailure
64
64
  Puppet.debug "curl did not transfer [#{name}]. Falling back to slower open-uri transfer methods."
@@ -24,7 +24,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
24
24
  hash = {}
25
25
 
26
26
  # now turn each returned line into a package object
27
- process.each { |line|
27
+ process.each_line { |line|
28
28
  if hash = parse_line(line)
29
29
  packages << new(hash)
30
30
  end
@@ -12,33 +12,26 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
12
12
 
13
13
  commands :gemcmd => "gem"
14
14
 
15
- def self.gemlist(hash)
16
- command = [command(:gemcmd), "list"]
15
+ def self.gemlist(options)
16
+ gem_list_command = [command(:gemcmd), "list"]
17
17
 
18
- if hash[:local]
19
- command << "--local"
18
+ if options[:local]
19
+ gem_list_command << "--local"
20
20
  else
21
- command << "--remote"
21
+ gem_list_command << "--remote"
22
22
  end
23
23
 
24
- if name = hash[:justme]
25
- command << name + "$"
24
+ if name = options[:justme]
25
+ gem_list_command << name + "$"
26
26
  end
27
27
 
28
28
  begin
29
- list = execute(command).split("\n").collect do |set|
30
- if gemhash = gemsplit(set)
31
- gemhash[:provider] = :gem
32
- gemhash
33
- else
34
- nil
35
- end
36
- end.compact
29
+ list = execute(gem_list_command).lines.map {|set| gemsplit(set) }
37
30
  rescue Puppet::ExecutionFailure => detail
38
31
  raise Puppet::Error, "Could not list gems: #{detail}"
39
32
  end
40
33
 
41
- if hash[:justme]
34
+ if options[:justme]
42
35
  return list.shift
43
36
  else
44
37
  return list
@@ -46,14 +39,19 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
46
39
  end
47
40
 
48
41
  def self.gemsplit(desc)
49
- case desc
50
- when /^\*\*\*/, /^\s*$/, /^\s+/; return nil
51
- when /^(\S+)\s+\((.+)\)/
42
+ # `gem list` when output console has a line like:
43
+ # *** LOCAL GEMS ***
44
+ # but when it's not to the console that line
45
+ # and all blank lines are stripped
46
+ # so we don't need to check for them
47
+
48
+ if desc =~ /^(\S+)\s+\((.+)\)/
52
49
  name = $1
53
- version = $2.split(/,\s*/)[0]
54
- return {
55
- :name => name,
56
- :ensure => version
50
+ versions = $2.split(/,\s*/)
51
+ {
52
+ :name => name,
53
+ :ensure => versions,
54
+ :provider => :gem
57
55
  }
58
56
  else
59
57
  Puppet.warning "Could not match #{desc}"
@@ -46,7 +46,7 @@ Puppet::Type.type(:package).provide :macports, :parent => Puppet::Provider::Pack
46
46
 
47
47
  def self.instances
48
48
  packages = []
49
- port("-q", :installed).each do |line|
49
+ port("-q", :installed).each_line do |line|
50
50
  if hash = parse_installed_query_line(line)
51
51
  packages << new(hash)
52
52
  end
@@ -1,7 +1,13 @@
1
1
  require 'puppet/provider/package'
2
2
 
3
3
  Puppet::Type.type(:package).provide(:msi, :parent => Puppet::Provider::Package) do
4
- desc "Package management by installing and removing MSIs."
4
+ desc "Windows package management by installing and removing MSIs.
5
+
6
+ This provider requires a `source` attribute, and will accept paths to local
7
+ files or files on mapped drives.
8
+
9
+ This provider cannot uninstall arbitrary MSI packages; it can only uninstall
10
+ packages which were originally installed by Puppet."
5
11
 
6
12
  confine :operatingsystem => :windows
7
13
  defaultfor :operatingsystem => :windows
@@ -22,7 +22,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
22
22
  hash = {}
23
23
 
24
24
  # now turn each returned line into a package object
25
- process.each { |line|
25
+ process.each_line { |line|
26
26
  if match = regex.match(line.split[0])
27
27
  fields.zip(match.captures) { |field,value|
28
28
  hash[field] = value
@@ -49,7 +49,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
49
49
  end
50
50
 
51
51
  def self.listcmd
52
- [command(:pkginfo), " -a"]
52
+ [command(:pkginfo), "-a"]
53
53
  end
54
54
 
55
55
  def install
@@ -57,28 +57,29 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
57
57
 
58
58
  unless @resource[:source]
59
59
  raise Puppet::Error,
60
- "You must specify a package source for BSD packages"
60
+ "You must specify a package source for BSD packages"
61
61
  end
62
62
 
63
- if @resource[:source][-1,1] == ::File::PATH_SEPARATOR
64
- e_vars = { :PKG_PATH => @resource[:source] }
65
- full_name = [ @resource[:name], get_version || @resource[:ensure], @resource[:flavor] ].join('-').chomp('-')
63
+ if @resource[:source][-1,1] == ::File::SEPARATOR
64
+ e_vars = { 'PKG_PATH' => @resource[:source] }
65
+ full_name = [ @resource[:name], get_version || @resource[:ensure], @resource[:flavor] ].join('-').chomp('-').chomp('-')
66
66
  else
67
67
  e_vars = {}
68
68
  full_name = @resource[:source]
69
69
  end
70
70
 
71
- Puppet::Util::Execution::withenv(e_vars) { pkgadd full_name }
71
+ Puppet::Util::Execution::withenv(e_vars) { pkgadd full_name }
72
72
  end
73
73
 
74
74
  def get_version
75
- execpipe([command(:pkginfo), " -I ", @resource[:name]]) do |process|
75
+ execpipe([command(:pkginfo), "-I", @resource[:name]]) do |process|
76
76
  # our regex for matching pkg_info output
77
77
  regex = /^(.*)-(\d[^-]*)[-]?(\D*)(.*)$/
78
78
  fields = [ :name, :version, :flavor ]
79
79
  master_version = 0
80
+ version = -1
80
81
 
81
- process.each do |line|
82
+ process.each_line do |line|
82
83
  if match = regex.match(line.split[0])
83
84
  # now we return the first version, unless ensure is latest
84
85
  version = match.captures[1]
@@ -89,6 +90,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
89
90
  end
90
91
 
91
92
  return master_version unless master_version == 0
93
+ return '' if version == -1
92
94
  raise Puppet::Error, "#{version} is not available for this package"
93
95
  end
94
96
  rescue Puppet::ExecutionFailure
@@ -96,17 +98,12 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
96
98
  end
97
99
 
98
100
  def query
99
- hash = {}
100
- info = pkginfo @resource[:name]
101
-
102
101
  # Search for the version info
103
- if info =~ /Information for (inst:)?#{@resource[:name]}-(\S+)/
104
- hash[:ensure] = $2
102
+ if pkginfo(@resource[:name]) =~ /Information for (inst:)?#{@resource[:name]}-(\S+)/
103
+ return { :ensure => $2 }
105
104
  else
106
105
  return nil
107
106
  end
108
-
109
- hash
110
107
  end
111
108
 
112
109
  def uninstall
@@ -20,7 +20,7 @@ Puppet::Type.type(:package).provide :pacman, :parent => Puppet::Provider::Packag
20
20
  end
21
21
 
22
22
  def self.listcmd
23
- [command(:pacman), " -Q"]
23
+ [command(:pacman), "-Q"]
24
24
  end
25
25
 
26
26
  # Fetch the list of packages currently installed on the system.
@@ -50,8 +50,11 @@ Puppet::Type.type(:package).provide :pip,
50
50
  def latest
51
51
  client = XMLRPC::Client.new2("http://pypi.python.org/pypi")
52
52
  client.http_header_extra = {"Content-Type" => "text/xml"}
53
+ client.timeout = 10
53
54
  result = client.call("package_releases", @resource[:name])
54
55
  result.first
56
+ rescue Timeout::Error => detail
57
+ raise Puppet::Error, "Timeout while contacting pypi.python.org: #{detail}";
55
58
  end
56
59
 
57
60
  # Install a package. The ensure parameter may specify installed,