puppet 6.4.2-universal-darwin → 6.4.3-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.
- checksums.yaml +4 -4
- data/Gemfile.lock +17 -17
- data/ext/solaris/smf/puppet.xml +2 -0
- data/lib/hiera/scope.rb +7 -0
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +16 -5
- data/lib/puppet/application/device.rb +12 -3
- data/lib/puppet/application/ssl.rb +2 -0
- data/lib/puppet/configurer.rb +1 -1
- data/lib/puppet/network/http/factory.rb +5 -0
- data/lib/puppet/pops/types/types.rb +5 -3
- data/lib/puppet/provider.rb +1 -2
- data/lib/puppet/provider/package.rb +2 -0
- data/lib/puppet/provider/package/dpkg.rb +15 -2
- data/lib/puppet/provider/package/gem.rb +65 -29
- data/lib/puppet/provider/package/pip.rb +135 -111
- data/lib/puppet/provider/package/pip3.rb +1 -1
- data/lib/puppet/provider/package/puppet_gem.rb +1 -1
- data/lib/puppet/provider/package/rpm.rb +27 -16
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package_targetable.rb +68 -0
- data/lib/puppet/provider/service/upstart.rb +5 -3
- data/lib/puppet/provider/user/useradd.rb +16 -13
- data/lib/puppet/settings/server_list_setting.rb +9 -0
- data/lib/puppet/ssl/host.rb +1 -1
- data/lib/puppet/ssl/state_machine.rb +99 -28
- data/lib/puppet/type/package.rb +46 -9
- data/lib/puppet/util/pidlock.rb +3 -2
- data/lib/puppet/util/windows/process.rb +8 -8
- data/lib/puppet/util/windows/registry.rb +7 -1
- data/lib/puppet/util/windows/user.rb +14 -4
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +115 -103
- data/man/man5/puppet.conf.5 +2 -2
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/integration/type/package_spec.rb +1 -1
- data/spec/integration/util/windows/registry_spec.rb +52 -0
- data/spec/integration/util/windows/user_spec.rb +19 -0
- data/spec/unit/application/agent_spec.rb +53 -32
- data/spec/unit/application/ssl_spec.rb +13 -0
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/functions/new_spec.rb +15 -0
- data/spec/unit/hiera/scope_spec.rb +7 -0
- data/spec/unit/network/http/factory_spec.rb +6 -0
- data/spec/unit/provider/package/dpkg_spec.rb +18 -1
- data/spec/unit/provider/package/gem_spec.rb +101 -48
- data/spec/unit/provider/package/pip3_spec.rb +17 -0
- data/spec/unit/provider/package/pip_spec.rb +57 -67
- data/spec/unit/provider/package/puppet_gem_spec.rb +22 -6
- data/spec/unit/provider/package/rpm_spec.rb +116 -27
- data/spec/unit/provider/service/upstart_spec.rb +3 -22
- data/spec/unit/settings/server_list_setting_spec.rb +21 -0
- data/spec/unit/ssl/state_machine_spec.rb +206 -83
- data/spec/unit/util/pidlock_spec.rb +26 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efd66006e59b9cd2b9b56cc3a7c45c53d7d220628ce57cdd75f9828f4152460d
|
4
|
+
data.tar.gz: ce31437de5092cb156e50ebac0666e5882a52dc7bd94b63b6302742d49df7269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e4b7c4740e39e0d14cc12f84443c9660ab3d38c3f80b2fcd6441ca17a81a1731faa9b095d6f6a49ab506dcca86e471eb6fc0cb0a69ad7f2a2309eb54f9a357b
|
7
|
+
data.tar.gz: d3728e9a92e756a01beee0e66d7676d6a46c29f81215beb081df8ee2a0a8a7369ad1474b169954e7aacb2723734cc31e60ec69765116d234a280f43b478acb70
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
puppet (6.4.
|
4
|
+
puppet (6.4.3)
|
5
5
|
CFPropertyList (~> 2.2)
|
6
6
|
facter (>= 2.4.0, < 4)
|
7
7
|
fast_gettext (~> 1.1.2)
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
crack (0.4.3)
|
24
24
|
safe_yaml (~> 1.0.0)
|
25
25
|
diff-lcs (1.3)
|
26
|
-
facter (2.5.
|
26
|
+
facter (2.5.4)
|
27
27
|
fast_gettext (1.1.2)
|
28
28
|
gettext (3.2.9)
|
29
29
|
locale (>= 2.0.5)
|
@@ -32,7 +32,7 @@ GEM
|
|
32
32
|
fast_gettext (~> 1.1.0)
|
33
33
|
gettext (>= 3.0.2)
|
34
34
|
locale
|
35
|
-
hashdiff (0.
|
35
|
+
hashdiff (1.0.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.
|
47
|
+
memory_profiler (0.9.14)
|
48
48
|
method_source (0.9.2)
|
49
49
|
minitar (0.8)
|
50
|
-
msgpack (1.
|
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.
|
54
|
+
packaging (0.99.36)
|
55
55
|
artifactory (~> 2)
|
56
56
|
rake (~> 12.3)
|
57
57
|
parallel (1.17.0)
|
58
|
-
parser (2.6.
|
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.
|
65
|
-
puppet-resource_api (1.8.
|
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.
|
85
|
+
rspec-core (3.8.2)
|
86
86
|
rspec-support (~> 3.8.0)
|
87
|
-
rspec-expectations (3.8.
|
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.
|
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.
|
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.
|
107
|
-
ruby-progressbar (1.10.
|
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.
|
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.
|
117
|
+
yard (0.9.20)
|
118
118
|
|
119
119
|
PLATFORMS
|
120
120
|
ruby
|
data/ext/solaris/smf/puppet.xml
CHANGED
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,
|
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'
|
@@ -358,11 +358,22 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
|
|
358
358
|
end
|
359
359
|
|
360
360
|
def fingerprint
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
361
|
+
Puppet::Util::Log.newdestination(:console)
|
362
|
+
cert_provider = Puppet::X509::CertProvider.new
|
363
|
+
client_cert = cert_provider.load_client_cert(Puppet[:certname])
|
364
|
+
if client_cert
|
365
|
+
puts Puppet::SSL::Digest.new(options[:digest].to_s, client_cert.to_der).to_s
|
366
|
+
else
|
367
|
+
csr = cert_provider.load_request(Puppet[:certname])
|
368
|
+
if csr
|
369
|
+
puts Puppet::SSL::Digest.new(options[:digest].to_s, csr.to_der).to_s
|
370
|
+
else
|
371
|
+
$stderr.puts _("Fingerprint asked but neither the certificate, nor the certificate request have been issued")
|
372
|
+
exit(1)
|
373
|
+
end
|
374
|
+
end
|
375
|
+
rescue => e
|
376
|
+
Puppet.log_exception(e, _("Failed to generate fingerprint: %{message}") % {message: e.message})
|
366
377
|
exit(1)
|
367
378
|
end
|
368
379
|
|
@@ -277,8 +277,17 @@ Licensed under the Apache 2.0 License
|
|
277
277
|
Puppet.settings.use :main, :agent, :ssl
|
278
278
|
|
279
279
|
unless options[:resource] || options[:facts] || options[:apply]
|
280
|
-
#
|
281
|
-
#
|
280
|
+
# Since it's too complicated to fix properly in the default settings, we workaround for PUP-9642 here.
|
281
|
+
# See https://github.com/puppetlabs/puppet/pull/7483#issuecomment-483455997 for details.
|
282
|
+
# This has to happen after `settings.use` above, so the directory is created and before `setup_host` below, where the SSL
|
283
|
+
# routines would fail with access errors
|
284
|
+
if Puppet.features.root? && !Puppet::Util::Platform.windows?
|
285
|
+
user = Puppet::Type.type(:user).new(name: Puppet[:user]).exists? ? Puppet[:user] : nil
|
286
|
+
group = Puppet::Type.type(:group).new(name: Puppet[:group]).exists? ? Puppet[:group] : nil
|
287
|
+
Puppet.debug("Fixing perms for #{user}:#{group} on #{Puppet[:confdir]}")
|
288
|
+
FileUtils.chown(user, group, Puppet[:confdir]) if user || group
|
289
|
+
end
|
290
|
+
|
282
291
|
ssl_context = setup_context
|
283
292
|
|
284
293
|
unless options[:libdir]
|
@@ -288,7 +297,7 @@ Licensed under the Apache 2.0 License
|
|
288
297
|
end
|
289
298
|
end
|
290
299
|
|
291
|
-
# this
|
300
|
+
# this inits the device singleton, so that the facts terminus
|
292
301
|
# and the various network_device provider can use it
|
293
302
|
Puppet::Util::NetworkDevice.init(device)
|
294
303
|
|
data/lib/puppet/configurer.rb
CHANGED
@@ -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[:
|
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 }
|
@@ -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
|
853
|
-
|
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[/#{
|
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
|
|
data/lib/puppet/provider.rb
CHANGED
@@ -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, _("
|
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
|
-
|
@@ -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
|
-
|
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/
|
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 an array where each element is either a
|
16
16
|
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
|
-
|
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
|
-
|
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
|
-
|
167
|
-
options = {:justme => resource[:name]}
|
168
|
-
options
|
169
|
-
|
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
|
-
|
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
|
-
|
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
|
|