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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c52a68237c35477a0e8a18b0ac4114476eaf6c49a21d454d7d2ae25031db44c
|
4
|
+
data.tar.gz: 73502d5faa64ef267863c436aea928af45991b8571a280f87f3fbcd888a2132c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2bf04c7a4e6a5f72a7f92eb66f0937f5adb9767babf15639fbbe6f4b1b368996f2abeddfbc4a82e146124fce04282aecdf769a5475543b7b480e4fbf9865067
|
7
|
+
data.tar.gz: 96ace6cbf150ce44057a48f5e33571ebcc2255abecdf2ba70591b184776175ad8777a0dac6ffbef75740f60a84f92e205c3f915b5919d866b758bb64d0773523
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
|
+
require 'bolt/task'
|
4
5
|
|
5
6
|
Puppet::Functions.create_function(:apply_prep) do
|
6
7
|
dispatch :apply_prep do
|
@@ -12,8 +13,10 @@ Puppet::Functions.create_function(:apply_prep) do
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def run_task(executor, targets, name, args = {})
|
15
|
-
|
16
|
-
raise Bolt::Error.new("#{name} could not be found", 'bolt/apply-prep') unless
|
16
|
+
tasksig = script_compiler.task_signature(name)
|
17
|
+
raise Bolt::Error.new("#{name} could not be found", 'bolt/apply-prep') unless tasksig
|
18
|
+
|
19
|
+
task = Bolt::Task.new(tasksig.task_hash)
|
17
20
|
results = executor.run_task(targets, task, args)
|
18
21
|
raise Bolt::RunFailure.new(results, 'run_task', task.name) unless results.ok?
|
19
22
|
results
|
@@ -2,12 +2,16 @@
|
|
2
2
|
|
3
3
|
require 'bolt/error'
|
4
4
|
|
5
|
-
# Makes a query to puppetdb
|
5
|
+
# Makes a query to {https://puppet.com/docs/puppetdb/latest/index.html puppetdb}
|
6
|
+
# using Bolt's PuppetDB client.
|
6
7
|
Puppet::Functions.create_function(:puppetdb_query) do
|
8
|
+
# rubocop:disable Metrics/LineLength
|
7
9
|
# @param query A PQL query.
|
10
|
+
# {https://puppet.com/docs/puppetdb/latest/api/query/tutorial-pql.html Learn more about Puppet's query language, PQL}
|
8
11
|
# @return Results of the PuppetDB query.
|
9
12
|
# @example Request certnames for all nodes
|
10
13
|
# puppetdb_query('nodes[certname] {}')
|
14
|
+
# rubocop:enable Metrics/LineLength
|
11
15
|
dispatch :make_query do
|
12
16
|
param 'Variant[String, Array[Data]]', :query
|
13
17
|
return_type 'Array[Data]'
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'bolt/error'
|
4
4
|
require 'bolt/pal'
|
5
|
+
require 'bolt/task'
|
5
6
|
|
6
7
|
# Runs a given instance of a `Task` on the given set of targets and returns the result from each.
|
7
8
|
# This function does nothing if the list of targets is empty.
|
@@ -101,11 +102,7 @@ Puppet::Functions.create_function(:run_task) do
|
|
101
102
|
# and the local-validation option is set to false for all of them
|
102
103
|
if !targets.empty? && targets.all? { |t| t.protocol == 'pcp' && t.options['local-validation'] == false }
|
103
104
|
# create a fake task
|
104
|
-
task =
|
105
|
-
'name' => task_name,
|
106
|
-
'implementations' => [{ 'name' => '', 'path' => '' }],
|
107
|
-
'supports_noop' => true
|
108
|
-
)
|
105
|
+
task = Bolt::Task.new(name: task_name, files: [{ 'name' => '', 'path' => '' }])
|
109
106
|
else
|
110
107
|
# TODO: use the compiler injection once PUP-8237 lands
|
111
108
|
task_signature = Puppet::Pal::ScriptCompiler.new(closure_scope.compiler).task_signature(task_name)
|
@@ -117,7 +114,7 @@ Puppet::Functions.create_function(:run_task) do
|
|
117
114
|
raise with_stack(:TYPE_MISMATCH, mismatch_message)
|
118
115
|
end || (raise with_stack(:TYPE_MISMATCH, 'Task parameters do not match'))
|
119
116
|
|
120
|
-
task = task_signature.
|
117
|
+
task = Bolt::Task.new(task_signature.task_hash)
|
121
118
|
end
|
122
119
|
|
123
120
|
unless Puppet::Pops::Types::TypeFactory.data.instance?(use_args)
|
@@ -133,9 +130,9 @@ Puppet::Functions.create_function(:run_task) do
|
|
133
130
|
|
134
131
|
# Wrap parameters marked with '"sensitive": true' in the task metadata with a
|
135
132
|
# Sensitive wrapper type. This way it's not shown in logs.
|
136
|
-
if task.parameters
|
133
|
+
if (params = task.parameters)
|
137
134
|
use_args.each do |k, v|
|
138
|
-
if
|
135
|
+
if params[k] && params[k]['sensitive']
|
139
136
|
use_args[k] = Puppet::Pops::Types::PSensitiveType::Sensitive.new(v)
|
140
137
|
end
|
141
138
|
end
|
data/lib/bolt/applicator.rb
CHANGED
@@ -40,16 +40,18 @@ module Bolt
|
|
40
40
|
def custom_facts_task
|
41
41
|
@custom_facts_task ||= begin
|
42
42
|
path = File.join(libexec, 'custom_facts.rb')
|
43
|
-
|
44
|
-
|
43
|
+
file = { 'name' => 'custom_facts.rb', 'path' => path }
|
44
|
+
metadata = { 'supports_noop' => true, 'input_method' => 'stdin' }
|
45
|
+
Bolt::Task.new(name: 'apply_helpers::custom_facts', files: [file], metadata: metadata)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
49
|
def catalog_apply_task
|
49
50
|
@catalog_apply_task ||= begin
|
50
51
|
path = File.join(libexec, 'apply_catalog.rb')
|
51
|
-
|
52
|
-
|
52
|
+
file = { 'name' => 'apply_catalog.rb', 'path' => path }
|
53
|
+
metadata = { 'supports_noop' => true, 'input_method' => 'stdin' }
|
54
|
+
Bolt::Task.new(name: 'apply_helpers::apply_catalog', files: [file], metadata: metadata)
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
@@ -103,7 +105,7 @@ module Bolt
|
|
103
105
|
|
104
106
|
def validate_hiera_config(hiera_config)
|
105
107
|
if File.exist?(File.path(hiera_config))
|
106
|
-
data = File.open(File.path(hiera_config), "r:UTF-8") { |f| YAML.safe_load(f.read) }
|
108
|
+
data = File.open(File.path(hiera_config), "r:UTF-8") { |f| YAML.safe_load(f.read, [Symbol]) }
|
107
109
|
unless data['version'] == 5
|
108
110
|
raise Bolt::ParseError, "Hiera v5 is required, found v#{data['version'] || 3} in #{hiera_config}"
|
109
111
|
end
|
@@ -197,9 +199,10 @@ module Bolt
|
|
197
199
|
@executor.with_node_logging("Applying manifest block", batch) do
|
198
200
|
arguments = { 'catalog' => future.value, 'plugins' => plugins, '_noop' => options['_noop'] }
|
199
201
|
raise future.reason if future.rejected?
|
200
|
-
|
201
|
-
|
202
|
-
|
202
|
+
results = transport.batch_task(batch, catalog_apply_task, arguments, options, ¬ify)
|
203
|
+
Array(results).map do |result|
|
204
|
+
identify_resource_failures(provide_puppet_missing_errors(result))
|
205
|
+
end
|
203
206
|
end
|
204
207
|
end
|
205
208
|
end
|
data/lib/bolt/boltdir.rb
CHANGED
@@ -12,13 +12,21 @@ module Bolt
|
|
12
12
|
Boltdir.new(File.join('~', '.puppetlabs', 'bolt'))
|
13
13
|
end
|
14
14
|
|
15
|
+
# Search recursively up the directory hierarchy for the Boltdir. Look for a
|
16
|
+
# directory called Boltdir or a file called bolt.yaml (for a control repo
|
17
|
+
# type Boltdir). Otherwise, repeat the check on each directory up the
|
18
|
+
# hierarchy, falling back to the default if we reach the root.
|
15
19
|
def self.find_boltdir(dir)
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
dir = Pathname.new(dir)
|
21
|
+
if (dir + BOLTDIR_NAME).directory?
|
22
|
+
new(dir + BOLTDIR_NAME)
|
23
|
+
elsif (dir + 'bolt.yaml').file?
|
24
|
+
new(dir)
|
25
|
+
elsif dir.root?
|
26
|
+
default_boltdir
|
27
|
+
else
|
28
|
+
find_boltdir(dir.parent)
|
19
29
|
end
|
20
|
-
|
21
|
-
local_boltdir || default_boltdir
|
22
30
|
end
|
23
31
|
|
24
32
|
def initialize(path)
|
data/lib/bolt/catalog.rb
CHANGED
@@ -5,13 +5,11 @@ require 'bolt/puppetdb'
|
|
5
5
|
|
6
6
|
Bolt::PAL.load_puppet
|
7
7
|
|
8
|
-
require 'bolt/catalog/compiler'
|
9
|
-
require 'bolt/catalog/loaders'
|
10
8
|
require 'bolt/catalog/logging'
|
11
9
|
|
12
10
|
module Bolt
|
13
11
|
class Catalog
|
14
|
-
def with_puppet_settings(hiera_config)
|
12
|
+
def with_puppet_settings(hiera_config = {})
|
15
13
|
Dir.mktmpdir('bolt') do |dir|
|
16
14
|
cli = []
|
17
15
|
Puppet::Settings::REQUIRED_APP_SETTINGS.each do |setting|
|
@@ -28,30 +26,15 @@ module Bolt
|
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
31
|
-
def setup_node(node, trusted)
|
32
|
-
facts = Puppet.lookup(:pal_facts)
|
33
|
-
node_facts = Puppet::Node::Facts.new(Puppet[:node_name_value], facts)
|
34
|
-
node.fact_merge(node_facts)
|
35
|
-
|
36
|
-
node.parameters = node.parameters.merge(Puppet.lookup(:pal_variables))
|
37
|
-
node.trusted_data = trusted
|
38
|
-
end
|
39
|
-
|
40
|
-
def compile_node(node)
|
41
|
-
# Add boltlib to system loaders so modules can use its functions without an
|
42
|
-
# explicit dependency.
|
43
|
-
node.environment.loaders = Bolt::Catalog::BoltLoaders.new(node.environment)
|
44
|
-
|
45
|
-
compiler = Puppet::Parser::BoltCompiler.new(node)
|
46
|
-
compiler.compile(&:to_resource)
|
47
|
-
end
|
48
|
-
|
49
29
|
def generate_ast(code)
|
50
30
|
with_puppet_settings do
|
51
|
-
Puppet::Pal.in_tmp_environment("bolt_parse") do |
|
52
|
-
|
53
|
-
|
54
|
-
|
31
|
+
Puppet::Pal.in_tmp_environment("bolt_parse") do |pal|
|
32
|
+
pal.with_catalog_compiler do |compiler|
|
33
|
+
ast = compiler.parse_string(code)
|
34
|
+
Puppet::Pops::Serialization::ToDataConverter.convert(ast,
|
35
|
+
rich_data: true,
|
36
|
+
symbol_to_string: true)
|
37
|
+
end
|
55
38
|
end
|
56
39
|
end
|
57
40
|
end
|
@@ -69,32 +52,24 @@ module Bolt
|
|
69
52
|
def compile_catalog(request)
|
70
53
|
pal_main = request['code_ast'] || request['code_string']
|
71
54
|
target = request['target']
|
72
|
-
|
73
55
|
pdb_client = Bolt::PuppetDB::Client.new(Bolt::PuppetDB::Config.new(request['pdb_config']))
|
74
56
|
|
75
57
|
with_puppet_settings(request['hiera_config']) do
|
76
|
-
Puppet[:
|
58
|
+
Puppet[:rich_data] = true
|
77
59
|
Puppet[:node_name_value] = target['name']
|
78
|
-
Puppet::Pal.in_tmp_environment(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
setup_node(node, target["trusted"])
|
92
|
-
|
93
|
-
Puppet.override(pal_main: pal_main,
|
94
|
-
bolt_pdb_client: pdb_client,
|
95
|
-
bolt_inventory:
|
96
|
-
setup_inventory(request['inventory'])) do
|
97
|
-
compile_node(node)
|
60
|
+
Puppet::Pal.in_tmp_environment('bolt_catalog',
|
61
|
+
modulepath: request["modulepath"] || [],
|
62
|
+
facts: target["facts"] || {},
|
63
|
+
variables: target["variables"] || {}) do |pal|
|
64
|
+
Puppet.override(bolt_pdb_client: pdb_client,
|
65
|
+
bolt_inventory: setup_inventory(request['inventory'])) do
|
66
|
+
Puppet.lookup(:pal_current_node).trusted_data = target['trusted']
|
67
|
+
pal.with_catalog_compiler do |compiler|
|
68
|
+
ast = Puppet::Pops::Serialization::FromDataConverter.convert(pal_main)
|
69
|
+
compiler.evaluate(ast)
|
70
|
+
compiler.compile_additions
|
71
|
+
compiler.with_json_encoding(&:encode)
|
72
|
+
end
|
98
73
|
end
|
99
74
|
end
|
100
75
|
end
|
data/lib/bolt/config.rb
CHANGED
@@ -60,17 +60,7 @@ module Bolt
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def self.from_boltdir(boltdir, overrides = {})
|
63
|
-
|
64
|
-
# config if that isn't found. Because logging is built in to the
|
65
|
-
# legacy_conf method, we don't want to look that up unless we need it.
|
66
|
-
configs = if boltdir.config_file.exist?
|
67
|
-
[boltdir.config_file]
|
68
|
-
else
|
69
|
-
[legacy_conf]
|
70
|
-
end
|
71
|
-
|
72
|
-
data = Bolt::Util.read_config_file(nil, configs, 'config') || {}
|
73
|
-
|
63
|
+
data = Bolt::Util.read_config_file(nil, [boltdir.config_file], 'config') || {}
|
74
64
|
new(boltdir, data, overrides)
|
75
65
|
end
|
76
66
|
|
@@ -174,21 +164,6 @@ module Bolt
|
|
174
164
|
end
|
175
165
|
private :update_from_file
|
176
166
|
|
177
|
-
# TODO: This is deprecated in 0.21.0 and can be removed in release 0.22.0.
|
178
|
-
def self.legacy_conf
|
179
|
-
root_path = File.expand_path(File.join('~', '.puppetlabs'))
|
180
|
-
legacy_paths = [File.join(root_path, 'bolt.yaml'), File.join(root_path, 'bolt.yml')]
|
181
|
-
legacy_conf = legacy_paths.find { |path| File.exist?(path) }
|
182
|
-
found_legacy_conf = !!legacy_conf
|
183
|
-
legacy_conf ||= legacy_paths[0]
|
184
|
-
if found_legacy_conf
|
185
|
-
correct_path = Bolt::Boltdir.default_boltdir.config_file
|
186
|
-
msg = "Found configfile at deprecated location #{legacy_conf}. Global config should be in #{correct_path}"
|
187
|
-
Logging.logger[self].warn(msg)
|
188
|
-
end
|
189
|
-
legacy_conf
|
190
|
-
end
|
191
|
-
|
192
167
|
def apply_overrides(options)
|
193
168
|
%i[concurrency transport format trace modulepath inventoryfile color].each do |key|
|
194
169
|
send("#{key}=", options[key]) if options.key?(key)
|
data/lib/bolt/executor.rb
CHANGED
@@ -224,7 +224,7 @@ module Bolt
|
|
224
224
|
arguments['_task'] = task.name
|
225
225
|
|
226
226
|
results = batch_execute(targets) do |transport, batch|
|
227
|
-
with_node_logging("Running task #{task.name} with '#{arguments}'
|
227
|
+
with_node_logging("Running task #{task.name} with '#{arguments}'", batch) do
|
228
228
|
transport.batch_task(batch, task, arguments, options, ¬ify)
|
229
229
|
end
|
230
230
|
end
|
data/lib/bolt/outputter.rb
CHANGED
@@ -18,15 +18,6 @@ module Bolt
|
|
18
18
|
@trace = trace
|
19
19
|
@stream = stream
|
20
20
|
end
|
21
|
-
|
22
|
-
# This method replaces data types tha have the name 'Data'
|
23
|
-
# with the string 'Any'
|
24
|
-
# This was a problem when using 'bolt task show <task_name>'
|
25
|
-
def replace_data_type(params)
|
26
|
-
params.map do |_, v|
|
27
|
-
v['type'] = 'Any' if v['type'].to_s == 'Data'
|
28
|
-
end
|
29
|
-
end
|
30
21
|
end
|
31
22
|
end
|
32
23
|
|
data/lib/bolt/outputter/human.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'terminal-table'
|
4
|
+
require 'bolt/pal'
|
5
|
+
|
4
6
|
module Bolt
|
5
7
|
class Outputter
|
6
8
|
class Human < Bolt::Outputter
|
@@ -119,26 +121,31 @@ module Bolt
|
|
119
121
|
task_info = +""
|
120
122
|
usage = +"bolt task run --nodes <node-name> #{task['name']}"
|
121
123
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
" #{k}=<value>"
|
131
|
-
end
|
132
|
-
end
|
124
|
+
task['metadata']['parameters']&.each do |k, v|
|
125
|
+
pretty_params << "- #{k}: #{v['type'] || 'Any'}\n"
|
126
|
+
pretty_params << " #{v['description']}\n" if v['description']
|
127
|
+
usage << if v['type'].is_a?(Puppet::Pops::Types::POptionalType)
|
128
|
+
" [#{k}=<value>]"
|
129
|
+
else
|
130
|
+
" #{k}=<value>"
|
131
|
+
end
|
133
132
|
end
|
134
133
|
|
135
|
-
usage << " [--noop]" if task['supports_noop']
|
134
|
+
usage << " [--noop]" if task['metadata']['supports_noop']
|
136
135
|
|
137
136
|
task_info << "\n#{task['name']}"
|
138
|
-
task_info << " - #{task['description']}" if task['description']
|
137
|
+
task_info << " - #{task['metadata']['description']}" if task['metadata']['description']
|
139
138
|
task_info << "\n\n"
|
140
139
|
task_info << "USAGE:\n#{usage}\n\n"
|
141
|
-
task_info << "PARAMETERS:\n#{pretty_params}\n"
|
140
|
+
task_info << "PARAMETERS:\n#{pretty_params}\n" unless pretty_params.empty?
|
141
|
+
task_info << "MODULE:\n"
|
142
|
+
|
143
|
+
path = task['files'][0]['path'].chomp("/tasks/#{task['files'][0]['name']}")
|
144
|
+
task_info << if path.start_with?(Bolt::PAL::MODULES_PATH)
|
145
|
+
"built-in module"
|
146
|
+
else
|
147
|
+
path
|
148
|
+
end
|
142
149
|
@stream.puts(task_info)
|
143
150
|
end
|
144
151
|
|
@@ -158,6 +165,14 @@ module Bolt
|
|
158
165
|
plan_info << "\n\n"
|
159
166
|
plan_info << "USAGE:\n#{usage}\n\n"
|
160
167
|
plan_info << "PARAMETERS:\n#{pretty_params}\n" if plan['parameters']
|
168
|
+
plan_info << "MODULE:\n"
|
169
|
+
|
170
|
+
path = plan['module']
|
171
|
+
plan_info << if path.start_with?(Bolt::PAL::MODULES_PATH)
|
172
|
+
"built-in module"
|
173
|
+
else
|
174
|
+
path
|
175
|
+
end
|
161
176
|
@stream.puts(plan_info)
|
162
177
|
end
|
163
178
|
|
data/lib/bolt/outputter/json.rb
CHANGED
@@ -44,11 +44,22 @@ module Bolt
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def print_task_info(task)
|
47
|
-
|
47
|
+
path = task['files'][0]['path'].chomp("/tasks/#{task['files'][0]['name']}")
|
48
|
+
task['module_dir'] = if path.start_with?(Bolt::PAL::MODULES_PATH)
|
49
|
+
"built-in module"
|
50
|
+
else
|
51
|
+
path
|
52
|
+
end
|
48
53
|
@stream.puts task.to_json
|
49
54
|
end
|
50
55
|
|
51
56
|
def print_plan_info(plan)
|
57
|
+
path = plan.delete('module')
|
58
|
+
plan['module_dir'] = if path.start_with?(Bolt::PAL::MODULES_PATH)
|
59
|
+
"built-in module"
|
60
|
+
else
|
61
|
+
path
|
62
|
+
end
|
52
63
|
@stream.puts plan.to_json
|
53
64
|
end
|
54
65
|
|
data/lib/bolt/pal.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'bolt/applicator'
|
3
4
|
require 'bolt/executor'
|
4
5
|
require 'bolt/error'
|
5
6
|
require 'bolt/plan_result'
|
6
7
|
require 'bolt/util'
|
7
|
-
require 'bolt/applicator'
|
8
8
|
|
9
9
|
module Bolt
|
10
10
|
class PAL
|
@@ -182,7 +182,7 @@ module Bolt
|
|
182
182
|
tasks = compiler.list_tasks
|
183
183
|
tasks.map(&:name).sort.map do |task_name|
|
184
184
|
task_sig = compiler.task_signature(task_name)
|
185
|
-
[task_name, task_sig.
|
185
|
+
[task_name, task_sig.task_hash['metadata']['description']]
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|
@@ -190,15 +190,15 @@ module Bolt
|
|
190
190
|
def parse_params(type, object_name, params)
|
191
191
|
in_bolt_compiler do |compiler|
|
192
192
|
if type == 'task'
|
193
|
-
param_spec = compiler.task_signature(object_name)&.task_hash
|
193
|
+
param_spec = compiler.task_signature(object_name)&.task_hash&.dig('parameters')
|
194
194
|
elsif type == 'plan'
|
195
195
|
plan = compiler.plan_signature(object_name)
|
196
|
-
param_spec =
|
196
|
+
param_spec = plan.params_type.elements&.each_with_object({}) { |t, h| h[t.name] = t.value_type } if plan
|
197
197
|
end
|
198
198
|
param_spec ||= {}
|
199
199
|
|
200
200
|
params.each_with_object({}) do |(name, str), acc|
|
201
|
-
type = param_spec
|
201
|
+
type = param_spec[name]
|
202
202
|
begin
|
203
203
|
parsed = JSON.parse(str, quirks_mode: true)
|
204
204
|
# The type may not exist if the module is remote on orch or if a task
|
@@ -227,7 +227,7 @@ module Bolt
|
|
227
227
|
raise Bolt::Error.new(Bolt::Error.unknown_task(task_name), 'bolt/unknown-task')
|
228
228
|
end
|
229
229
|
|
230
|
-
task.task_hash
|
230
|
+
task.task_hash.reject { |k, _| k == 'parameters' }
|
231
231
|
end
|
232
232
|
|
233
233
|
def list_plans
|
@@ -236,9 +236,8 @@ module Bolt
|
|
236
236
|
end
|
237
237
|
end
|
238
238
|
|
239
|
-
# This converts a plan signature object into a format
|
240
|
-
#
|
241
|
-
# to pickup type aliases used in the plan signature.
|
239
|
+
# This converts a plan signature object into a format used by the outputter.
|
240
|
+
# Must be called from within bolt compiler to pickup type aliases used in the plan signature.
|
242
241
|
def plan_hash(plan_name, plan)
|
243
242
|
elements = plan.params_type.elements || []
|
244
243
|
parameters = elements.each_with_object({}) do |param, acc|
|
@@ -250,11 +249,14 @@ module Bolt
|
|
250
249
|
'parameters' => parameters
|
251
250
|
}
|
252
251
|
end
|
252
|
+
private :plan_hash
|
253
253
|
|
254
254
|
def get_plan_info(plan_name)
|
255
255
|
plan_info = in_bolt_compiler do |compiler|
|
256
256
|
plan = compiler.plan_signature(plan_name)
|
257
|
-
plan_hash(plan_name, plan) if plan
|
257
|
+
hash = plan_hash(plan_name, plan) if plan
|
258
|
+
hash['module'] = plan.instance_variable_get(:@plan_func).loader.parent.path if plan
|
259
|
+
hash
|
258
260
|
end
|
259
261
|
|
260
262
|
if plan_info.nil?
|