bolt 0.23.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bolt might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +5 -2
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb +5 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +5 -8
- data/lib/bolt/applicator.rb +11 -8
- data/lib/bolt/boltdir.rb +13 -5
- data/lib/bolt/catalog.rb +22 -47
- data/lib/bolt/config.rb +1 -26
- data/lib/bolt/executor.rb +1 -1
- data/lib/bolt/outputter.rb +0 -9
- data/lib/bolt/outputter/human.rb +29 -14
- data/lib/bolt/outputter/json.rb +12 -1
- data/lib/bolt/pal.rb +12 -10
- data/lib/bolt/target.rb +0 -6
- data/lib/bolt/task.rb +53 -10
- data/lib/bolt/transport/base.rb +1 -6
- data/lib/bolt/transport/local.rb +11 -13
- data/lib/bolt/transport/local/shell.rb +2 -2
- data/lib/bolt/transport/ssh.rb +16 -11
- data/lib/bolt/transport/winrm.rb +8 -11
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_ext/schemas/task.json +12 -5
- data/libexec/apply_catalog.rb +3 -1
- data/libexec/bolt_catalog +4 -0
- data/vendored/puppet/lib/puppet.rb +2 -1
- data/vendored/puppet/lib/puppet/application/agent.rb +2 -6
- data/vendored/puppet/lib/puppet/application/apply.rb +100 -60
- data/vendored/puppet/lib/puppet/application/cert.rb +26 -291
- data/vendored/puppet/lib/puppet/application/device.rb +0 -5
- data/vendored/puppet/lib/puppet/application/lookup.rb +1 -1
- data/vendored/puppet/lib/puppet/application/ssl.rb +133 -0
- data/vendored/puppet/lib/puppet/application_support.rb +1 -2
- data/vendored/puppet/lib/puppet/configurer.rb +34 -50
- data/vendored/puppet/lib/puppet/configurer/downloader.rb +1 -1
- data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +1 -1
- data/vendored/puppet/lib/puppet/daemon.rb +1 -1
- data/vendored/puppet/lib/puppet/defaults.rb +40 -117
- data/vendored/puppet/lib/puppet/face/epp.rb +2 -2
- data/vendored/puppet/lib/puppet/face/help.rb +21 -7
- data/vendored/puppet/lib/puppet/face/node/clean.rb +14 -10
- data/vendored/puppet/lib/puppet/feature/base.rb +7 -23
- data/vendored/puppet/lib/puppet/feature/eventlog.rb +1 -1
- data/vendored/puppet/lib/puppet/file_serving/base.rb +2 -2
- data/vendored/puppet/lib/puppet/file_serving/fileset.rb +1 -1
- data/vendored/puppet/lib/puppet/file_serving/metadata.rb +2 -2
- data/vendored/puppet/lib/puppet/functions.rb +133 -0
- data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -5
- data/vendored/puppet/lib/puppet/functions/filter.rb +7 -6
- data/vendored/puppet/lib/puppet/functions/new.rb +37 -53
- data/vendored/puppet/lib/puppet/functions/warning.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/yaml_data.rb +4 -5
- data/vendored/puppet/lib/puppet/gettext/config.rb +1 -1
- data/vendored/puppet/lib/puppet/graph.rb +0 -2
- data/vendored/puppet/lib/puppet/indirector/catalog/json.rb +14 -3
- data/vendored/puppet/lib/puppet/indirector/catalog/yaml.rb +0 -16
- data/vendored/puppet/lib/puppet/indirector/certificate/file.rb +0 -1
- data/vendored/puppet/lib/puppet/indirector/facts/yaml.rb +4 -2
- data/vendored/puppet/lib/puppet/indirector/key/file.rb +1 -6
- data/vendored/puppet/lib/puppet/indirector/node/exec.rb +1 -3
- data/vendored/puppet/lib/puppet/indirector/node/yaml.rb +0 -6
- data/vendored/puppet/lib/puppet/indirector/request.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/ssl_file.rb +3 -44
- data/vendored/puppet/lib/puppet/indirector/yaml.rb +4 -4
- data/vendored/puppet/lib/puppet/info_service/task_information_service.rb +7 -3
- data/vendored/puppet/lib/puppet/loaders.rb +1 -0
- data/vendored/puppet/lib/puppet/module/task.rb +198 -29
- data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/vendored/puppet/lib/puppet/network/format_support.rb +13 -8
- data/vendored/puppet/lib/puppet/network/formats.rb +93 -2
- data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +10 -3
- data/vendored/puppet/lib/puppet/node/facts.rb +11 -1
- data/vendored/puppet/lib/puppet/parser/catalog_compiler.rb +56 -0
- data/vendored/puppet/lib/puppet/parser/compiler.rb +3 -1
- data/vendored/puppet/lib/puppet/parser/functions.rb +3 -1
- data/vendored/puppet/lib/puppet/parser/functions/filter.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/generate.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/sprintf.rb +12 -1
- data/vendored/puppet/lib/puppet/parser/functions/tagged.rb +1 -4
- data/vendored/puppet/lib/puppet/parser/scope.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/script_compiler.rb +7 -2
- data/vendored/puppet/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_converter.rb +23 -4
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +3 -4
- data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +4 -0
- data/vendored/puppet/lib/puppet/pops/issues.rb +8 -0
- data/vendored/puppet/lib/puppet/pops/loader/loader.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +3 -1
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +30 -9
- data/vendored/puppet/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +62 -0
- data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +0 -1
- data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +13 -70
- data/vendored/puppet/lib/puppet/pops/loaders.rb +19 -29
- data/vendored/puppet/lib/puppet/pops/lookup/hiera_config.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +4 -1
- data/vendored/puppet/lib/puppet/pops/pcore.rb +10 -33
- data/vendored/puppet/lib/puppet/pops/serialization.rb +2 -0
- data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +11 -3
- data/vendored/puppet/lib/puppet/pops/serialization/to_stringified_converter.rb +226 -0
- data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +3 -0
- data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +97 -47
- data/vendored/puppet/lib/puppet/pops/validation/validator_factory_4_0.rb +7 -8
- data/vendored/puppet/lib/puppet/property/keyvalue.rb +70 -8
- data/vendored/puppet/lib/puppet/provider/aix_object.rb +483 -0
- data/vendored/puppet/lib/puppet/provider/file/windows.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/group/aix.rb +51 -112
- data/vendored/puppet/lib/puppet/provider/package/gem.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/pip.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/puppet_gem.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/rpm.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/windows/package.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/zypper.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/service/windows.rb +37 -40
- data/vendored/puppet/lib/puppet/provider/user/aix.rb +142 -254
- data/vendored/puppet/lib/puppet/resource.rb +20 -3
- data/vendored/puppet/lib/puppet/resource/catalog.rb +2 -12
- data/vendored/puppet/lib/puppet/rest/routes.rb +97 -34
- data/vendored/puppet/lib/puppet/settings.rb +1 -1
- data/vendored/puppet/lib/puppet/settings/file_setting.rb +1 -1
- data/vendored/puppet/lib/puppet/ssl/base.rb +1 -9
- data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +1 -13
- data/vendored/puppet/lib/puppet/ssl/certificate_request_attributes.rb +1 -1
- data/vendored/puppet/lib/puppet/ssl/host.rb +114 -232
- data/vendored/puppet/lib/puppet/ssl/key.rb +1 -5
- data/vendored/puppet/lib/puppet/ssl/oids.rb +1 -1
- data/vendored/puppet/lib/puppet/test/test_helper.rb +0 -4
- data/vendored/puppet/lib/puppet/transaction/event.rb +3 -7
- data/vendored/puppet/lib/puppet/transaction/persistence.rb +1 -1
- data/vendored/puppet/lib/puppet/type/exec.rb +18 -16
- data/vendored/puppet/lib/puppet/type/file.rb +3 -3
- data/vendored/puppet/lib/puppet/type/file/source.rb +20 -7
- data/vendored/puppet/lib/puppet/type/group.rb +3 -5
- data/vendored/puppet/lib/puppet/type/notify.rb +1 -1
- data/vendored/puppet/lib/puppet/type/package.rb +2 -5
- data/vendored/puppet/lib/puppet/type/schedule.rb +1 -1
- data/vendored/puppet/lib/puppet/type/service.rb +3 -6
- data/vendored/puppet/lib/puppet/type/tidy.rb +1 -1
- data/vendored/puppet/lib/puppet/type/user.rb +13 -20
- data/vendored/puppet/lib/puppet/util.rb +8 -9
- data/vendored/puppet/lib/puppet/util/execution.rb +3 -3
- data/vendored/puppet/lib/puppet/util/feature.rb +61 -39
- data/vendored/puppet/lib/puppet/util/log/destinations.rb +1 -1
- data/vendored/puppet/lib/puppet/util/rdoc.rb +1 -1
- data/vendored/puppet/lib/puppet/util/run_mode.rb +1 -1
- data/vendored/puppet/lib/puppet/util/storage.rb +1 -1
- data/vendored/puppet/lib/puppet/util/suidmanager.rb +7 -5
- data/vendored/puppet/lib/puppet/util/tag_set.rb +1 -1
- data/vendored/puppet/lib/puppet/util/tagging.rb +1 -1
- data/vendored/puppet/lib/puppet/util/windows.rb +18 -2
- data/vendored/puppet/lib/puppet/util/windows/adsi.rb +154 -205
- data/vendored/puppet/lib/puppet/util/windows/service.rb +770 -0
- data/vendored/puppet/lib/puppet/util/yaml.rb +41 -5
- data/vendored/puppet/lib/puppet/version.rb +1 -1
- data/vendored/puppet/lib/puppet_pal.rb +280 -24
- metadata +8 -38
- data/lib/bolt/catalog/compiler.rb +0 -48
- data/lib/bolt/catalog/loaders.rb +0 -19
- data/vendored/puppet/lib/puppet/application/ca.rb +0 -11
- data/vendored/puppet/lib/puppet/application/certificate.rb +0 -17
- data/vendored/puppet/lib/puppet/application/certificate_request.rb +0 -7
- data/vendored/puppet/lib/puppet/application/certificate_revocation_list.rb +0 -7
- data/vendored/puppet/lib/puppet/face/ca.rb +0 -266
- data/vendored/puppet/lib/puppet/face/certificate.rb +0 -167
- data/vendored/puppet/lib/puppet/face/certificate_request.rb +0 -56
- data/vendored/puppet/lib/puppet/face/certificate_revocation_list.rb +0 -56
- data/vendored/puppet/lib/puppet/graph/random_prioritizer.rb +0 -16
- data/vendored/puppet/lib/puppet/graph/title_hash_prioritizer.rb +0 -16
- data/vendored/puppet/lib/puppet/indirector/certificate/ca.rb +0 -9
- data/vendored/puppet/lib/puppet/indirector/certificate/disabled_ca.rb +0 -22
- data/vendored/puppet/lib/puppet/indirector/certificate_request/ca.rb +0 -22
- data/vendored/puppet/lib/puppet/indirector/certificate_request/disabled_ca.rb +0 -22
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/ca.rb +0 -8
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +0 -22
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/file.rb +0 -8
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/rest.rb +0 -11
- data/vendored/puppet/lib/puppet/indirector/certificate_status.rb +0 -4
- data/vendored/puppet/lib/puppet/indirector/certificate_status/file.rb +0 -91
- data/vendored/puppet/lib/puppet/indirector/certificate_status/rest.rb +0 -11
- data/vendored/puppet/lib/puppet/indirector/key/ca.rb +0 -16
- data/vendored/puppet/lib/puppet/indirector/key/disabled_ca.rb +0 -22
- data/vendored/puppet/lib/puppet/indirector/ldap.rb +0 -86
- data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +0 -275
- data/vendored/puppet/lib/puppet/provider/aixobject.rb +0 -392
- data/vendored/puppet/lib/puppet/provider/cron/crontab.rb +0 -297
- data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +0 -475
- data/vendored/puppet/lib/puppet/ssl/certificate_authority/autosign_command.rb +0 -45
- data/vendored/puppet/lib/puppet/ssl/certificate_authority/interface.rb +0 -324
- data/vendored/puppet/lib/puppet/ssl/certificate_factory.rb +0 -219
- data/vendored/puppet/lib/puppet/ssl/certificate_revocation_list.rb +0 -111
- data/vendored/puppet/lib/puppet/ssl/inventory.rb +0 -55
- data/vendored/puppet/lib/puppet/type/cron.rb +0 -480
@@ -405,7 +405,7 @@ Puppet::Face.define(:epp, '0.0.1') do
|
|
405
405
|
if values_file = options[:values_file]
|
406
406
|
begin
|
407
407
|
if values_file =~ /\.yaml$/
|
408
|
-
template_values =
|
408
|
+
template_values = Puppet::Util::Yaml.safe_load_file(values_file, [Symbol])
|
409
409
|
elsif values_file =~ /\.pp$/
|
410
410
|
evaluating_parser = Puppet::Pops::Parser::EvaluatingParser.new
|
411
411
|
template_values = evaluating_parser.evaluate_file(compiler.topscope, values_file)
|
@@ -511,7 +511,7 @@ Puppet::Face.define(:epp, '0.0.1') do
|
|
511
511
|
elsif fact_file.end_with?("json")
|
512
512
|
given_facts = Puppet::Util::Json.load(Puppet::FileSystem.read(fact_file, :encoding => 'utf-8'))
|
513
513
|
else
|
514
|
-
given_facts =
|
514
|
+
given_facts = Puppet::Util::Yaml.safe_load_file(fact_file)
|
515
515
|
end
|
516
516
|
|
517
517
|
unless given_facts.instance_of?(Hash)
|
@@ -132,19 +132,21 @@ Puppet::Face.define(:help, '0.0.1') do
|
|
132
132
|
# element in the outer array is a pair whose first element is a String containing the application
|
133
133
|
# name, and whose second element is a String containing the summary for that application.
|
134
134
|
def all_application_summaries()
|
135
|
-
|
135
|
+
available_application_names_special_sort().inject([]) do |result, appname|
|
136
136
|
next result if exclude_from_docs?(appname)
|
137
137
|
|
138
|
-
if (
|
138
|
+
if (appname == COMMON || appname == SPECIALIZED || appname == BLANK)
|
139
|
+
result << appname
|
140
|
+
elsif (is_face_app?(appname))
|
139
141
|
begin
|
140
142
|
face = Puppet::Face[appname, :current]
|
141
143
|
# Add deprecation message to summary if the face is deprecated
|
142
144
|
summary = face.deprecated? ? face.summary + ' ' + _("(Deprecated)") : face.summary
|
143
|
-
result << [appname, summary]
|
145
|
+
result << [appname, summary, ' ']
|
144
146
|
rescue StandardError, LoadError
|
145
147
|
error_message = _("!%{sub_command}! Subcommand unavailable due to error.") % { sub_command: appname }
|
146
148
|
error_message += ' ' + _("Check error logs.")
|
147
|
-
result << [ error_message ]
|
149
|
+
result << [ error_message, '', ' ' ]
|
148
150
|
end
|
149
151
|
else
|
150
152
|
begin
|
@@ -152,16 +154,28 @@ Puppet::Face.define(:help, '0.0.1') do
|
|
152
154
|
if summary.empty?
|
153
155
|
summary = horribly_extract_summary_from(appname)
|
154
156
|
end
|
155
|
-
result << [appname, summary]
|
157
|
+
result << [appname, summary, ' ']
|
156
158
|
rescue StandardError, LoadError
|
157
159
|
error_message = _("!%{sub_command}! Subcommand unavailable due to error.") % { sub_command: appname }
|
158
160
|
error_message += ' ' + _("Check error logs.")
|
159
|
-
result << [ error_message ]
|
161
|
+
result << [ error_message, '', ' ' ]
|
160
162
|
end
|
161
163
|
end
|
162
164
|
end
|
163
165
|
end
|
164
166
|
|
167
|
+
COMMON = 'Common:'.freeze
|
168
|
+
SPECIALIZED = 'Specialized:'.freeze
|
169
|
+
BLANK = "\n".freeze
|
170
|
+
def available_application_names_special_sort()
|
171
|
+
full_list = Puppet::Application.available_application_names
|
172
|
+
a_list = full_list & %w{apply agent config help lookup module resource}
|
173
|
+
a_list = a_list.sort
|
174
|
+
also_ran = full_list - a_list
|
175
|
+
also_ran = also_ran.sort
|
176
|
+
[[COMMON], a_list, [BLANK], [SPECIALIZED], also_ran].flatten(1)
|
177
|
+
end
|
178
|
+
|
165
179
|
def horribly_extract_summary_from(appname)
|
166
180
|
help = Puppet::Application[appname].help.split("\n")
|
167
181
|
# Now we find the line with our summary, extract it, and return it. This
|
@@ -181,7 +195,7 @@ Puppet::Face.define(:help, '0.0.1') do
|
|
181
195
|
#private :horribly_extract_summary_from
|
182
196
|
|
183
197
|
def exclude_from_docs?(appname)
|
184
|
-
%w{face_base indirection_base}.include? appname
|
198
|
+
%w{face_base indirection_base cert key man plugin report status}.include? appname
|
185
199
|
end
|
186
200
|
# This should absolutely be a private method, but for some reason it appears
|
187
201
|
# that you can't use the 'private' keyword inside of a Face definition.
|
@@ -14,6 +14,7 @@ Puppet::Face.define(:node, '0.0.1') do
|
|
14
14
|
|
15
15
|
<Reports> - ($vardir/reports/node.domain)
|
16
16
|
|
17
|
+
NOTE: this action now cleans up certs via Puppet Server's CA API. A running server is required for certs to be cleaned.
|
17
18
|
EOT
|
18
19
|
|
19
20
|
when_invoked do |*args|
|
@@ -29,12 +30,6 @@ Puppet::Face.define(:node, '0.0.1') do
|
|
29
30
|
# certificates correctly.
|
30
31
|
Puppet.settings.preferred_run_mode = "master"
|
31
32
|
|
32
|
-
if Puppet::SSL::CertificateAuthority.ca?
|
33
|
-
Puppet::SSL::Host.ca_location = :local
|
34
|
-
else
|
35
|
-
Puppet::SSL::Host.ca_location = :none
|
36
|
-
end
|
37
|
-
|
38
33
|
Puppet::Node::Facts.indirection.terminus_class = :yaml
|
39
34
|
Puppet::Node::Facts.indirection.cache_class = :yaml
|
40
35
|
Puppet::Node.indirection.terminus_class = :yaml
|
@@ -51,12 +46,21 @@ Puppet::Face.define(:node, '0.0.1') do
|
|
51
46
|
clean_reports(node)
|
52
47
|
end
|
53
48
|
|
49
|
+
class LoggerIO
|
50
|
+
def err(message)
|
51
|
+
Puppet.err(message) unless message =~ /^\s*Error:\s*/
|
52
|
+
end
|
53
|
+
|
54
|
+
def inform(message)
|
55
|
+
Puppet.notice(message)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
54
59
|
# clean signed cert for +host+
|
55
60
|
def clean_cert(node)
|
56
|
-
if Puppet
|
57
|
-
|
58
|
-
|
59
|
-
Puppet.info _("%{node} certificates removed from ca") % { node: node }
|
61
|
+
if Puppet.features.puppetserver_ca?
|
62
|
+
require 'puppetserver/ca/action/clean'
|
63
|
+
Puppetserver::Ca::Action::Clean.new(LoggerIO.new).run({ 'certnames' => [node] })
|
60
64
|
else
|
61
65
|
Puppet.info _("Not managing %{node} certs as this host is not a CA") % { node: node }
|
62
66
|
end
|
@@ -14,28 +14,7 @@ Puppet.features.add(:posix) do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# We can use Microsoft Windows functions
|
17
|
-
Puppet.features.add(:microsoft_windows)
|
18
|
-
begin
|
19
|
-
# ruby
|
20
|
-
require 'Win32API' # case matters in this require!
|
21
|
-
|
22
|
-
# Note: Setting codepage here globally ensures all strings returned via
|
23
|
-
# WIN32OLE (Ruby's late-bound COM support) are encoded in Encoding::UTF_8
|
24
|
-
#
|
25
|
-
# Also, this does not modify the value of WIN32OLE.locale - which defaults
|
26
|
-
# to 2048 (at least on US English Windows) and is not listed in the MS
|
27
|
-
# locales table, here: https://msdn.microsoft.com/en-us/library/ms912047(v=winembedded.10).aspx
|
28
|
-
require 'win32ole' ; WIN32OLE.codepage = WIN32OLE::CP_UTF8
|
29
|
-
# gems
|
30
|
-
require 'win32/process'
|
31
|
-
require 'win32/dir'
|
32
|
-
require 'win32/service'
|
33
|
-
true
|
34
|
-
rescue LoadError => err
|
35
|
-
#TRANSLATORS "win32-process", "win32-dir", and "win32-service" are program names and should not be translated
|
36
|
-
warn _("Cannot run on Microsoft Windows without the win32-process, win32-dir and win32-service gems: %{err}") % { err: err } unless Puppet.features.posix?
|
37
|
-
end
|
38
|
-
end
|
17
|
+
Puppet.features.add(:microsoft_windows) { Puppet::Util::Platform.windows? }
|
39
18
|
|
40
19
|
raise Puppet::Error,_("Cannot determine basic system flavour") unless Puppet.features.posix? or Puppet.features.microsoft_windows?
|
41
20
|
|
@@ -49,7 +28,10 @@ Puppet.features.add(:usage, :libs => %w{rdoc/ri/ri_paths rdoc/usage})
|
|
49
28
|
Puppet.features.add(:libshadow, :libs => ["shadow"])
|
50
29
|
|
51
30
|
# We're running as root.
|
52
|
-
Puppet.features.add(:root)
|
31
|
+
Puppet.features.add(:root) do
|
32
|
+
require 'puppet/util/suidmanager'
|
33
|
+
Puppet::Util::SUIDManager.root?
|
34
|
+
end
|
53
35
|
|
54
36
|
# We have lcs diff
|
55
37
|
Puppet.features.add :diff, :libs => %w{diff/lcs diff/lcs/hunk}
|
@@ -90,3 +72,5 @@ Puppet.features.add(:manages_symlinks) do
|
|
90
72
|
WindowsSymlink.is_implemented
|
91
73
|
end
|
92
74
|
end
|
75
|
+
|
76
|
+
Puppet.features.add(:puppetserver_ca, libs: ['puppetserver/ca'])
|
@@ -24,7 +24,7 @@ class Puppet::FileServing::Base
|
|
24
24
|
full_path = File.join(path, relative_path)
|
25
25
|
end
|
26
26
|
|
27
|
-
if Puppet.
|
27
|
+
if Puppet::Util::Platform.windows?
|
28
28
|
# Replace multiple slashes as long as they aren't at the beginning of a filename
|
29
29
|
full_path.gsub(%r{(./)/+}, '\1')
|
30
30
|
else
|
@@ -81,6 +81,6 @@ class Puppet::FileServing::Base
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def self.absolute?(path)
|
84
|
-
Puppet::Util.absolute_path?(path, :posix)
|
84
|
+
Puppet::Util.absolute_path?(path, :posix) || (Puppet::Util::Platform.windows? && Puppet::Util.absolute_path?(path, :windows))
|
85
85
|
end
|
86
86
|
end
|
@@ -25,7 +25,7 @@ class Puppet::FileServing::Fileset
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def initialize(path, options = {})
|
28
|
-
if Puppet.
|
28
|
+
if Puppet::Util::Platform.windows?
|
29
29
|
# REMIND: UNC path
|
30
30
|
path = path.chomp(File::SEPARATOR) unless path =~ /^[A-Za-z]:\/$/
|
31
31
|
else
|
@@ -65,7 +65,7 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
|
|
65
65
|
end
|
66
66
|
|
67
67
|
class WindowsStat < MetaStat
|
68
|
-
if Puppet.
|
68
|
+
if Puppet::Util::Platform.windows?
|
69
69
|
require 'puppet/util/windows/security'
|
70
70
|
end
|
71
71
|
|
@@ -88,7 +88,7 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
|
|
88
88
|
def collect_stat(path)
|
89
89
|
stat = stat()
|
90
90
|
|
91
|
-
if Puppet.
|
91
|
+
if Puppet::Util::Platform.windows?
|
92
92
|
WindowsStat.new(stat, path, @source_permissions)
|
93
93
|
else
|
94
94
|
MetaStat.new(stat, @source_permissions)
|
@@ -385,6 +385,7 @@ module Puppet::Functions
|
|
385
385
|
end
|
386
386
|
end
|
387
387
|
|
388
|
+
|
388
389
|
# Public api methods of the DispatcherBuilder are available within dispatch()
|
389
390
|
# blocks declared in a Puppet::Function.create_function() call.
|
390
391
|
#
|
@@ -679,6 +680,128 @@ module Puppet::Functions
|
|
679
680
|
end
|
680
681
|
end
|
681
682
|
|
683
|
+
class Function3x < InternalFunction
|
684
|
+
|
685
|
+
# Table of optimized parameter names - 0 to 5 parameters
|
686
|
+
PARAM_NAMES = [
|
687
|
+
[],
|
688
|
+
['p0'.freeze].freeze,
|
689
|
+
['p0'.freeze, 'p1'.freeze].freeze,
|
690
|
+
['p0'.freeze, 'p1'.freeze, 'p2'.freeze].freeze,
|
691
|
+
['p0'.freeze, 'p1'.freeze, 'p2'.freeze, 'p3'.freeze].freeze,
|
692
|
+
['p0'.freeze, 'p1'.freeze, 'p2'.freeze, 'p3'.freeze, 'p4'.freeze].freeze,
|
693
|
+
]
|
694
|
+
|
695
|
+
# Creates an anonymous Function3x class that wraps a 3x function
|
696
|
+
#
|
697
|
+
# @api private
|
698
|
+
def self.create_function(func_name, func_info, loader)
|
699
|
+
func_name = func_name.to_s
|
700
|
+
|
701
|
+
# Creates an anonymous class to represent the function
|
702
|
+
# The idea being that it is garbage collected when there are no more
|
703
|
+
# references to it.
|
704
|
+
#
|
705
|
+
# (Do not give the class the block here, as instance variables should be set first)
|
706
|
+
the_class = Class.new(Function3x)
|
707
|
+
|
708
|
+
unless loader.nil?
|
709
|
+
the_class.instance_variable_set(:'@loader', loader.private_loader)
|
710
|
+
end
|
711
|
+
|
712
|
+
the_class.instance_variable_set(:'@func_name', func_name)
|
713
|
+
the_class.instance_variable_set(:'@method3x', :"function_#{func_name}")
|
714
|
+
|
715
|
+
# Make the anonymous class appear to have the class-name <func_name>
|
716
|
+
# Even if this class is not bound to such a symbol in a global ruby scope and
|
717
|
+
# must be resolved via the loader.
|
718
|
+
# This also overrides any attempt to define a name method in the given block
|
719
|
+
# (Since it redefines it)
|
720
|
+
#
|
721
|
+
the_class.instance_eval do
|
722
|
+
def name
|
723
|
+
@func_name
|
724
|
+
end
|
725
|
+
|
726
|
+
def loader
|
727
|
+
@loader
|
728
|
+
end
|
729
|
+
|
730
|
+
def method3x
|
731
|
+
@method3x
|
732
|
+
end
|
733
|
+
end
|
734
|
+
|
735
|
+
# Add the method that is called - it simply delegates to
|
736
|
+
# the 3.x function by calling it via the calling scope using the @method3x symbol
|
737
|
+
# :"function_#{name}".
|
738
|
+
#
|
739
|
+
# When function is not an rvalue function, make sure it produces nil
|
740
|
+
#
|
741
|
+
the_class.class_eval do
|
742
|
+
|
743
|
+
# Bypasses making the call via the dispatcher to make sure errors
|
744
|
+
# are reported exactly the same way as in 3x. The dispatcher is still needed as it is
|
745
|
+
# used to support other features than calling.
|
746
|
+
#
|
747
|
+
def call(scope, *args, &block)
|
748
|
+
begin
|
749
|
+
result = catch(:return) do
|
750
|
+
mapped_args = Puppet::Pops::Evaluator::Runtime3FunctionArgumentConverter.map_args(args, scope, '')
|
751
|
+
# this is the scope.function_xxx(...) call
|
752
|
+
return scope.send(self.class.method3x, mapped_args)
|
753
|
+
end
|
754
|
+
return result.value
|
755
|
+
rescue Puppet::Pops::Evaluator::Next => jumper
|
756
|
+
begin
|
757
|
+
throw :next, jumper.value
|
758
|
+
rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION
|
759
|
+
raise Puppet::ParseError.new("next() from context where this is illegal", jumper.file, jumper.line)
|
760
|
+
end
|
761
|
+
rescue Puppet::Pops::Evaluator::Return => jumper
|
762
|
+
begin
|
763
|
+
throw :return, jumper
|
764
|
+
rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION
|
765
|
+
raise Puppet::ParseError.new("return() from context where this is illegal", jumper.file, jumper.line)
|
766
|
+
end
|
767
|
+
end
|
768
|
+
end
|
769
|
+
end
|
770
|
+
|
771
|
+
# Create a dispatcher based on func_info
|
772
|
+
type, names = Puppet::Functions.any_signature(*from_to_names(func_info))
|
773
|
+
last_captures_rest = (type.size_range[1] == Float::INFINITY)
|
774
|
+
|
775
|
+
# The method '3x_function' here is a dummy as the dispatcher is not used for calling, only for information.
|
776
|
+
the_class.dispatcher.add(Puppet::Pops::Functions::Dispatch.new(type, '3x_function', names, last_captures_rest))
|
777
|
+
# The function class is returned as the result of the create function method
|
778
|
+
the_class
|
779
|
+
end
|
780
|
+
|
781
|
+
# Compute min and max number of arguments and a list of constructed
|
782
|
+
# parameter names p0 - pn (since there are no parameter names in 3x functions).
|
783
|
+
#
|
784
|
+
# @api private
|
785
|
+
def self.from_to_names(func_info)
|
786
|
+
arity = func_info[:arity]
|
787
|
+
if arity.nil?
|
788
|
+
arity = -1
|
789
|
+
end
|
790
|
+
if arity < 0
|
791
|
+
from = -arity - 1 # arity -1 is 0 min param, -2 is min 1 param
|
792
|
+
to = :default # infinite range
|
793
|
+
count = -arity # the number of named parameters
|
794
|
+
else
|
795
|
+
count = from = to = arity
|
796
|
+
end
|
797
|
+
# Names of parameters, up to 5 are optimized and use frozen version
|
798
|
+
# Note that (0..count-1) produces expected empty array for count == 0, 0-n for count >= 1
|
799
|
+
names = count <= 5 ? PARAM_NAMES[count] : (0..count-1).map {|n| "p#{n}" }
|
800
|
+
[from, to, names]
|
801
|
+
end
|
802
|
+
end
|
803
|
+
|
804
|
+
|
682
805
|
# Injection and Weaving of parameters
|
683
806
|
# ---
|
684
807
|
# It is possible to inject and weave a set of well known parameters into a call.
|
@@ -719,6 +842,16 @@ module Puppet::Functions
|
|
719
842
|
inject(:cache)
|
720
843
|
end
|
721
844
|
|
845
|
+
# Inject parameter for `Puppet::Pal::CatalogCompiler`
|
846
|
+
def compiler_param
|
847
|
+
inject(:pal_catalog_compiler)
|
848
|
+
end
|
849
|
+
|
850
|
+
# Inject parameter for either `Puppet::Pal::CatalogCompiler` or `Puppet::Pal::ScriptCompiler`
|
851
|
+
def pal_compiler_param
|
852
|
+
inject(:pal_compiler)
|
853
|
+
end
|
854
|
+
|
722
855
|
private
|
723
856
|
|
724
857
|
def inject(injection_name)
|
@@ -46,7 +46,7 @@ Puppet::Functions.create_function(:eyaml_lookup_key) do
|
|
46
46
|
path = options['path']
|
47
47
|
context.cached_file_data(path) do |content|
|
48
48
|
begin
|
49
|
-
data =
|
49
|
+
data = Puppet::Util::Yaml.safe_load(content, [Symbol], path)
|
50
50
|
if data.is_a?(Hash)
|
51
51
|
Puppet::Pops::Lookup::HieraConfig.symkeys_to_string(data)
|
52
52
|
else
|
@@ -55,10 +55,9 @@ Puppet::Functions.create_function(:eyaml_lookup_key) do
|
|
55
55
|
Puppet.warning(msg)
|
56
56
|
{}
|
57
57
|
end
|
58
|
-
rescue
|
59
|
-
#
|
60
|
-
|
61
|
-
raise Puppet::DataBinding::LookupError, "Unable to parse #{ex.message}"
|
58
|
+
rescue Puppet::Util::Yaml::YamlLoadError => ex
|
59
|
+
# YamlLoadErrors include the absolute path to the file, so no need to add that
|
60
|
+
raise Puppet::DataBinding::LookupError, _("Unable to parse %{message}") % { message: ex.message }
|
62
61
|
end
|
63
62
|
end
|
64
63
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Applies a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
|
2
2
|
# to every value in a data structure and returns an array or hash containing any elements
|
3
|
-
# for which the lambda evaluates to `
|
3
|
+
# for which the lambda evaluates to a truthy value (not `false` or `undef`).
|
4
4
|
#
|
5
5
|
# This function takes two mandatory arguments, in this order:
|
6
6
|
#
|
@@ -67,6 +67,7 @@
|
|
67
67
|
# ```
|
68
68
|
#
|
69
69
|
# @since 4.0.0
|
70
|
+
# @since 6.0.0 does not filter if truthy value is returned from block
|
70
71
|
#
|
71
72
|
Puppet::Functions.create_function(:filter) do
|
72
73
|
dispatch :filter_Hash_2 do
|
@@ -90,14 +91,14 @@ Puppet::Functions.create_function(:filter) do
|
|
90
91
|
end
|
91
92
|
|
92
93
|
def filter_Hash_1(hash)
|
93
|
-
result = hash.select {|x, y| yield([x, y])
|
94
|
+
result = hash.select {|x, y| yield([x, y]) }
|
94
95
|
# Ruby 1.8.7 returns Array
|
95
96
|
result = Hash[result] unless result.is_a? Hash
|
96
97
|
result
|
97
98
|
end
|
98
99
|
|
99
100
|
def filter_Hash_2(hash)
|
100
|
-
result = hash.select {|x, y| yield(x, y)
|
101
|
+
result = hash.select {|x, y| yield(x, y) }
|
101
102
|
# Ruby 1.8.7 returns Array
|
102
103
|
result = Hash[result] unless result.is_a? Hash
|
103
104
|
result
|
@@ -109,7 +110,7 @@ Puppet::Functions.create_function(:filter) do
|
|
109
110
|
begin
|
110
111
|
loop do
|
111
112
|
it = enum.next
|
112
|
-
if yield(it)
|
113
|
+
if yield(it)
|
113
114
|
result << it
|
114
115
|
end
|
115
116
|
end
|
@@ -122,7 +123,7 @@ Puppet::Functions.create_function(:filter) do
|
|
122
123
|
enum = Puppet::Pops::Types::Iterable.asserted_iterable(self, enumerable)
|
123
124
|
if enum.hash_style?
|
124
125
|
result = {}
|
125
|
-
enum.each { |k, v| result[k] = v if yield(k, v)
|
126
|
+
enum.each { |k, v| result[k] = v if yield(k, v) }
|
126
127
|
result
|
127
128
|
else
|
128
129
|
result = []
|
@@ -130,7 +131,7 @@ Puppet::Functions.create_function(:filter) do
|
|
130
131
|
index = 0
|
131
132
|
loop do
|
132
133
|
it = enum.next
|
133
|
-
if yield(index, it)
|
134
|
+
if yield(index, it)
|
134
135
|
result << it
|
135
136
|
end
|
136
137
|
index += 1
|