puppet 6.0.9-x86-mingw32 → 6.0.10-x86-mingw32

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
@@ -1,11 +1,10 @@
1
1
  # Puppet package provider for Python's `pip` package management frontend.
2
2
  # <http://pip.pypa.io/>
3
3
 
4
- require 'puppet/provider/package'
4
+ require 'puppet/provider/package_targetable'
5
5
  require 'puppet/util/http_proxy'
6
6
 
7
- Puppet::Type.type(:package).provide :pip,
8
- :parent => ::Puppet::Provider::Package do
7
+ Puppet::Type.type(:package).provide :pip, :parent => ::Puppet::Provider::Package::Targetable do
9
8
 
10
9
  desc "Python packages via `pip`.
11
10
 
@@ -13,43 +12,24 @@ Puppet::Type.type(:package).provide :pip,
13
12
  These options should be specified as a string (e.g. '--flag'), a hash (e.g. {'--flag' => 'value'}),
14
13
  or an array where each element is either a string or a hash."
15
14
 
16
- has_feature :installable, :uninstallable, :upgradeable, :versionable, :install_options
15
+ has_feature :installable, :uninstallable, :upgradeable, :versionable, :install_options, :targetable
17
16
 
18
- # Parse lines of output from `pip freeze`, which are structured as
19
- # _package_==_version_.
20
- def self.parse(line)
21
- if line.chomp =~ /^([^=]+)==([^=]+)$/
22
- {:ensure => $2, :name => $1, :provider => name}
23
- else
24
- nil
25
- end
26
- end
17
+ # Override the specificity method to return 1 if pip is not set as default provider
18
+ def self.specificity
19
+ match = default_match
20
+ length = match ? match.length : 0
27
21
 
28
- # Return an array of structured information about every installed package
29
- # that's managed by `pip` or an empty array if `pip` is not available.
30
- def self.instances
31
- packages = []
32
- pip_cmd = self.pip_cmd
33
- return [] unless pip_cmd
34
- command = [pip_cmd, 'freeze']
35
- if Puppet::Util::Package.versioncmp(self.pip_version, '8.1.0') >= 0 # a >= b
36
- command << '--all'
37
- end
38
- execpipe command do |process|
39
- process.collect do |line|
40
- next unless options = parse(line)
41
- packages << new(options)
42
- end
43
- end
22
+ return 1 if length == 0
44
23
 
45
- # Pip can also upgrade pip, but it's not listed in freeze so need to special case it
46
- # Pip list would also show pip installed version, but "pip list" doesn't exist for older versions of pip (E.G v1.0)
47
- # Not needed when "pip freeze --all" is available
48
- if Puppet::Util::Package.versioncmp(self.pip_version, '8.1.0') == -1 && version = self.pip_version
49
- packages << new({:ensure => version, :name => File.basename(pip_cmd), :provider => name})
50
- end
24
+ super
25
+ end
51
26
 
52
- packages
27
+ # Define the default provider package command name when the provider is targetable.
28
+ # Required by Puppet::Provider::Package::Targetable::resource_or_provider_command
29
+
30
+ def self.provider_command
31
+ # Ensure pip can upgrade pip, which usually puts pip into a new path /usr/local/bin/pip (compared to /usr/bin/pip)
32
+ self.cmd.map { |c| which(c) }.find { |c| c != nil }
53
33
  end
54
34
 
55
35
  def self.cmd
@@ -60,104 +40,94 @@ Puppet::Type.type(:package).provide :pip,
60
40
  end
61
41
  end
62
42
 
63
- def self.pip_cmd
64
- self.cmd.map { |c| which(c) }.find { |c| c != nil }
65
- end
66
-
67
- def self.pip_version
68
- pip_cmd = self.pip_cmd
69
- return nil unless pip_cmd
70
-
71
- execpipe [pip_cmd, '--version'] do |process|
43
+ def self.pip_version(command)
44
+ execpipe [command, '--version'] do |process|
72
45
  process.collect do |line|
73
46
  return line.strip.match(/^pip (\d+\.\d+\.?\d*).*$/)[1]
74
47
  end
75
48
  end
76
49
  end
77
50
 
78
- # Return structured information about a particular package or `nil` if
79
- # it is not installed or `pip` itself is not available.
80
- def query
81
- self.class.instances.each do |provider_pip|
82
- return provider_pip.properties if @resource[:name].downcase == provider_pip.name.downcase
51
+ # Return an array of structured information about every installed package
52
+ # that's managed by `pip` or an empty array if `pip` is not available.
53
+
54
+ def self.instances(target_command = nil)
55
+ if target_command
56
+ command = target_command
57
+ self.validate_command(command)
58
+ else
59
+ command = provider_command
83
60
  end
84
- return nil
85
- end
86
61
 
87
- # Use pip CLI to look up versions from PyPI repositories, honoring local pip config such as custom repositories
88
- def latest
89
- return nil unless self.class.pip_cmd
90
- if Puppet::Util::Package.versioncmp(self.class.pip_version, '1.5.4') == -1 # a < b
91
- return latest_with_old_pip
62
+ packages = []
63
+ return packages unless command
64
+
65
+ command_options = ['freeze']
66
+ command_version = self.pip_version(command)
67
+ if Puppet::Util::Package.versioncmp(command_version, '8.1.0') >= 0
68
+ command_options << '--all'
92
69
  end
93
- latest_with_new_pip
94
- end
95
70
 
96
- # Install a package. The ensure parameter may specify installed,
97
- # latest, a version number, or, in conjunction with the source
98
- # parameter, an SCM revision. In that case, the source parameter
99
- # gives the fully-qualified URL to the repository.
100
- def install
101
- args = %w{install -q}
102
- args += install_options if @resource[:install_options]
103
- if @resource[:source]
104
- if String === @resource[:ensure]
105
- args << "#{@resource[:source]}@#{@resource[:ensure]}#egg=#{
106
- @resource[:name]}"
107
- else
108
- args << "#{@resource[:source]}#egg=#{@resource[:name]}"
109
- end
110
- else
111
- case @resource[:ensure]
112
- when String
113
- args << "#{@resource[:name]}==#{@resource[:ensure]}"
114
- when :latest
115
- args << "--upgrade" << @resource[:name]
116
- else
117
- args << @resource[:name]
71
+ execpipe [command, command_options] do |process|
72
+ process.collect do |line|
73
+ next unless pkg = parse(line)
74
+ pkg[:command] = command
75
+ packages << new(pkg)
118
76
  end
119
77
  end
120
- lazy_pip(*args)
121
- end
122
78
 
123
- # Uninstall a package. Uninstall won't work reliably on Debian/Ubuntu
124
- # unless this issue gets fixed.
125
- # <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=562544>
126
- def uninstall
127
- lazy_pip "uninstall", "-y", "-q", @resource[:name]
79
+ # Pip can also upgrade pip, but it's not listed in freeze so need to special case it
80
+ # Pip list would also show pip installed version, but "pip list" doesn't exist for older versions of pip (E.G v1.0)
81
+ # Not needed when "pip freeze --all" is available.
82
+ if Puppet::Util::Package.versioncmp(command_version, '8.1.0') == -1
83
+ packages << new({:ensure => command_version, :name => File.basename(command), :provider => name, :command => command})
84
+ end
85
+
86
+ packages
128
87
  end
129
88
 
130
- def update
131
- install
89
+ # Parse lines of output from `pip freeze`, which are structured as:
90
+ # _package_==_version_
91
+ def self.parse(line)
92
+ if line.chomp =~ /^([^=]+)==([^=]+)$/
93
+ {:ensure => $2, :name => $1, :provider => name}
94
+ end
132
95
  end
133
96
 
134
- # Execute a `pip` command. If Puppet doesn't yet know how to do so,
135
- # try to teach it and if even that fails, raise the error.
136
- private
137
- def lazy_pip(*args)
138
- pip(*args)
139
- rescue NoMethodError => e
140
- # Ensure pip can upgrade pip, which usually puts pip into a new path /usr/local/bin/pip (compared to /usr/bin/pip)
141
- # The path to pip needs to be looked up again in the subsequent request. Using the preferred approach as noted
142
- # in provider.rb ensures this (copied below for reference)
143
- #
144
- # @note From provider.rb; It is preferred if the commands are not entered with absolute paths as this allows puppet
145
- # to search for them using the PATH variable.
146
- if pathname = self.class.cmd.map { |c| which(c) }.find { |c| c != nil }
147
- self.class.commands :pip => File.basename(pathname)
148
- pip(*args)
149
- else
150
- raise e, "Could not locate command #{self.class.cmd.join(' and ')}.", e.backtrace
97
+ # Return structured information about a particular package or `nil`
98
+ # if the package is not installed or `pip` itself is not available.
99
+
100
+ def query
101
+ command = resource_or_provider_command
102
+ self.class.validate_command(command)
103
+
104
+ self.class.instances(command).each do |pkg|
105
+ return pkg.properties if @resource[:name].downcase == pkg.name.downcase
151
106
  end
107
+ return nil
152
108
  end
153
109
 
154
- def install_options
155
- join_options(@resource[:install_options])
110
+ # Use pip CLI to look up versions from PyPI repositories,
111
+ # honoring local pip config such as custom repositories.
112
+
113
+ def latest
114
+ command = resource_or_provider_command
115
+ self.class.validate_command(command)
116
+
117
+ command_version = self.class.pip_version(command)
118
+ if Puppet::Util::Package.versioncmp(command_version, '1.5.4') == -1
119
+ latest_with_old_pip
120
+ else
121
+ latest_with_new_pip
122
+ end
156
123
  end
157
124
 
158
125
  def latest_with_new_pip
126
+ command = resource_or_provider_command
127
+ self.class.validate_command(command)
128
+
159
129
  # Less resource intensive approach for pip version 1.5.4 and above
160
- execpipe ["#{self.class.pip_cmd}", "install", "#{@resource[:name]}==versionplease"] do |process|
130
+ execpipe [command, "install", "#{@resource[:name]}==versionplease"] do |process|
161
131
  process.collect do |line|
162
132
  # PIP OUTPUT: Could not find a version that satisfies the requirement Django==versionplease (from versions: 1.1.3, 1.8rc1)
163
133
  if line =~ /from versions: /
@@ -173,8 +143,11 @@ Puppet::Type.type(:package).provide :pip,
173
143
  end
174
144
 
175
145
  def latest_with_old_pip
146
+ command = resource_or_provider_command
147
+ self.class.validate_command(command)
148
+
176
149
  Dir.mktmpdir("puppet_pip") do |dir|
177
- execpipe ["#{self.class.pip_cmd}", "install", "#{@resource[:name]}", "-d", "#{dir}", "-v"] do |process|
150
+ execpipe [command, "install", "#{@resource[:name]}", "-d", "#{dir}", "-v"] do |process|
178
151
  process.collect do |line|
179
152
  # PIP OUTPUT: Using version 0.10.1 (newest of versions: 0.10.1, 0.10, 0.9, 0.8.1, 0.8, 0.7.2, 0.7.1, 0.7, 0.6.1, 0.6, 0.5.2, 0.5.1, 0.5, 0.4, 0.3.1, 0.3, 0.2, 0.1)
180
153
  if line =~ /Using version (.+?) \(newest of versions/
@@ -185,4 +158,55 @@ Puppet::Type.type(:package).provide :pip,
185
158
  end
186
159
  end
187
160
  end
161
+
162
+ # Install a package. The ensure parameter may specify installed,
163
+ # latest, a version number, or, in conjunction with the source
164
+ # parameter, an SCM revision. In that case, the source parameter
165
+ # gives the fully-qualified URL to the repository.
166
+
167
+ def install
168
+ command = resource_or_provider_command
169
+ self.class.validate_command(command)
170
+
171
+ command_options = %w{install -q}
172
+ command_options += install_options if @resource[:install_options]
173
+ if @resource[:source]
174
+ if String === @resource[:ensure]
175
+ command_options << "#{@resource[:source]}@#{@resource[:ensure]}#egg=#{@resource[:name]}"
176
+ else
177
+ command_options << "#{@resource[:source]}#egg=#{@resource[:name]}"
178
+ end
179
+ else
180
+ case @resource[:ensure]
181
+ when String
182
+ command_options << "#{@resource[:name]}==#{@resource[:ensure]}"
183
+ when :latest
184
+ command_options << "--upgrade" << @resource[:name]
185
+ else
186
+ command_options << @resource[:name]
187
+ end
188
+ end
189
+
190
+ execute([command, command_options])
191
+ end
192
+
193
+ # Uninstall a package. Uninstall won't work reliably on Debian/Ubuntu unless this issue gets fixed.
194
+ # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=562544
195
+
196
+ def uninstall
197
+ command = resource_or_provider_command
198
+ self.class.validate_command(command)
199
+
200
+ command_options = ["uninstall", "-y", "-q", @resource[:name]]
201
+
202
+ execute([command, command_options])
203
+ end
204
+
205
+ def update
206
+ install
207
+ end
208
+
209
+ def install_options
210
+ join_options(@resource[:install_options])
211
+ end
188
212
  end
@@ -12,7 +12,7 @@ Puppet::Type.type(:package).provide :pip3,
12
12
  These options should be specified as a string (e.g. '--flag'), a hash (e.g. {'--flag' => 'value'}),
13
13
  or an array where each element is either a string or a hash."
14
14
 
15
- has_feature :installable, :uninstallable, :upgradeable, :versionable, :install_options
15
+ has_feature :installable, :uninstallable, :upgradeable, :versionable, :install_options, :targetable
16
16
 
17
17
  def self.cmd
18
18
  ["pip3"]
@@ -1,4 +1,4 @@
1
- require 'puppet/provider/package'
1
+ require 'puppet/provider/package/gem'
2
2
 
3
3
  Puppet::Type.type(:package).provide :puppet_gem, :parent => :gem do
4
4
  desc "Puppet Ruby Gem support. This provider is useful for managing
@@ -155,28 +155,39 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr
155
155
  end
156
156
 
157
157
  def uninstall
158
- query if get(:arch) == :absent
159
- nvr = "#{get(:name)}-#{get(:version)}-#{get(:release)}"
160
- arch = ".#{get(:arch)}"
161
- # If they specified an arch in the manifest, erase that Otherwise,
162
- # erase the arch we got back from the query. If multiple arches are
163
- # installed and only the package name is specified (without the
164
- # arch), this will uninstall all of them on successive runs of the
165
- # client, one after the other
166
-
167
- # version of RPM prior to 4.2.1 can't accept the architecture as
168
- # part of the package name.
169
- unless Puppet::Util::Package.versioncmp(self.class.current_version, '4.2.1') < 0
170
- if @resource[:name][-arch.size, arch.size] == arch
171
- nvr += arch
158
+ query
159
+ # If version and release (or only version) is specified in the resource,
160
+ # uninstall using them, otherwise uninstall using only the name of the package.
161
+ name = get(:name)
162
+ version = get(:version)
163
+ release = get(:release)
164
+ nav = "#{name}-#{version}"
165
+ nvr = "#{nav}-#{release}"
166
+ if @resource[:name].start_with? nvr
167
+ identifier = nvr
168
+ else
169
+ if @resource[:name].start_with? nav
170
+ identifier = nav
172
171
  else
173
- nvr += ".#{get(:arch)}"
172
+ identifier = name
173
+ end
174
+ end
175
+ # If an arch is specified in the resource, uninstall that arch,
176
+ # otherwise uninstall the arch returned by query.
177
+ # If multiple arches are installed and arch is not specified,
178
+ # this will uninstall all of them after successive runs.
179
+ #
180
+ # rpm prior to 4.2.1 cannot accept architecture as part of the package name.
181
+ unless Puppet::Util::Package.versioncmp(self.class.current_version, '4.2.1') < 0
182
+ arch = ".#{get(:arch)}"
183
+ if @resource[:name].end_with? arch
184
+ identifier += arch
174
185
  end
175
186
  end
176
187
 
177
188
  flag = ['-e']
178
189
  flag += uninstall_options if resource[:uninstall_options]
179
- rpm flag, nvr
190
+ rpm flag, identifier
180
191
  end
181
192
 
182
193
  def update
@@ -23,6 +23,7 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
23
23
  end
24
24
  end
25
25
 
26
+ defaultfor :operatingsystem => :amazon
26
27
  defaultfor :osfamily => :redhat, :operatingsystemmajrelease => (4..7).to_a
27
28
 
28
29
  def self.prefetch(packages)
@@ -107,7 +108,7 @@ defaultfor :osfamily => :redhat, :operatingsystemmajrelease => (4..7).to_a
107
108
  end
108
109
 
109
110
  def self.update_to_hash(pkgname, pkgversion)
110
-
111
+
111
112
  # The pkgname string has two parts: name, and architecture. Architecture
112
113
  # is the portion of the string following the last "." character. All
113
114
  # characters preceding the final dot are the package name. Parse out
@@ -0,0 +1,68 @@
1
+ # Targetable package providers implement a `command` attribute.
2
+ #
3
+ # The `packages` hash passed to `Puppet::Provider::Package::prefetch` is deduplicated,
4
+ # as it is keyed only by name in `Puppet::Transaction::prefetch_if_necessary`.
5
+ #
6
+ # (The `packages` hash passed to ``Puppet::Provider::Package::prefetch`` should be keyed by all namevars,
7
+ # possibly via a `prefetchV2` method that could take a better data structure.)
8
+ #
9
+ # In addition, `Puppet::Provider::Package::properties` calls `query` in the provider.
10
+ require 'puppet/provider/package'
11
+
12
+ # But `query` in the provider depends upon whether a `command` attribute is defined for the resource.
13
+ # This is a Catch-22.
14
+ #
15
+ # Instead ...
16
+ #
17
+ # Inspect any package to access the catalog (every package includes a reference to the catalog).
18
+ # Inspect the catalog to find all of the `command` attributes for all of the packages of this class.
19
+ # Find all of the package instances using each package `command`, including the default provider command.
20
+ # Assign each instance's `provider` by selecting it from the `packages` hash passed to `prefetch`, based upon `name` and `command`.
21
+ #
22
+ # The original `command` parameter in the catalog is not populated by the default (`:default`) for the parameter in type/package.rb.
23
+ # Rather, the result of the `original_parameters` is `nil` when the `command` parameter is undefined in the catalog.
24
+
25
+ class Puppet::Provider::Package::Targetable < Puppet::Provider::Package
26
+ # Prefetch our package list, yo.
27
+ def self.prefetch(packages)
28
+ catalog_packages = packages.first[1]::catalog::resources.select{ |p| p.provider.class == self }
29
+ package_commands = catalog_packages.map { |catalog_package| catalog_package::original_parameters[:command] }.uniq
30
+ package_commands.each do |command|
31
+ instances(command).each do |instance|
32
+ catalog_packages.each do |catalog_package|
33
+ if catalog_package[:name] == instance.name && catalog_package::original_parameters[:command] == command
34
+ catalog_package.provider = instance
35
+ self.debug "Prefetched instance: %{name} via command: %{command}" % { name: instance.name, cmd: (command || :default)}
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ # Returns the resource command or provider command.
43
+
44
+ def resource_or_provider_command
45
+ resource::original_parameters[:command] || self.class.provider_command
46
+ end
47
+
48
+ # Targetable providers use has_command/is_optional to defer validation of provider suitability.
49
+ # Evaluate provider suitability here and now by validating that the command is defined and exists.
50
+ #
51
+ # cmd: the full path to the package command.
52
+
53
+ def self.validate_command(cmd)
54
+ unless cmd
55
+ raise Puppet::Error, _("Provider %{name} package command is not functional on this host") % { name: name }
56
+ end
57
+ unless File.file?(cmd)
58
+ raise Puppet::Error, _("Provider %{name} package command '%{cmd}' does not exist on this host") % { name: name, cmd: cmd }
59
+ end
60
+ end
61
+
62
+ # Return information about the package, its provider, and its (optional) command.
63
+
64
+ def to_s
65
+ cmd = resource[:command] || :default
66
+ "#{@resource}(provider=#{self.class.name})(command=#{cmd})"
67
+ end
68
+ end