puppet 6.18.0-x86-mingw32 → 6.19.0-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.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -10
- data/README.md +1 -2
- data/Rakefile +4 -12
- data/lib/puppet/agent/locker.rb +0 -7
- data/lib/puppet/application/agent.rb +8 -3
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/lookup.rb +5 -5
- data/lib/puppet/configurer.rb +39 -7
- data/lib/puppet/defaults.rb +55 -29
- data/lib/puppet/environments.rb +51 -10
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/config.rb +46 -16
- data/lib/puppet/face/node.rb +3 -3
- data/lib/puppet/face/node/clean.rb +2 -2
- data/lib/puppet/face/status.rb +1 -1
- data/lib/puppet/file_bucket/dipper.rb +1 -1
- data/lib/puppet/functions/new.rb +8 -3
- data/lib/puppet/http.rb +1 -0
- data/lib/puppet/http/client.rb +1 -1
- data/lib/puppet/http/resolver.rb +5 -8
- data/lib/puppet/http/resolver/server_list.rb +18 -36
- data/lib/puppet/http/resolver/settings.rb +4 -4
- data/lib/puppet/http/resolver/srv.rb +5 -5
- data/lib/puppet/http/service.rb +3 -1
- data/lib/puppet/http/service/compiler.rb +1 -1
- data/lib/puppet/http/service/file_server.rb +1 -1
- data/lib/puppet/http/service/puppetserver.rb +39 -0
- data/lib/puppet/http/session.rb +5 -4
- data/lib/puppet/indirector/catalog/compiler.rb +1 -1
- data/lib/puppet/indirector/facts/yaml.rb +1 -1
- data/lib/puppet/indirector/json.rb +1 -1
- data/lib/puppet/indirector/msgpack.rb +1 -1
- data/lib/puppet/indirector/request.rb +4 -4
- data/lib/puppet/indirector/yaml.rb +1 -1
- data/lib/puppet/network/http/api/master/v3/environments.rb +0 -1
- data/lib/puppet/node/facts.rb +17 -0
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -3
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
- data/lib/puppet/pops/types/p_meta_type.rb +1 -1
- data/lib/puppet/pops/types/p_type_set_type.rb +4 -0
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/pip2.rb +17 -0
- data/lib/puppet/provider/package/puppetserver_gem.rb +180 -0
- data/lib/puppet/provider/package/yum.rb +1 -0
- data/lib/puppet/resource/type.rb +2 -1
- data/lib/puppet/rest/route.rb +2 -2
- data/lib/puppet/settings.rb +19 -5
- data/lib/puppet/transaction/report.rb +11 -7
- data/lib/puppet/type/file/source.rb +1 -1
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/util/connection.rb +8 -8
- data/lib/puppet/util/run_mode.rb +5 -1
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +153 -156
- data/man/man5/puppet.conf.5 +29 -13
- data/man/man8/puppet-agent.8 +6 -3
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +6 -6
- 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 +4 -4
- 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 +2 -2
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/provider/package/puppetserver_gem/gem-list-local-packages +30 -0
- data/spec/integration/application/agent_spec.rb +23 -19
- data/spec/integration/application/filebucket_spec.rb +7 -7
- data/spec/integration/application/plugin_spec.rb +3 -3
- data/spec/integration/configurer_spec.rb +14 -0
- data/spec/integration/defaults_spec.rb +26 -1
- data/spec/integration/util/windows/adsi_spec.rb +2 -2
- data/spec/shared_contexts/types_setup.rb +2 -0
- data/spec/unit/application/doc_spec.rb +2 -2
- data/spec/unit/application/facts_spec.rb +3 -1
- data/spec/unit/application_spec.rb +9 -4
- data/spec/unit/configurer_spec.rb +39 -6
- data/spec/unit/environments_spec.rb +99 -32
- data/spec/unit/face/config_spec.rb +56 -0
- data/spec/unit/face/node_spec.rb +2 -2
- data/spec/unit/file_system_spec.rb +1 -2
- data/spec/unit/http/resolver_spec.rb +24 -4
- data/spec/unit/http/service/ca_spec.rb +2 -2
- data/spec/unit/http/service/compiler_spec.rb +2 -2
- data/spec/unit/http/service/file_server_spec.rb +2 -2
- data/spec/unit/http/service/puppetserver_spec.rb +82 -0
- data/spec/unit/http/service/report_spec.rb +2 -2
- data/spec/unit/http/session_spec.rb +8 -20
- data/spec/unit/indirector/catalog/json_spec.rb +1 -1
- data/spec/unit/indirector/catalog/rest_spec.rb +1 -1
- data/spec/unit/indirector/facts/rest_spec.rb +1 -1
- data/spec/unit/indirector/json_spec.rb +8 -8
- data/spec/unit/indirector/msgpack_spec.rb +8 -8
- data/spec/unit/indirector/node/rest_spec.rb +1 -1
- data/spec/unit/indirector/request_spec.rb +4 -4
- data/spec/unit/indirector/rest_spec.rb +1 -1
- data/spec/unit/indirector/status/rest_spec.rb +1 -1
- data/spec/unit/indirector/yaml_spec.rb +7 -7
- data/spec/unit/network/http/api/master/v3/environments_spec.rb +12 -23
- data/spec/unit/provider/exec_spec.rb +4 -3
- data/spec/unit/provider/package/dpkg_spec.rb +22 -7
- data/spec/unit/provider/package/openbsd_spec.rb +2 -0
- data/spec/unit/provider/package/pip2_spec.rb +36 -0
- data/spec/unit/provider/package/puppetserver_gem_spec.rb +137 -0
- data/spec/unit/provider/package/yum_spec.rb +31 -0
- data/spec/unit/provider/service/base_spec.rb +2 -4
- data/spec/unit/provider/service/bsd_spec.rb +5 -1
- data/spec/unit/provider/service/daemontools_spec.rb +1 -1
- data/spec/unit/provider/service/debian_spec.rb +3 -5
- data/spec/unit/provider/service/freebsd_spec.rb +1 -1
- data/spec/unit/provider/service/gentoo_spec.rb +4 -5
- data/spec/unit/provider/service/init_spec.rb +4 -5
- data/spec/unit/provider/service/launchd_spec.rb +5 -6
- data/spec/unit/provider/service/openrc_spec.rb +4 -5
- data/spec/unit/provider/service/openwrt_spec.rb +1 -1
- data/spec/unit/provider/service/redhat_spec.rb +1 -1
- data/spec/unit/provider/service/runit_spec.rb +2 -1
- data/spec/unit/provider/service/smf_spec.rb +1 -1
- data/spec/unit/provider/service/src_spec.rb +3 -5
- data/spec/unit/provider/service/systemd_spec.rb +3 -1
- data/spec/unit/provider/service/upstart_spec.rb +4 -5
- data/spec/unit/rest/route_spec.rb +4 -4
- data/spec/unit/settings_spec.rb +44 -22
- data/spec/unit/transaction/report_spec.rb +2 -0
- data/spec/unit/type/file/source_spec.rb +1 -1
- data/spec/unit/type/filebucket_spec.rb +1 -1
- data/spec/unit/util/run_mode_spec.rb +6 -6
- metadata +13 -2
data/lib/puppet/http/session.rb
CHANGED
@@ -64,20 +64,21 @@ class Puppet::HTTP::Session
|
|
64
64
|
cached = @resolved_services[name]
|
65
65
|
return cached if cached
|
66
66
|
|
67
|
-
|
68
|
-
|
67
|
+
canceled = false
|
68
|
+
canceled_handler = lambda { |cancel| canceled = cancel }
|
69
69
|
|
70
70
|
@resolvers.each do |resolver|
|
71
71
|
Puppet.debug("Resolving service '#{name}' using #{resolver.class}")
|
72
|
-
service = resolver.resolve(self, name, ssl_context: ssl_context,
|
72
|
+
service = resolver.resolve(self, name, ssl_context: ssl_context, canceled_handler: canceled_handler)
|
73
73
|
if service
|
74
74
|
@resolved_services[name] = service
|
75
75
|
Puppet.debug("Resolved service '#{name}' to #{service.url}")
|
76
76
|
return service
|
77
|
+
elsif canceled
|
78
|
+
break
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
80
|
-
resolution_exceptions.each { |e| Puppet.log_exception(e) }
|
81
82
|
raise Puppet::HTTP::RouteError, "No more routes to #{name}"
|
82
83
|
end
|
83
84
|
|
@@ -20,7 +20,7 @@ class Puppet::Node::Facts::Yaml < Puppet::Indirector::Yaml
|
|
20
20
|
|
21
21
|
# Return the path to a given node's file.
|
22
22
|
def yaml_dir_path
|
23
|
-
base = Puppet.run_mode.
|
23
|
+
base = Puppet.run_mode.server? ? Puppet[:yamldir] : Puppet[:clientyamldir]
|
24
24
|
File.join(base, 'facts', '*.yaml')
|
25
25
|
end
|
26
26
|
|
@@ -41,7 +41,7 @@ class Puppet::Indirector::JSON < Puppet::Indirector::Terminus
|
|
41
41
|
raise ArgumentError, _("invalid key")
|
42
42
|
end
|
43
43
|
|
44
|
-
base = Puppet.run_mode.
|
44
|
+
base = Puppet.run_mode.server? ? Puppet[:server_datadir] : Puppet[:client_datadir]
|
45
45
|
File.join(base, self.class.indirection_name.to_s, name.to_s + ext)
|
46
46
|
end
|
47
47
|
|
@@ -48,7 +48,7 @@ class Puppet::Indirector::Msgpack < Puppet::Indirector::Terminus
|
|
48
48
|
raise ArgumentError, _("invalid key")
|
49
49
|
end
|
50
50
|
|
51
|
-
base = Puppet.run_mode.
|
51
|
+
base = Puppet.run_mode.server? ? Puppet[:server_datadir] : Puppet[:client_datadir]
|
52
52
|
File.join(base, self.class.indirection_name.to_s, name.to_s + ext)
|
53
53
|
end
|
54
54
|
|
@@ -231,9 +231,9 @@ class Puppet::Indirector::Request
|
|
231
231
|
debug_once _("Selected port from the first entry of the `server_list` setting: %{port}") % {port: primary_server[1]}
|
232
232
|
primary_server[1]
|
233
233
|
else
|
234
|
-
#TRANSLATORS '
|
235
|
-
debug_once _("Selected port from the `
|
236
|
-
Puppet.settings[:
|
234
|
+
#TRANSLATORS 'serverport' is the name of a setting and should not be translated
|
235
|
+
debug_once _("Selected port from the `serverport` setting: %{port}") % {port: Puppet.settings[:serverport]}
|
236
|
+
Puppet.settings[:serverport]
|
237
237
|
end
|
238
238
|
end
|
239
239
|
end
|
@@ -277,7 +277,7 @@ class Puppet::Indirector::Request
|
|
277
277
|
# If the URI class can look up the scheme, it will provide a port,
|
278
278
|
# otherwise it will default to '0'.
|
279
279
|
if uri.port.to_i == 0 and uri.scheme == "puppet"
|
280
|
-
@port = Puppet.settings[:
|
280
|
+
@port = Puppet.settings[:serverport].to_i
|
281
281
|
else
|
282
282
|
@port = uri.port.to_i
|
283
283
|
end
|
@@ -40,7 +40,7 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
|
|
40
40
|
raise ArgumentError, _("invalid key")
|
41
41
|
end
|
42
42
|
|
43
|
-
base = Puppet.run_mode.
|
43
|
+
base = Puppet.run_mode.server? ? Puppet[:yamldir] : Puppet[:clientyamldir]
|
44
44
|
File.join(base, self.class.indirection_name.to_s, name.to_s + ext)
|
45
45
|
end
|
46
46
|
|
data/lib/puppet/node/facts.rb
CHANGED
@@ -116,8 +116,25 @@ class Puppet::Node::Facts
|
|
116
116
|
@timestamp = Time.now
|
117
117
|
end
|
118
118
|
|
119
|
+
def to_yaml
|
120
|
+
facts_to_display = Psych.parse_stream(YAML.dump(self))
|
121
|
+
quote_special_strings(facts_to_display)
|
122
|
+
end
|
123
|
+
|
119
124
|
private
|
120
125
|
|
126
|
+
def quote_special_strings(fact_hash)
|
127
|
+
fact_hash.grep(Psych::Nodes::Scalar).each do |node|
|
128
|
+
next unless node.value =~ /:/
|
129
|
+
|
130
|
+
node.plain = false
|
131
|
+
node.quoted = true
|
132
|
+
node.style = Psych::Nodes::Scalar::DOUBLE_QUOTED
|
133
|
+
end
|
134
|
+
|
135
|
+
fact_hash.yaml
|
136
|
+
end
|
137
|
+
|
121
138
|
def sanitize_fact(fact)
|
122
139
|
if fact.is_a? Hash then
|
123
140
|
ret = {}
|
@@ -45,9 +45,7 @@ class Puppet::Pops::Evaluator::Collectors::AbstractCollector
|
|
45
45
|
return false if objects.empty?
|
46
46
|
|
47
47
|
if @overrides and !objects.empty?
|
48
|
-
overrides[:source].
|
49
|
-
true
|
50
|
-
end
|
48
|
+
overrides[:source].override = true
|
51
49
|
|
52
50
|
objects.each do |res|
|
53
51
|
unless @collected.include?(res.ref)
|
@@ -79,9 +79,9 @@ class Runtime3Converter
|
|
79
79
|
|
80
80
|
def convert_String(o, scope, undef_value)
|
81
81
|
# Although wasteful, a dup is needed because user code may mutate these strings when applying
|
82
|
-
# Resources. This does not happen when in
|
82
|
+
# Resources. This does not happen when in server mode since it only uses Resources that are
|
83
83
|
# in puppet core and those are all safe.
|
84
|
-
o.frozen? && !Puppet.run_mode.
|
84
|
+
o.frozen? && !Puppet.run_mode.server? ? o.dup : o
|
85
85
|
end
|
86
86
|
|
87
87
|
def convert_Object(o, scope, undef_value)
|
@@ -22,7 +22,7 @@ class PMetaType < PAnyType
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def instance?(o, guard = nil)
|
25
|
-
|
25
|
+
raise NotImplementedError, "Subclass of PMetaType should implement 'instance?'"
|
26
26
|
end
|
27
27
|
|
28
28
|
# Called from the TypeParser once it has found a type using the Loader. The TypeParser will
|
@@ -349,6 +349,10 @@ class PTypeSetType < PMetaType
|
|
349
349
|
self.class == o.class && @name_authority == o.name_authority && @name == o.name && @version == o.version
|
350
350
|
end
|
351
351
|
|
352
|
+
def instance?(o, guard = nil)
|
353
|
+
o.is_a?(PTypeSetType)
|
354
|
+
end
|
355
|
+
|
352
356
|
DEFAULT = self.new({
|
353
357
|
KEY_NAME => 'DefaultTypeSet',
|
354
358
|
KEY_NAME_AUTHORITY => Pcore::RUNTIME_NAME_AUTHORITY,
|
@@ -74,7 +74,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
|
|
74
74
|
elsif ['config-files', 'half-installed', 'unpacked', 'half-configured'].include?(hash[:status])
|
75
75
|
hash[:ensure] = :absent
|
76
76
|
end
|
77
|
-
hash[:mark] =
|
77
|
+
hash[:mark] = hash[:desired] == 'hold' ? :hold : :none
|
78
78
|
else
|
79
79
|
Puppet.debug("Failed to match dpkg-query line #{line.inspect}")
|
80
80
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Puppet package provider for Python's `pip2` package management frontend.
|
2
|
+
# <http://pip.pypa.io/>
|
3
|
+
|
4
|
+
Puppet::Type.type(:package).provide :pip2,
|
5
|
+
:parent => :pip do
|
6
|
+
|
7
|
+
desc "Python packages via `pip2`.
|
8
|
+
|
9
|
+
This provider supports the `install_options` attribute, which allows command-line flags to be passed to pip2.
|
10
|
+
These options should be specified as an array where each element is either a string or a hash."
|
11
|
+
|
12
|
+
has_feature :installable, :uninstallable, :upgradeable, :versionable, :install_options, :targetable
|
13
|
+
|
14
|
+
def self.cmd
|
15
|
+
["pip2"]
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
unless Puppet::Util::Platform.jruby_fips?
|
2
|
+
require 'rubygems/commands/list_command'
|
3
|
+
end
|
4
|
+
require 'stringio'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
# Ruby gems support.
|
8
|
+
Puppet::Type.type(:package).provide :puppetserver_gem, :parent => :gem do
|
9
|
+
desc "Puppet Server Ruby Gem support. If a URL is passed via `source`, then
|
10
|
+
that URL is appended to the list of remote gem repositories which by default
|
11
|
+
contains rubygems.org; To ensure that only the specified source is used also
|
12
|
+
pass `--clear-sources` in via `install_options`; if a source is present but
|
13
|
+
is not a valid URL, it will be interpreted as the path to a local gem file.
|
14
|
+
If source is not present at all, the gem will be installed from the default
|
15
|
+
gem repositories."
|
16
|
+
|
17
|
+
has_feature :versionable, :install_options, :uninstall_options
|
18
|
+
|
19
|
+
confine :feature => :hocon
|
20
|
+
# see SERVER-2578
|
21
|
+
confine :fips_enabled => false
|
22
|
+
|
23
|
+
# Define the default provider package command name, as the parent 'gem' provider is targetable.
|
24
|
+
# Required by Puppet::Provider::Package::Targetable::resource_or_provider_command
|
25
|
+
|
26
|
+
def self.provider_command
|
27
|
+
command(:puppetservercmd)
|
28
|
+
end
|
29
|
+
|
30
|
+
# The gem command uses HOME to locate a gemrc file.
|
31
|
+
# CommandDefiner in provider.rb will set failonfail, combine, and environment.
|
32
|
+
|
33
|
+
has_command(:puppetservercmd, '/opt/puppetlabs/bin/puppetserver') do
|
34
|
+
environment(HOME: ENV['HOME'])
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.gemlist(options)
|
38
|
+
command_options = ['gem', 'list']
|
39
|
+
|
40
|
+
if options[:local]
|
41
|
+
command_options << '--local'
|
42
|
+
else
|
43
|
+
command_options << '--remote'
|
44
|
+
end
|
45
|
+
|
46
|
+
if options[:source]
|
47
|
+
command_options << '--source' << options[:source]
|
48
|
+
end
|
49
|
+
|
50
|
+
if options[:justme]
|
51
|
+
gem_regex = '\A' + options[:justme] + '\z'
|
52
|
+
command_options << gem_regex
|
53
|
+
end
|
54
|
+
|
55
|
+
if options[:local]
|
56
|
+
list = execute_rubygems_list_command(gem_regex)
|
57
|
+
else
|
58
|
+
begin
|
59
|
+
list = puppetservercmd(command_options)
|
60
|
+
rescue Puppet::ExecutionFailure => detail
|
61
|
+
raise Puppet::Error, _("Could not list gems: %{detail}") % { detail: detail }, detail.backtrace
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# When `/tmp` is mounted `noexec`, `puppetserver gem list` will output:
|
66
|
+
# *** LOCAL GEMS ***
|
67
|
+
# causing gemsplit to output:
|
68
|
+
# Warning: Could not match *** LOCAL GEMS ***
|
69
|
+
gem_list = list
|
70
|
+
.lines
|
71
|
+
.select { |x| x =~ /^(\S+)\s+\((.+)\)/ }
|
72
|
+
.map { |set| gemsplit(set) }
|
73
|
+
|
74
|
+
if options[:justme]
|
75
|
+
return gem_list.shift
|
76
|
+
else
|
77
|
+
return gem_list
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def install(useversion = true)
|
82
|
+
command_options = ['gem', 'install']
|
83
|
+
command_options += install_options if resource[:install_options]
|
84
|
+
|
85
|
+
command_options << '-v' << resource[:ensure] if (!resource[:ensure].is_a? Symbol) && useversion
|
86
|
+
|
87
|
+
command_options << '--no-document'
|
88
|
+
|
89
|
+
if resource[:source]
|
90
|
+
begin
|
91
|
+
uri = URI.parse(resource[:source])
|
92
|
+
rescue => detail
|
93
|
+
self.fail Puppet::Error, _("Invalid source '%{uri}': %{detail}") % { uri: uri, detail: detail }, detail
|
94
|
+
end
|
95
|
+
|
96
|
+
case uri.scheme
|
97
|
+
when nil
|
98
|
+
# no URI scheme => interpret the source as a local file
|
99
|
+
command_options << resource[:source]
|
100
|
+
when /file/i
|
101
|
+
command_options << uri.path
|
102
|
+
when 'puppet'
|
103
|
+
# we don't support puppet:// URLs (yet)
|
104
|
+
raise Puppet::Error.new(_('puppet:// URLs are not supported as gem sources'))
|
105
|
+
else
|
106
|
+
# interpret it as a gem repository
|
107
|
+
command_options << '--source' << "#{resource[:source]}" << resource[:name]
|
108
|
+
end
|
109
|
+
else
|
110
|
+
command_options << resource[:name]
|
111
|
+
end
|
112
|
+
|
113
|
+
output = puppetservercmd(command_options)
|
114
|
+
# Apparently, some gem versions don't exit non-0 on failure.
|
115
|
+
self.fail _("Could not install: %{output}") % { output: output.chomp } if output.include?('ERROR')
|
116
|
+
end
|
117
|
+
|
118
|
+
def uninstall
|
119
|
+
command_options = ['gem', 'uninstall']
|
120
|
+
command_options << '--executables' << '--all' << resource[:name]
|
121
|
+
command_options += uninstall_options if resource[:uninstall_options]
|
122
|
+
|
123
|
+
output = puppetservercmd(command_options)
|
124
|
+
# Apparently, some gem versions don't exit non-0 on failure.
|
125
|
+
self.fail _("Could not uninstall: %{output}") % { output: output.chomp } if output.include?('ERROR')
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
# The puppetserver gem cli command is very slow, since it starts a JVM.
|
131
|
+
#
|
132
|
+
# Instead, for the list subcommand (which is executed with every puppet run),
|
133
|
+
# use the rubygems library from puppet ruby: setting GEM_HOME and GEM_PATH
|
134
|
+
# to the default values, or the values in the puppetserver configuration file.
|
135
|
+
#
|
136
|
+
# The rubygems library cannot access java platform gems,
|
137
|
+
# for example: json (1.8.3 java)
|
138
|
+
# but java platform gems should not be managed by this (or any) provider.
|
139
|
+
|
140
|
+
def self.execute_rubygems_list_command(gem_regex)
|
141
|
+
puppetserver_default_gem_home = '/opt/puppetlabs/server/data/puppetserver/jruby-gems'
|
142
|
+
puppetserver_default_vendored_jruby_gems = '/opt/puppetlabs/server/data/puppetserver/vendored-jruby-gems'
|
143
|
+
puppet_default_vendor_gems = '/opt/puppetlabs/puppet/lib/ruby/vendor_gems'
|
144
|
+
puppetserver_default_gem_path = [puppetserver_default_gem_home, puppetserver_default_vendored_jruby_gems, puppet_default_vendor_gems].join(':')
|
145
|
+
|
146
|
+
pe_puppetserver_conf_file = '/etc/puppetlabs/puppetserver/conf.d/pe-puppet-server.conf'
|
147
|
+
os_puppetserver_conf_file = '/etc/puppetlabs/puppetserver/puppetserver.conf'
|
148
|
+
puppetserver_conf_file = Facter.value(:pe_server_version) ? pe_puppetserver_conf_file : os_puppetserver_conf_file
|
149
|
+
puppetserver_conf = Hocon.load(puppetserver_conf_file)
|
150
|
+
|
151
|
+
gem_env = {}
|
152
|
+
if puppetserver_conf.empty? || puppetserver_conf.key?('jruby-puppet') == false
|
153
|
+
gem_env['GEM_HOME'] = puppetserver_default_gem_home
|
154
|
+
gem_env['GEM_PATH'] = puppetserver_default_gem_path
|
155
|
+
else
|
156
|
+
gem_env['GEM_HOME'] = puppetserver_conf['jruby-puppet'].key?('gem-home') ? puppetserver_conf['jruby-puppet']['gem-home'] : puppetserver_default_gem_home
|
157
|
+
gem_env['GEM_PATH'] = puppetserver_conf['jruby-puppet'].key?('gem-path') ? puppetserver_conf['jruby-puppet']['gem-path'].join(':') : puppetserver_default_gem_path
|
158
|
+
end
|
159
|
+
gem_env['GEM_SPEC_CACHE'] = "/tmp/#{$$}"
|
160
|
+
Gem.paths = gem_env
|
161
|
+
|
162
|
+
sio_inn = StringIO.new
|
163
|
+
sio_out = StringIO.new
|
164
|
+
sio_err = StringIO.new
|
165
|
+
stream_ui = Gem::StreamUI.new(sio_inn, sio_out, sio_err, false)
|
166
|
+
gem_list_cmd = Gem::Commands::ListCommand.new
|
167
|
+
gem_list_cmd.options[:domain] = :local
|
168
|
+
gem_list_cmd.options[:args] = [gem_regex] if gem_regex
|
169
|
+
gem_list_cmd.ui = stream_ui
|
170
|
+
gem_list_cmd.execute
|
171
|
+
|
172
|
+
# There is no method exclude default gems from the local gem list,
|
173
|
+
# for example: psych (default: 2.2.2)
|
174
|
+
# but default gems should not be managed by this (or any) provider.
|
175
|
+
gem_list = sio_out.string.lines.reject { |gem| gem =~ / \(default\: / }
|
176
|
+
gem_list.join("\n")
|
177
|
+
ensure
|
178
|
+
Gem.clear_paths
|
179
|
+
end
|
180
|
+
end
|
@@ -328,6 +328,7 @@ defaultfor :osfamily => :redhat, :operatingsystemmajrelease => (4..7).to_a
|
|
328
328
|
return "#{upd[:epoch]}:#{upd[:version]}-#{upd[:release]}"
|
329
329
|
else
|
330
330
|
# Yum didn't find updates, pretend the current version is the latest
|
331
|
+
self.debug "Yum didn't find updates, current version (#{properties[:ensure]}) is the latest"
|
331
332
|
version = properties[:ensure]
|
332
333
|
raise Puppet::DevError, _("Tried to get latest on a missing package") if version == :absent || version == :purged
|
333
334
|
return version
|
data/lib/puppet/resource/type.rb
CHANGED
@@ -34,7 +34,7 @@ class Puppet::Resource::Type
|
|
34
34
|
DOUBLE_COLON = '::'.freeze
|
35
35
|
EMPTY_ARRAY = [].freeze
|
36
36
|
|
37
|
-
attr_accessor :file, :line, :doc, :code, :parent, :resource_type_collection
|
37
|
+
attr_accessor :file, :line, :doc, :code, :parent, :resource_type_collection, :override
|
38
38
|
attr_reader :namespace, :arguments, :behaves_like, :module_name
|
39
39
|
|
40
40
|
# The attributes 'produces' and 'consumes' are arrays of the blueprints
|
@@ -63,6 +63,7 @@ class Puppet::Resource::Type
|
|
63
63
|
# Are we a child of the passed class? Do a recursive search up our
|
64
64
|
# parentage tree to figure it out.
|
65
65
|
def child_of?(klass)
|
66
|
+
return true if override
|
66
67
|
return false unless parent
|
67
68
|
|
68
69
|
return(klass == parent_type ? true : parent_type.child_of?(klass))
|
data/lib/puppet/rest/route.rb
CHANGED
@@ -14,11 +14,11 @@ module Puppet::Rest
|
|
14
14
|
# construction
|
15
15
|
# @param [Symbol] server_setting the setting to check for special
|
16
16
|
# server configuration
|
17
|
-
# @param [Symbol] port_setting the setting to check for
|
17
|
+
# @param [Symbol] port_setting the setting to check for special
|
18
18
|
# port configuration
|
19
19
|
# @param [Symbol] srv_service the name of the service when using SRV
|
20
20
|
# records
|
21
|
-
def initialize(api:, server_setting: :server, port_setting: :
|
21
|
+
def initialize(api:, server_setting: :server, port_setting: :serverport, srv_service: :puppet)
|
22
22
|
@api = api
|
23
23
|
@default_server = Puppet::Util::Connection.determine_server(server_setting)
|
24
24
|
@default_port = Puppet::Util::Connection.determine_port(port_setting, server_setting)
|
data/lib/puppet/settings.rb
CHANGED
@@ -44,7 +44,7 @@ class Puppet::Settings
|
|
44
44
|
REQUIRED_APP_SETTINGS = [:logdir, :confdir, :vardir, :codedir]
|
45
45
|
|
46
46
|
# The acceptable sections of the puppet.conf configuration file.
|
47
|
-
ALLOWED_SECTION_NAMES = ['main', 'master', 'agent', 'user'].freeze
|
47
|
+
ALLOWED_SECTION_NAMES = ['main', 'server', 'master', 'agent', 'user'].freeze
|
48
48
|
|
49
49
|
NONE = 'none'.freeze
|
50
50
|
|
@@ -330,7 +330,7 @@ class Puppet::Settings
|
|
330
330
|
end
|
331
331
|
|
332
332
|
option_parser.on('--run_mode',
|
333
|
-
"The effective 'run mode' of the application:
|
333
|
+
"The effective 'run mode' of the application: server, agent, or user.",
|
334
334
|
:REQUIRED) do |arg|
|
335
335
|
Puppet.settings.preferred_run_mode = arg
|
336
336
|
end
|
@@ -564,7 +564,7 @@ class Puppet::Settings
|
|
564
564
|
# @api private
|
565
565
|
def preferred_run_mode=(mode)
|
566
566
|
mode = mode.to_s.downcase.intern
|
567
|
-
raise ValidationError, "Invalid run mode '#{mode}'" unless [:master, :agent, :user].include?(mode)
|
567
|
+
raise ValidationError, "Invalid run mode '#{mode}'" unless [:server, :master, :agent, :user].include?(mode)
|
568
568
|
@preferred_run_mode_name = mode
|
569
569
|
# Changing the run mode has far-reaching consequences. Flush any cached
|
570
570
|
# settings so they will be re-generated.
|
@@ -659,7 +659,7 @@ class Puppet::Settings
|
|
659
659
|
if explicit_config_file?
|
660
660
|
return self[:config]
|
661
661
|
else
|
662
|
-
return File.join(Puppet::Util::RunMode[:
|
662
|
+
return File.join(Puppet::Util::RunMode[:server].conf_dir, config_file_name)
|
663
663
|
end
|
664
664
|
end
|
665
665
|
private :main_config_file
|
@@ -829,7 +829,16 @@ class Puppet::Settings
|
|
829
829
|
SearchPathElement.new(:cli, :values),
|
830
830
|
]
|
831
831
|
searchpath << SearchPathElement.new(environment.intern, :environment) if environment
|
832
|
-
|
832
|
+
|
833
|
+
if run_mode
|
834
|
+
if [:master, :server].include?(run_mode)
|
835
|
+
searchpath << SearchPathElement.new(:server, :section)
|
836
|
+
searchpath << SearchPathElement.new(:master, :section)
|
837
|
+
else
|
838
|
+
searchpath << SearchPathElement.new(run_mode, :section)
|
839
|
+
end
|
840
|
+
end
|
841
|
+
|
833
842
|
searchpath << SearchPathElement.new(:main, :section)
|
834
843
|
end
|
835
844
|
|
@@ -1053,6 +1062,11 @@ Generated on #{Time.now}.
|
|
1053
1062
|
# Create the necessary objects to use a section. This is idempotent;
|
1054
1063
|
# you can 'use' a section as many times as you want.
|
1055
1064
|
def use(*sections)
|
1065
|
+
Puppet.warning(":master section deprecated in favor of :server section") if sections.include?(:master)
|
1066
|
+
|
1067
|
+
# add :server if sections include :master or :master if sections include :server
|
1068
|
+
sections |= [:master, :server] if (sections & [:master, :server]).any?
|
1069
|
+
|
1056
1070
|
sections = sections.collect { |s| s.to_sym }
|
1057
1071
|
sections = sections.reject { |s| @used.include?(s) }
|
1058
1072
|
|