puppet 6.0.9-universal-darwin → 6.0.10-universal-darwin

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +16 -16
  3. data/lib/hiera/scope.rb +7 -0
  4. data/lib/puppet.rb +1 -1
  5. data/lib/puppet/application/device.rb +13 -3
  6. data/lib/puppet/application/ssl.rb +2 -0
  7. data/lib/puppet/configurer.rb +1 -1
  8. data/lib/puppet/network/http/connection.rb +2 -0
  9. data/lib/puppet/network/http/factory.rb +5 -0
  10. data/lib/puppet/pops/types/types.rb +5 -3
  11. data/lib/puppet/provider.rb +1 -2
  12. data/lib/puppet/provider/package.rb +2 -0
  13. data/lib/puppet/provider/package/dpkg.rb +15 -2
  14. data/lib/puppet/provider/package/gem.rb +65 -29
  15. data/lib/puppet/provider/package/pip.rb +135 -111
  16. data/lib/puppet/provider/package/pip3.rb +1 -1
  17. data/lib/puppet/provider/package/puppet_gem.rb +1 -1
  18. data/lib/puppet/provider/package/rpm.rb +27 -16
  19. data/lib/puppet/provider/package/yum.rb +2 -1
  20. data/lib/puppet/provider/package_targetable.rb +68 -0
  21. data/lib/puppet/provider/service/upstart.rb +5 -3
  22. data/lib/puppet/provider/user/useradd.rb +16 -13
  23. data/lib/puppet/settings/server_list_setting.rb +9 -0
  24. data/lib/puppet/ssl/host.rb +0 -11
  25. data/lib/puppet/ssl/validator/default_validator.rb +31 -0
  26. data/lib/puppet/type/package.rb +46 -9
  27. data/lib/puppet/util/pidlock.rb +3 -2
  28. data/lib/puppet/util/windows/process.rb +8 -8
  29. data/lib/puppet/util/windows/registry.rb +7 -1
  30. data/lib/puppet/util/windows/user.rb +14 -4
  31. data/lib/puppet/version.rb +1 -1
  32. data/locales/puppet.pot +83 -79
  33. data/man/man5/puppet.conf.5 +2 -2
  34. data/man/man8/puppet-agent.8 +1 -1
  35. data/man/man8/puppet-apply.8 +1 -1
  36. data/man/man8/puppet-catalog.8 +1 -1
  37. data/man/man8/puppet-config.8 +1 -1
  38. data/man/man8/puppet-describe.8 +1 -1
  39. data/man/man8/puppet-device.8 +1 -1
  40. data/man/man8/puppet-doc.8 +1 -1
  41. data/man/man8/puppet-epp.8 +1 -1
  42. data/man/man8/puppet-facts.8 +1 -1
  43. data/man/man8/puppet-filebucket.8 +1 -1
  44. data/man/man8/puppet-generate.8 +1 -1
  45. data/man/man8/puppet-help.8 +1 -1
  46. data/man/man8/puppet-key.8 +1 -1
  47. data/man/man8/puppet-lookup.8 +1 -1
  48. data/man/man8/puppet-man.8 +1 -1
  49. data/man/man8/puppet-module.8 +1 -1
  50. data/man/man8/puppet-node.8 +1 -1
  51. data/man/man8/puppet-parser.8 +1 -1
  52. data/man/man8/puppet-plugin.8 +1 -1
  53. data/man/man8/puppet-report.8 +1 -1
  54. data/man/man8/puppet-resource.8 +1 -1
  55. data/man/man8/puppet-script.8 +1 -1
  56. data/man/man8/puppet-ssl.8 +1 -1
  57. data/man/man8/puppet-status.8 +1 -1
  58. data/man/man8/puppet.8 +2 -2
  59. data/spec/integration/network/http_pool_spec.rb +120 -0
  60. data/spec/integration/type/package_spec.rb +1 -1
  61. data/spec/integration/util/windows/registry_spec.rb +52 -0
  62. data/spec/integration/util/windows/user_spec.rb +19 -0
  63. data/spec/lib/puppet_spec/https.rb +166 -0
  64. data/spec/unit/application/ssl_spec.rb +5 -0
  65. data/spec/unit/configurer_spec.rb +1 -1
  66. data/spec/unit/functions/new_spec.rb +15 -0
  67. data/spec/unit/hiera/scope_spec.rb +7 -0
  68. data/spec/unit/indirector/resource/ral_spec.rb +1 -0
  69. data/spec/unit/network/http/connection_spec.rb +0 -96
  70. data/spec/unit/network/http/factory_spec.rb +6 -0
  71. data/spec/unit/provider/package/dpkg_spec.rb +18 -1
  72. data/spec/unit/provider/package/gem_spec.rb +101 -48
  73. data/spec/unit/provider/package/pip3_spec.rb +17 -0
  74. data/spec/unit/provider/package/pip_spec.rb +57 -67
  75. data/spec/unit/provider/package/puppet_gem_spec.rb +22 -6
  76. data/spec/unit/provider/package/rpm_spec.rb +116 -27
  77. data/spec/unit/provider/service/upstart_spec.rb +3 -22
  78. data/spec/unit/settings/server_list_setting_spec.rb +21 -0
  79. data/spec/unit/ssl/validator_spec.rb +2 -0
  80. data/spec/unit/util/pidlock_spec.rb +26 -0
  81. metadata +9 -5
  82. data/lib/puppet/rest/client.rb +0 -83
  83. data/spec/unit/rest/client_spec.rb +0 -166
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56311e7c3b86537855856cdcd951720adc0b203387220e1d29a4fb776781e64d
4
- data.tar.gz: a16455b4b97ea1813ad0eb8058d9589d3f0264754d7cd92e4dface878a798d2e
3
+ metadata.gz: 111ad96fa546f882e7348e48d345ddd74e360de2efeacb112d1066a5f241d5a0
4
+ data.tar.gz: 82f1f290b48c95753aca70853f198927e9b8682c324dd13e7b33f0c3dedbeb56
5
5
  SHA512:
6
- metadata.gz: 05b515f21c3243718c4da990d0b2e29c9eccfecf16d0f38b0b401dbb15cab91775f6b9046578dd49d70fd970c5a0329a93f54a43699de34b5480ae71dae87e38
7
- data.tar.gz: abc105068df6496fb65c24dc508b588afc0f745373fea51b76aeb5e89458b00bc5ea5bd849b0cfa7491210a37dc642d284183003c6f4440b3d211fee81d1aff2
6
+ metadata.gz: 132e8d02c6704483c32afc8a2432b606436b7aac982aa12617bd7f9c107b651fad10471a6a0babc128e1bc56dbe4e4d7e0e44c680780732302e6d4f22574f015
7
+ data.tar.gz: e1e10bb7aa00f8f66c4b4faded757e275ad1dc0bef8304503b12302bb862f37cb557c80031c506f02149fff9bb490958bc88678ebcfb553d166048b932925a7e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puppet (6.0.9)
4
+ puppet (6.0.10)
5
5
  CFPropertyList (~> 2.2)
6
6
  facter (>= 2.4.0, < 4)
7
7
  fast_gettext (~> 1.1.2)
@@ -32,7 +32,7 @@ GEM
32
32
  fast_gettext (~> 1.1.0)
33
33
  gettext (>= 3.0.2)
34
34
  locale
35
- hashdiff (0.3.9)
35
+ hashdiff (0.4.0)
36
36
  hiera (3.5.0)
37
37
  hiera-eyaml (3.0.0)
38
38
  highline (~> 1.6.19)
@@ -44,25 +44,25 @@ GEM
44
44
  json-schema (2.8.1)
45
45
  addressable (>= 2.4)
46
46
  locale (2.1.2)
47
- memory_profiler (0.9.13)
47
+ memory_profiler (0.9.14)
48
48
  method_source (0.9.2)
49
49
  minitar (0.8)
50
- msgpack (1.2.10)
50
+ msgpack (1.3.0)
51
51
  multi_json (1.13.1)
52
52
  mustache (1.1.0)
53
53
  optimist (3.0.0)
54
- packaging (0.99.29)
54
+ packaging (0.99.36)
55
55
  artifactory (~> 2)
56
56
  rake (~> 12.3)
57
57
  parallel (1.17.0)
58
- parser (2.6.2.1)
58
+ parser (2.6.3.0)
59
59
  ast (~> 2.4.0)
60
60
  powerpack (0.1.2)
61
61
  pry (0.12.2)
62
62
  coderay (~> 1.1.0)
63
63
  method_source (~> 0.9.0)
64
- public_suffix (3.0.3)
65
- puppet-resource_api (1.8.1)
64
+ public_suffix (3.1.1)
65
+ puppet-resource_api (1.8.4)
66
66
  hocon (>= 1.0)
67
67
  puppetserver-ca (1.3.1)
68
68
  facter (>= 2.0.1, < 4)
@@ -82,18 +82,18 @@ GEM
82
82
  rspec-mocks (~> 3.8.0)
83
83
  rspec-collection_matchers (1.1.3)
84
84
  rspec-expectations (>= 2.99.0.beta1)
85
- rspec-core (3.8.0)
85
+ rspec-core (3.8.2)
86
86
  rspec-support (~> 3.8.0)
87
- rspec-expectations (3.8.3)
87
+ rspec-expectations (3.8.4)
88
88
  diff-lcs (>= 1.2.0, < 2.0)
89
89
  rspec-support (~> 3.8.0)
90
90
  rspec-its (1.3.0)
91
91
  rspec-core (>= 3.0.0)
92
92
  rspec-expectations (>= 3.0.0)
93
- rspec-mocks (3.8.0)
93
+ rspec-mocks (3.8.1)
94
94
  diff-lcs (>= 1.2.0, < 2.0)
95
95
  rspec-support (~> 3.8.0)
96
- rspec-support (3.8.0)
96
+ rspec-support (3.8.2)
97
97
  rubocop (0.49.1)
98
98
  parallel (~> 1.10)
99
99
  parser (>= 2.3.3.1, < 3.0)
@@ -103,18 +103,18 @@ GEM
103
103
  unicode-display_width (~> 1.0, >= 1.0.1)
104
104
  rubocop-i18n (1.2.0)
105
105
  rubocop (~> 0.49.0)
106
- ruby-prof (0.17.0)
107
- ruby-progressbar (1.10.0)
106
+ ruby-prof (0.18.0)
107
+ ruby-progressbar (1.10.1)
108
108
  safe_yaml (1.0.5)
109
109
  semantic_puppet (1.0.2)
110
110
  text (1.3.1)
111
- unicode-display_width (1.5.0)
111
+ unicode-display_width (1.6.0)
112
112
  vcr (2.9.3)
113
113
  webmock (1.24.6)
114
114
  addressable (>= 2.3.6)
115
115
  crack (>= 0.3.2)
116
116
  hashdiff
117
- yard (0.9.19)
117
+ yard (0.9.20)
118
118
 
119
119
  PLATFORMS
120
120
  ruby
data/lib/hiera/scope.rb CHANGED
@@ -1,5 +1,8 @@
1
+ require 'forwardable'
1
2
  class Hiera
2
3
  class Scope
4
+ extend Forwardable
5
+
3
6
  CALLING_CLASS = 'calling_class'.freeze
4
7
  CALLING_CLASS_PATH = 'calling_class_path'.freeze
5
8
  CALLING_MODULE = 'calling_module'.freeze
@@ -79,5 +82,9 @@ class Hiera
79
82
  end
80
83
  end
81
84
  private :find_hostclass
85
+
86
+ # This is needed for type conversion to work
87
+ def_delegators :@real, :call_function
88
+
82
89
  end
83
90
  end
data/lib/puppet.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'puppet/version'
2
2
 
3
3
  if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new("2.3.0")
4
- raise LoadError, _("Puppet %{version} requires ruby 2.3.0 or greater.") % { version: Puppet.version }
4
+ raise LoadError, "Puppet #{Puppet.version} requires Ruby 2.3.0 or greater, found Ruby #{RUBY_VERSION.dup}."
5
5
  end
6
6
 
7
7
  Puppet::OLDEST_RECOMMENDED_RUBY_VERSION = '2.3.0'
@@ -274,8 +274,18 @@ Licensed under the Apache 2.0 License
274
274
  Puppet.settings.use :main, :agent, :ssl
275
275
 
276
276
  unless options[:resource] || options[:facts] || options[:apply]
277
- # ask for a ssl cert if needed, but at least
278
- # setup the ssl system for this device.
277
+ # Since it's too complicated to fix properly in the default settings, we workaround for PUP-9642 here.
278
+ # See https://github.com/puppetlabs/puppet/pull/7483#issuecomment-483455997 for details.
279
+ # This has to happen after `settings.use` above, so the directory is created and before `setup_host` below, where the SSL
280
+ # routines would fail with access errors
281
+ if Puppet.features.root? && !Puppet::Util::Platform.windows?
282
+ user = Puppet::Type.type(:user).new(name: Puppet[:user]).exists? ? Puppet[:user] : nil
283
+ group = Puppet::Type.type(:group).new(name: Puppet[:group]).exists? ? Puppet[:group] : nil
284
+ Puppet.debug("Fixing perms for #{user}:#{group} on #{Puppet[:confdir]}")
285
+ FileUtils.chown(user, group, Puppet[:confdir]) if user || group
286
+ end
287
+
288
+ # ask for a ssl cert if needed, and setup the ssl system for this device.
279
289
  ssl_host = setup_host(device.name)
280
290
 
281
291
  unless options[:libdir]
@@ -285,7 +295,7 @@ Licensed under the Apache 2.0 License
285
295
  end
286
296
  end
287
297
 
288
- # this init the device singleton, so that the facts terminus
298
+ # this inits the device singleton, so that the facts terminus
289
299
  # and the various network_device provider can use it
290
300
  Puppet::Util::NetworkDevice.init(device)
291
301
 
@@ -98,6 +98,8 @@ HELP
98
98
  Puppet.settings.use(:main, :agent)
99
99
  end
100
100
 
101
+ Puppet::SSL::Oids.register_puppet_oids
102
+
101
103
  action = command_line.args.first
102
104
  case action
103
105
  when 'submit_request'
@@ -227,7 +227,7 @@ class Puppet::Configurer
227
227
  if options[:catalog].nil? && do_failover
228
228
  server, port = find_functional_server
229
229
  if server.nil?
230
- raise Puppet::Error, _("Could not select a functional puppet master from server_list: '%{server_list}'") % { server_list: Puppet[:server_list] }
230
+ raise Puppet::Error, _("Could not select a functional puppet master from server_list: '%{server_list}'") % { server_list: Puppet.settings.value(:server_list, Puppet[:environment].to_sym, true) }
231
231
  else
232
232
  #TRANSLATORS 'server_list' is the name of a setting and should not be translated
233
233
  Puppet.debug _("Selected puppet server from the `server_list` setting: %{server}:%{port}") % { server: server, port: port }
@@ -331,6 +331,8 @@ module Puppet::Network::HTTP
331
331
  end
332
332
  response
333
333
  rescue OpenSSL::SSL::SSLError => error
334
+ raise @verify.last_error if @verify.last_error
335
+
334
336
  Puppet::Util::SSL.handle_connection_error(error, @verify, site.host)
335
337
  end
336
338
  end
@@ -41,6 +41,11 @@ class Puppet::Network::HTTP::Factory
41
41
  http.open_timeout = Puppet[:http_connect_timeout]
42
42
  http.keep_alive_timeout = KEEP_ALIVE_TIMEOUT if http.respond_to?(:keep_alive_timeout=)
43
43
 
44
+ if http.respond_to?(:max_retries)
45
+ # 0 means make one request and never retry
46
+ http.max_retries = 0
47
+ end
48
+
44
49
  if Puppet[:sourceaddress]
45
50
  Puppet.debug("Using source IP #{Puppet[:sourceaddress]}")
46
51
  http.local_host = Puppet[:sourceaddress]
@@ -843,14 +843,16 @@ INTEGER_HEX = '(?:0[xX][0-9A-Fa-f]+)'
843
843
  INTEGER_OCT = '(?:0[0-7]+)'
844
844
  INTEGER_BIN = '(?:0[bB][01]+)'
845
845
  INTEGER_DEC = '(?:0|[1-9]\d*)'
846
+ INTEGER_DEC_OR_OCT = '(?:\d+)'
846
847
  SIGN_PREFIX = '[+-]?\s*'
847
848
 
848
849
  OPTIONAL_FRACTION = '(?:\.\d+)?'
849
850
  OPTIONAL_EXPONENT = '(?:[eE]-?\d+)?'
850
851
  FLOAT_DEC = '(?:' + INTEGER_DEC + OPTIONAL_FRACTION + OPTIONAL_EXPONENT + ')'
851
852
 
852
- INTEGER_PATTERN = '\A' + SIGN_PREFIX + '(?:' + INTEGER_DEC + '|' + INTEGER_HEX + '|' + INTEGER_OCT + '|' + INTEGER_BIN + ')\z'
853
- FLOAT_PATTERN = '\A' + SIGN_PREFIX + '(?:' + FLOAT_DEC + '|' + INTEGER_HEX + '|' + INTEGER_OCT + '|' + INTEGER_BIN + ')\z'
853
+ INTEGER_PATTERN = '\A' + SIGN_PREFIX + '(?:' + INTEGER_DEC + '|' + INTEGER_HEX + '|' + INTEGER_OCT + '|' + INTEGER_BIN + ')\z'
854
+ INTEGER_PATTERN_LENIENT = '\A' + SIGN_PREFIX + '(?:' + INTEGER_DEC_OR_OCT + '|' + INTEGER_HEX + '|' + INTEGER_BIN + ')\z'
855
+ FLOAT_PATTERN = '\A' + SIGN_PREFIX + '(?:' + FLOAT_DEC + '|' + INTEGER_HEX + '|' + INTEGER_OCT + '|' + INTEGER_BIN + ')\z'
854
856
 
855
857
  # @api public
856
858
  #
@@ -1089,7 +1091,7 @@ class PIntegerType < PNumericType
1089
1091
  @@new_function ||= Puppet::Functions.create_loaded_function(:new, loader) do
1090
1092
  local_types do
1091
1093
  type 'Radix = Variant[Default, Integer[2,2], Integer[8,8], Integer[10,10], Integer[16,16]]'
1092
- type "Convertible = Variant[Numeric, Boolean, Pattern[/#{INTEGER_PATTERN}/], Timespan, Timestamp]"
1094
+ type "Convertible = Variant[Numeric, Boolean, Pattern[/#{INTEGER_PATTERN_LENIENT}/], Timespan, Timestamp]"
1093
1095
  type 'NamedArgs = Struct[{from => Convertible, Optional[radix] => Radix, Optional[abs] => Boolean}]'
1094
1096
  end
1095
1097
 
@@ -395,7 +395,7 @@ class Puppet::Provider
395
395
  # @raise [Puppet::DevError] Error indicating that the method should have been implemented by subclass.
396
396
  # @see prefetch
397
397
  def self.instances
398
- raise Puppet::DevError, _("Provider %{provider} has not defined the 'instances' class method") % { provider: self.name }
398
+ raise Puppet::DevError, _("To support listing resources of this type the '%{provider}' provider needs to implement an 'instances' class method returning the current set of resources. We recommend porting your module to the simpler Resource API instead: https://puppet.com/search/docs?keys=resource+api") % { provider: self.name }
399
399
  end
400
400
 
401
401
  # Creates getter- and setter- methods for each property supported by the resource type.
@@ -621,4 +621,3 @@ class Puppet::Provider
621
621
  # @return [void]
622
622
  # @api public
623
623
  end
624
-
@@ -1,3 +1,5 @@
1
+ require 'puppet/provider'
2
+
1
3
  class Puppet::Provider::Package < Puppet::Provider
2
4
  # Prefetch our package list, yo.
3
5
  def self.prefetch(packages)
@@ -81,7 +81,6 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
81
81
  unless file = @resource[:source]
82
82
  raise ArgumentError, _("You cannot install dpkg packages without a source")
83
83
  end
84
-
85
84
  args = []
86
85
 
87
86
  # We always unhold when installing to remove any prior hold.
@@ -146,7 +145,9 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
146
145
  end
147
146
 
148
147
  def hold
149
- self.install
148
+ if package_not_installed?(@resource[:name])
149
+ self.install
150
+ end
150
151
  Tempfile.open('puppet_dpkg_set_selection') do |tmpfile|
151
152
  tmpfile.write("#{@resource[:name]} hold\n")
152
153
  tmpfile.flush
@@ -162,4 +163,16 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
162
163
  end
163
164
  end
164
165
 
166
+ def package_not_installed?(name)
167
+ if !name.nil? && !name.empty?
168
+ begin
169
+ dpkgquery("-W", "--showformat", self.class::DPKG_QUERY_FORMAT_STRING, name)
170
+ rescue Puppet::ExecutionFailure
171
+ # return true if exception is generated because package is not found
172
+ return true
173
+ end
174
+ return false
175
+ end
176
+ raise ArgumentError.new("Package name is nil or empty")
177
+ end
165
178
  end
@@ -1,8 +1,8 @@
1
- require 'puppet/provider/package'
1
+ require 'puppet/provider/package_targetable'
2
2
  require 'uri'
3
3
 
4
4
  # Ruby gems support.
5
- Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package do
5
+ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package::Targetable do
6
6
  desc "Ruby Gem support. If a URL is passed via `source`, then that URL is
7
7
  appended to the list of remote gem repositories; to ensure that only the
8
8
  specified source is used, also pass `--clear-sources` via `install_options`.
@@ -15,9 +15,31 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
15
15
  These options should be specified as a string (e.g. '--flag'), a hash (e.g. {'--flag' => 'value'}),
16
16
  or an array where each element is either a string or a hash."
17
17
 
18
- has_feature :versionable, :install_options, :uninstall_options
18
+ has_feature :versionable, :install_options, :uninstall_options, :targetable
19
19
 
20
- commands :gemcmd => "gem"
20
+ # Override the specificity method to return 1 if gem is not set as default provider
21
+ def self.specificity
22
+ match = default_match
23
+ length = match ? match.length : 0
24
+
25
+ return 1 if length == 0
26
+
27
+ super
28
+ end
29
+
30
+ # Define the default provider package command name when the provider is targetable.
31
+ # Required by Puppet::Provider::Package::Targetable::resource_or_provider_command
32
+
33
+ def self.provider_command
34
+ command(:gemcmd)
35
+ end
36
+
37
+ # Define the default provider package command as optional when the provider is targetable.
38
+ # Doing do defers the evaluation of provider suitability until all commands are evaluated.
39
+
40
+ has_command(:gemcmd, 'gem') do
41
+ is_optional
42
+ end
21
43
 
22
44
  # CommandDefiner in provider.rb creates convenience execution methods that set failonfail, combine, and optionally, environment.
23
45
  # And when a child provider defines its own command via commands() or has_command(), the provider-specific path is always returned by command().
@@ -26,12 +48,29 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
26
48
  #
27
49
  # In this case, causing the puppet_gem provider to inherit the parent gem provider's convenience gemcmd() methods, with the wrong path.
28
50
 
29
- def self.execute_gem_command(command_options)
30
- cmd = [command(:gemcmd)] << command_options
51
+ def self.execute_gem_command(command, command_options)
52
+ validate_command(command)
53
+ cmd = [command] << command_options
31
54
 
32
55
  execute(cmd, {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}})
33
56
  end
34
57
 
58
+ def self.instances(target_command = nil)
59
+ if target_command
60
+ command = target_command
61
+ else
62
+ command = provider_command
63
+ # The default provider package command is optional.
64
+ return [] unless command
65
+ end
66
+
67
+ gemlist(:command => command, :local => true).collect do |pkg|
68
+ # Track the command when the provider is targetable.
69
+ pkg[:command] = command
70
+ new(pkg)
71
+ end
72
+ end
73
+
35
74
  def self.gemlist(options)
36
75
  command_options = ["list"]
37
76
 
@@ -48,7 +87,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
48
87
  end
49
88
 
50
89
  begin
51
- list = execute_gem_command(command_options).lines.
90
+ list = execute_gem_command(options[:command], command_options).lines.
52
91
  map {|set| gemsplit(set) }.
53
92
  reject {|x| x.nil? }
54
93
  rescue Puppet::ExecutionFailure => detail
@@ -83,12 +122,6 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
83
122
  end
84
123
  end
85
124
 
86
- def self.instances(justme = false)
87
- gemlist(:local => true).collect do |hash|
88
- new(hash)
89
- end
90
- end
91
-
92
125
  def insync?(is)
93
126
  return false unless is && is != :absent
94
127
 
@@ -105,13 +138,13 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
105
138
  is.any? { |version| dependency.match?('', version) }
106
139
  end
107
140
 
108
- def rubygem_version
141
+ def rubygem_version(command)
109
142
  command_options = ["--version"]
110
-
111
- self.class.execute_gem_command(command_options)
143
+ self.class.execute_gem_command(command, command_options)
112
144
  end
113
145
 
114
146
  def install(useversion = true)
147
+ command = resource_or_provider_command
115
148
  command_options = ["install"]
116
149
  command_options += install_options if resource[:install_options]
117
150
 
@@ -122,7 +155,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
122
155
  command_options << "-v" << resource[:ensure] if (! resource[:ensure].is_a? Symbol) and useversion
123
156
  end
124
157
 
125
- if Puppet::Util::Package.versioncmp(rubygem_version, '2.0.0') == -1
158
+ if Puppet::Util::Package.versioncmp(rubygem_version(command), '2.0.0') == -1
126
159
  command_options << "--no-rdoc" << "--no-ri"
127
160
  else
128
161
  command_options << "--no-document"
@@ -157,31 +190,34 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
157
190
  command_options << resource[:name]
158
191
  end
159
192
 
160
- output = self.class.execute_gem_command(command_options)
161
- # Apparently some gem versions don't exit non-0 on failure
193
+ output = self.class.execute_gem_command(command, command_options)
194
+ # Apparently some gem versions don't exit non-0 on failure.
162
195
  self.fail _("Could not install: %{output}") % { output: output.chomp } if output.include?("ERROR")
163
196
  end
164
197
 
165
198
  def latest
166
- # This always gets the latest version available.
167
- options = {:justme => resource[:name]}
168
- options.merge!({:source => resource[:source]}) unless resource[:source].nil?
169
- hash = self.class.gemlist(options)
170
-
171
- hash[:ensure][0]
199
+ command = resource_or_provider_command
200
+ options = { :command => command, :justme => resource[:name] }
201
+ options[:source] = resource[:source] unless resource[:source].nil?
202
+ pkg = self.class.gemlist(options)
203
+ pkg[:ensure][0]
172
204
  end
173
205
 
174
206
  def query
175
- self.class.gemlist(:justme => resource[:name], :local => true)
207
+ command = resource_or_provider_command
208
+ options = { :command => command, :justme => resource[:name], :local => true }
209
+ pkg = self.class.gemlist(options)
210
+ pkg[:command] = command unless pkg.nil?
211
+ pkg
176
212
  end
177
213
 
178
214
  def uninstall
215
+ command = resource_or_provider_command
179
216
  command_options = ["uninstall"]
180
217
  command_options << "--executables" << "--all" << resource[:name]
181
218
  command_options += uninstall_options if resource[:uninstall_options]
182
-
183
- output = self.class.execute_gem_command(command_options)
184
- # Apparently some gem versions don't exit non-0 on failure
219
+ output = self.class.execute_gem_command(command, command_options)
220
+ # Apparently some gem versions don't exit non-0 on failure.
185
221
  self.fail _("Could not uninstall: %{output}") % { output: output.chomp } if output.include?("ERROR")
186
222
  end
187
223