bolt 0.15.0 → 0.16.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/lib/bolt/cli.rb +30 -131
- data/lib/bolt/config.rb +35 -9
- data/lib/bolt/executor.rb +33 -7
- data/lib/bolt/node.rb +19 -2
- data/lib/bolt/node/orch.rb +4 -4
- data/lib/bolt/node/ssh.rb +46 -21
- data/lib/bolt/node/winrm.rb +12 -23
- data/lib/bolt/outputter.rb +9 -0
- data/lib/bolt/outputter/human.rb +33 -4
- data/lib/bolt/outputter/json.rb +6 -1
- data/lib/bolt/pal.rb +87 -20
- data/lib/bolt/version.rb +1 -1
- data/modules/boltlib/lib/puppet/functions/run_command.rb +1 -1
- data/modules/boltlib/lib/puppet/functions/run_plan.rb +18 -1
- data/modules/boltlib/lib/puppet/functions/run_script.rb +1 -1
- data/modules/boltlib/lib/puppet/functions/run_task.rb +2 -1
- data/vendored/facter/lib/facter/virtual.rb +2 -0
- data/vendored/hiera/lib/hiera/config.rb +2 -2
- data/vendored/hiera/lib/hiera/version.rb +1 -1
- data/vendored/puppet/lib/hiera/puppet_function.rb +5 -2
- data/vendored/puppet/lib/hiera_puppet.rb +3 -3
- data/vendored/puppet/lib/puppet/agent/locker.rb +6 -5
- data/vendored/puppet/lib/puppet/application/filebucket.rb +23 -6
- data/vendored/puppet/lib/puppet/daemon.rb +2 -2
- data/vendored/puppet/lib/puppet/defaults.rb +42 -10
- data/vendored/puppet/lib/puppet/error.rb +5 -15
- data/vendored/puppet/lib/puppet/external/pson/common.rb +2 -2
- data/vendored/puppet/lib/puppet/face/module/build.rb +1 -0
- data/vendored/puppet/lib/puppet/face/module/install.rb +1 -0
- data/vendored/puppet/lib/puppet/face/module/search.rb +2 -1
- data/vendored/puppet/lib/puppet/face/module/uninstall.rb +1 -0
- data/vendored/puppet/lib/puppet/face/module/upgrade.rb +1 -0
- data/vendored/puppet/lib/puppet/file_bucket/dipper.rb +1 -1
- data/vendored/puppet/lib/puppet/file_serving/base.rb +2 -1
- data/vendored/puppet/lib/puppet/file_serving/configuration/parser.rb +21 -9
- data/vendored/puppet/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/vendored/puppet/lib/puppet/forge.rb +2 -1
- data/vendored/puppet/lib/puppet/functions/binary_file.rb +1 -0
- data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
- data/vendored/puppet/lib/puppet/functions/module_directory.rb +41 -0
- data/vendored/puppet/lib/puppet/functions/strftime.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/unique.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/yaml_data.rb +1 -1
- data/vendored/puppet/lib/puppet/gettext/config.rb +10 -5
- data/vendored/puppet/lib/puppet/graph/relationship_graph.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/exec.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/facts/facter.rb +3 -3
- data/vendored/puppet/lib/puppet/indirector/facts/network_device.rb +2 -2
- data/vendored/puppet/lib/puppet/indirector/file_bucket_file/file.rb +10 -3
- data/vendored/puppet/lib/puppet/indirector/indirection.rb +17 -9
- data/vendored/puppet/lib/puppet/indirector/ldap.rb +2 -2
- data/vendored/puppet/lib/puppet/indirector/node/write_only_yaml.rb +3 -1
- data/vendored/puppet/lib/puppet/indirector/rest.rb +2 -1
- data/vendored/puppet/lib/puppet/indirector/ssl_file.rb +2 -2
- data/vendored/puppet/lib/puppet/indirector/terminus.rb +3 -3
- data/vendored/puppet/lib/puppet/interface.rb +1 -1
- data/vendored/puppet/lib/puppet/interface/action.rb +41 -24
- data/vendored/puppet/lib/puppet/interface/action_builder.rb +14 -5
- data/vendored/puppet/lib/puppet/interface/action_manager.rb +1 -1
- data/vendored/puppet/lib/puppet/interface/documentation.rb +21 -10
- data/vendored/puppet/lib/puppet/interface/face_collection.rb +4 -2
- data/vendored/puppet/lib/puppet/interface/option.rb +36 -15
- data/vendored/puppet/lib/puppet/interface/option_builder.rb +23 -9
- data/vendored/puppet/lib/puppet/interface/option_manager.rb +8 -3
- data/vendored/puppet/lib/puppet/metatype/manager.rb +7 -3
- data/vendored/puppet/lib/puppet/module.rb +2 -1
- data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +4 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +3 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +3 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +3 -0
- data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +3 -3
- data/vendored/puppet/lib/puppet/network/auth_config_parser.rb +10 -5
- data/vendored/puppet/lib/puppet/network/authstore.rb +2 -2
- data/vendored/puppet/lib/puppet/network/client_request.rb +1 -1
- data/vendored/puppet/lib/puppet/network/format.rb +3 -3
- data/vendored/puppet/lib/puppet/network/http/api/indirection_type.rb +1 -1
- data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +5 -2
- data/vendored/puppet/lib/puppet/network/http/webrick.rb +1 -3
- data/vendored/puppet/lib/puppet/node.rb +16 -7
- data/vendored/puppet/lib/puppet/parameter.rb +3 -3
- data/vendored/puppet/lib/puppet/parameter/value_collection.rb +5 -2
- data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/ast/node.rb +2 -2
- data/vendored/puppet/lib/puppet/parser/compiler.rb +6 -5
- data/vendored/puppet/lib/puppet/parser/functions.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/fqdn_rand.rb +6 -2
- data/vendored/puppet/lib/puppet/parser/functions/generate.rb +2 -4
- data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +1 -2
- data/vendored/puppet/lib/puppet/parser/functions/sha256.rb +5 -0
- data/vendored/puppet/lib/puppet/parser/functions/template.rb +6 -2
- data/vendored/puppet/lib/puppet/parser/resource.rb +18 -91
- data/vendored/puppet/lib/puppet/parser/scope.rb +12 -11
- data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/collector_transformer.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/epp_evaluator.rb +21 -8
- data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_converter.rb +3 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +5 -6
- data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/functions/function.rb +8 -2
- data/vendored/puppet/lib/puppet/pops/issue_reporter.rb +7 -2
- data/vendored/puppet/lib/puppet/pops/issues.rb +14 -4
- data/vendored/puppet/lib/puppet/pops/label_provider.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/loader/base_loader.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/dependency_loader.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/loader.rb +6 -1
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +27 -6
- data/vendored/puppet/lib/puppet/pops/loader/runtime3_type_loader.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/loaders.rb +7 -3
- data/vendored/puppet/lib/puppet/pops/lookup/explainer.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/merge_strategy.rb +6 -3
- data/vendored/puppet/lib/puppet/pops/migration/migration_checker.rb +8 -8
- data/vendored/puppet/lib/puppet/pops/model/factory.rb +4 -2
- data/vendored/puppet/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/serialization/abstract_writer.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +6 -2
- data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +36 -15
- data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +3 -1
- data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +4 -1
- data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +75 -7
- data/vendored/puppet/lib/puppet/pops/types/types.rb +9 -5
- data/vendored/puppet/lib/puppet/pops/validation.rb +14 -12
- data/vendored/puppet/lib/puppet/property.rb +14 -6
- data/vendored/puppet/lib/puppet/property/ensure.rb +2 -2
- data/vendored/puppet/lib/puppet/provider.rb +4 -4
- data/vendored/puppet/lib/puppet/provider/group/aix.rb +4 -2
- data/vendored/puppet/lib/puppet/provider/group/groupadd.rb +25 -1
- data/vendored/puppet/lib/puppet/provider/ldap.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/naginator.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/nameservice.rb +7 -4
- data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +4 -3
- data/vendored/puppet/lib/puppet/provider/nameservice/objectadd.rb +13 -24
- data/vendored/puppet/lib/puppet/provider/nameservice/pw.rb +14 -14
- data/vendored/puppet/lib/puppet/provider/package/aix.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/pkg.rb +3 -2
- data/vendored/puppet/lib/puppet/provider/package/yum.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/parsedfile.rb +4 -4
- data/vendored/puppet/lib/puppet/provider/service/base.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/service/launchd.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/service/runit.rb +2 -1
- data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -0
- data/vendored/puppet/lib/puppet/provider/service/upstart.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/user/aix.rb +13 -6
- data/vendored/puppet/lib/puppet/provider/user/openbsd.rb +2 -1
- data/vendored/puppet/lib/puppet/provider/user/useradd.rb +33 -4
- data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +2 -1
- data/vendored/puppet/lib/puppet/provider/zone/solaris.rb +2 -2
- data/vendored/puppet/lib/puppet/relationship.rb +2 -1
- data/vendored/puppet/lib/puppet/reports/store.rb +1 -1
- data/vendored/puppet/lib/puppet/resource.rb +7 -5
- data/vendored/puppet/lib/puppet/resource/capability_finder.rb +14 -11
- data/vendored/puppet/lib/puppet/resource/catalog.rb +33 -18
- data/vendored/puppet/lib/puppet/resource/type.rb +5 -5
- data/vendored/puppet/lib/puppet/settings.rb +19 -13
- data/vendored/puppet/lib/puppet/settings/base_setting.rb +23 -8
- data/vendored/puppet/lib/puppet/settings/config_file.rb +14 -4
- data/vendored/puppet/lib/puppet/settings/environment_conf.rb +5 -7
- data/vendored/puppet/lib/puppet/settings/ini_file.rb +4 -0
- data/vendored/puppet/lib/puppet/ssl/base.rb +9 -4
- data/vendored/puppet/lib/puppet/ssl/oids.rb +8 -2
- data/vendored/puppet/lib/puppet/transaction.rb +6 -2
- data/vendored/puppet/lib/puppet/transaction/persistence.rb +15 -0
- data/vendored/puppet/lib/puppet/transaction/report.rb +9 -1
- data/vendored/puppet/lib/puppet/type.rb +26 -26
- data/vendored/puppet/lib/puppet/type/file.rb +2 -1
- data/vendored/puppet/lib/puppet/type/file/data_sync.rb +2 -1
- data/vendored/puppet/lib/puppet/type/file/source.rb +1 -1
- data/vendored/puppet/lib/puppet/type/group.rb +4 -1
- data/vendored/puppet/lib/puppet/type/mount.rb +1 -1
- data/vendored/puppet/lib/puppet/type/resources.rb +1 -1
- data/vendored/puppet/lib/puppet/type/user.rb +12 -7
- data/vendored/puppet/lib/puppet/type/zone.rb +1 -1
- data/vendored/puppet/lib/puppet/util.rb +15 -21
- data/vendored/puppet/lib/puppet/util/at_fork/solaris.rb +6 -4
- data/vendored/puppet/lib/puppet/util/command_line/trollop.rb +6 -5
- data/vendored/puppet/lib/puppet/util/errors.rb +59 -8
- data/vendored/puppet/lib/puppet/util/fileparsing.rb +3 -5
- data/vendored/puppet/lib/puppet/util/http_proxy.rb +14 -6
- data/vendored/puppet/lib/puppet/util/instance_loader.rb +1 -3
- data/vendored/puppet/lib/puppet/util/ldap/manager.rb +6 -3
- data/vendored/puppet/lib/puppet/util/log.rb +15 -21
- data/vendored/puppet/lib/puppet/util/logging.rb +21 -28
- data/vendored/puppet/lib/puppet/util/methodhelper.rb +1 -1
- data/vendored/puppet/lib/puppet/util/nagios_maker.rb +1 -1
- data/vendored/puppet/lib/puppet/util/network_device/config.rb +20 -13
- data/vendored/puppet/lib/puppet/util/platform.rb +13 -0
- data/vendored/puppet/lib/puppet/util/posix.rb +1 -1
- data/vendored/puppet/lib/puppet/util/provider_features.rb +1 -1
- data/vendored/puppet/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
- data/vendored/puppet/lib/puppet/util/selinux.rb +1 -1
- data/vendored/puppet/lib/puppet/util/windows/eventlog.rb +10 -5
- data/vendored/puppet/lib/puppet/util/windows/file.rb +61 -9
- data/vendored/puppet/lib/puppet/util/windows/process.rb +1 -1
- data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +2 -2
- data/vendored/puppet/lib/puppet/version.rb +1 -1
- data/vendored/puppet/lib/puppet_pal.rb +23 -22
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8583fc13483530b30cda78e12c42f207e07995d7
|
4
|
+
data.tar.gz: 13ec2527cf65cac99c03e7db2bf718279c289751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3dcfd21a5279b2fdf9fa35b66ed39f7207674a8d0cfe284bea12990fec93c294159638a88b93544d7a5818a0c093bb2d07595509ce8e1f6211ed6d587f381de
|
7
|
+
data.tar.gz: e823df525ff7ef1c0726af8a9d17482df286a0fc3f3fb0088a4b6aa48667fb0fa556b4ea188ad24837bdd293057d8046b07f300317ca72371c8e074d1b6b4688
|
data/lib/bolt/cli.rb
CHANGED
@@ -11,6 +11,7 @@ require 'bolt/executor'
|
|
11
11
|
require 'bolt/target'
|
12
12
|
require 'bolt/outputter'
|
13
13
|
require 'bolt/config'
|
14
|
+
require 'bolt/pal'
|
14
15
|
require 'io/console'
|
15
16
|
|
16
17
|
module Bolt
|
@@ -34,6 +35,7 @@ Available subcommands:
|
|
34
35
|
bolt task show <task> Show documentation for task
|
35
36
|
bolt task run <task> [params] Run a Puppet task
|
36
37
|
bolt plan show Show list of available plans
|
38
|
+
bolt plan show <plan> Show details for plan
|
37
39
|
bolt plan run <plan> [params] Run a Puppet task plan
|
38
40
|
bolt file upload <src> <dest> Upload a local file
|
39
41
|
|
@@ -45,6 +47,7 @@ Usage: bolt task <action> <task> [options] [parameters]
|
|
45
47
|
|
46
48
|
Available actions are:
|
47
49
|
show Show list of available tasks
|
50
|
+
show <task> Show documentation for task
|
48
51
|
run Run a Puppet task
|
49
52
|
|
50
53
|
Parameters are of the form <parameter>=<value>.
|
@@ -75,6 +78,7 @@ Usage: bolt plan <action> <plan> [options] [parameters]
|
|
75
78
|
|
76
79
|
Available actions are:
|
77
80
|
show Show list of available plans
|
81
|
+
show <plan> Show details for plan
|
78
82
|
run Run a Puppet task plan
|
79
83
|
|
80
84
|
Parameters are of the form <parameter>=<value>.
|
@@ -130,7 +134,7 @@ HELP
|
|
130
134
|
'* Windows nodes must specify protocol with winrm://',
|
131
135
|
'* protocol is `ssh` by default, may be `ssh` or `winrm`',
|
132
136
|
'* port defaults to `22` for SSH',
|
133
|
-
'* port defaults to `5985` or `5986` for WinRM, based on the --
|
137
|
+
'* port defaults to `5985` or `5986` for WinRM, based on the --[no-]ssl setting') do |nodes|
|
134
138
|
results[:nodes] += parse_nodes(nodes)
|
135
139
|
results[:nodes].uniq!
|
136
140
|
end
|
@@ -181,9 +185,13 @@ HELP
|
|
181
185
|
"Output format to use: human or json") do |format|
|
182
186
|
results[:format] = format
|
183
187
|
end
|
184
|
-
opts.on('-
|
185
|
-
"
|
186
|
-
results[:
|
188
|
+
opts.on('--[no-]host-key-check',
|
189
|
+
"Check host keys with SSH") do |host_key_check|
|
190
|
+
results[:host_key_check] = host_key_check
|
191
|
+
end
|
192
|
+
opts.on('--[no-]ssl',
|
193
|
+
"Use SSL with WinRM") do |ssl|
|
194
|
+
results[:ssl] = ssl
|
187
195
|
end
|
188
196
|
opts.on('--transport TRANSPORT', TRANSPORTS,
|
189
197
|
"Specify a default transport: #{TRANSPORTS.join(', ')}") do |t|
|
@@ -394,42 +402,35 @@ HELP
|
|
394
402
|
|
395
403
|
def execute(options)
|
396
404
|
if options[:mode] == 'plan' || options[:mode] == 'task'
|
397
|
-
|
398
|
-
require_relative '../../vendored/require_vendored'
|
399
|
-
rescue LoadError
|
400
|
-
raise Bolt::CLIError, "Puppet must be installed to execute tasks"
|
401
|
-
end
|
402
|
-
|
403
|
-
# Now that puppet is loaded we can include puppet mixins in data types
|
404
|
-
Bolt::ResultSet.include_iterable
|
405
|
-
|
406
|
-
Puppet::Util::Log.newdestination(:console)
|
407
|
-
Puppet[:log_level] = if @config[:log_level] == :debug
|
408
|
-
'debug'
|
409
|
-
else
|
410
|
-
'notice'
|
411
|
-
end
|
405
|
+
pal = Bolt::PAL.new(@config)
|
412
406
|
end
|
413
407
|
|
414
408
|
if options[:action] == 'show'
|
415
409
|
if options[:mode] == 'task'
|
416
410
|
if options[:object]
|
417
|
-
outputter.print_task_info(get_task_info(options[:object]))
|
411
|
+
outputter.print_task_info(pal.get_task_info(options[:object]))
|
418
412
|
else
|
419
|
-
outputter.print_table(list_tasks)
|
413
|
+
outputter.print_table(pal.list_tasks)
|
420
414
|
outputter.print_message("\nUse `bolt task show <task-name>` to view "\
|
421
|
-
|
422
|
-
"task.")
|
415
|
+
"details and parameters for a specific task.")
|
423
416
|
end
|
424
417
|
elsif options[:mode] == 'plan'
|
425
|
-
|
418
|
+
if options[:object]
|
419
|
+
outputter.print_plan_info(pal.get_plan_info(options[:object]))
|
420
|
+
else
|
421
|
+
outputter.print_table(pal.list_plans)
|
422
|
+
outputter.print_message("\nUse `bolt plan show <plan-name>` to view "\
|
423
|
+
"details and parameters for a specific plan.")
|
424
|
+
end
|
426
425
|
end
|
427
426
|
return 0
|
428
427
|
end
|
429
428
|
|
430
429
|
if options[:mode] == 'plan'
|
431
430
|
executor = Bolt::Executor.new(@config, options[:noop], true)
|
432
|
-
|
431
|
+
result = pal.run_plan(options[:object], options[:task_options], executor)
|
432
|
+
outputter.print_plan_result(result)
|
433
|
+
# An exception would have been raised if the plan failed
|
433
434
|
code = 0
|
434
435
|
else
|
435
436
|
executor = Bolt::Executor.new(@config, options[:noop])
|
@@ -454,7 +455,10 @@ HELP
|
|
454
455
|
outputter.print_event(event)
|
455
456
|
end
|
456
457
|
when 'task'
|
457
|
-
|
458
|
+
pal.run_task(options[:object],
|
459
|
+
targets,
|
460
|
+
options[:task_options],
|
461
|
+
executor) do |event|
|
458
462
|
outputter.print_event(event)
|
459
463
|
end
|
460
464
|
when 'file'
|
@@ -480,28 +484,6 @@ HELP
|
|
480
484
|
raise e
|
481
485
|
end
|
482
486
|
|
483
|
-
def with_bolt_executor(executor, &block)
|
484
|
-
Puppet.override(bolt_executor: executor, &block)
|
485
|
-
end
|
486
|
-
|
487
|
-
def execute_task(executor, options, &block)
|
488
|
-
with_bolt_executor(executor) do
|
489
|
-
run_task(options[:object],
|
490
|
-
options[:nodes],
|
491
|
-
options[:task_options],
|
492
|
-
&block)
|
493
|
-
end
|
494
|
-
end
|
495
|
-
|
496
|
-
def execute_plan(executor, options)
|
497
|
-
# Plans return null here?
|
498
|
-
result = with_bolt_executor(executor) do
|
499
|
-
run_plan(options[:object],
|
500
|
-
options[:task_options])
|
501
|
-
end
|
502
|
-
outputter.print_plan(result)
|
503
|
-
end
|
504
|
-
|
505
487
|
def validate_file(type, path)
|
506
488
|
if path.nil?
|
507
489
|
raise Bolt::CLIError, "A #{type} must be specified"
|
@@ -525,88 +507,5 @@ HELP
|
|
525
507
|
def outputter
|
526
508
|
@outputter ||= Bolt::Outputter.for_format(@config[:format])
|
527
509
|
end
|
528
|
-
|
529
|
-
# Runs a block in a PAL script compiler configured for Bolt. Catches
|
530
|
-
# exceptions thrown by the block and re-raises them ensuring they are
|
531
|
-
# Bolt::Errors since the script compiler block will squash all exceptions.
|
532
|
-
def in_bolt_compiler(opts = [])
|
533
|
-
Puppet.initialize_settings(opts)
|
534
|
-
r = Puppet::Pal.in_tmp_environment('bolt', modulepath: [BOLTLIB_PATH] + @config[:modulepath], facts: {}) do |pal|
|
535
|
-
pal.with_script_compiler do |compiler|
|
536
|
-
begin
|
537
|
-
yield compiler
|
538
|
-
rescue Puppet::PreformattedError => err
|
539
|
-
# Puppet sometimes rescues exceptions notes the location and reraises
|
540
|
-
# For now return the original error. Exception cause support was added in Ruby 2.1
|
541
|
-
# so we fall back to reporting the error we got for Ruby 2.0.
|
542
|
-
if err.respond_to?(:cause) && err.cause
|
543
|
-
if err.cause.is_a? Bolt::Error
|
544
|
-
err.cause
|
545
|
-
else
|
546
|
-
e = Bolt::CLIError.new(err.cause.message)
|
547
|
-
e.set_backtrace(err.cause.backtrace)
|
548
|
-
e
|
549
|
-
end
|
550
|
-
else
|
551
|
-
e = Bolt::CLIError.new(err.message)
|
552
|
-
e.set_backtrace(err.backtrace)
|
553
|
-
e
|
554
|
-
end
|
555
|
-
rescue StandardError => err
|
556
|
-
e = Bolt::CLIError.new(err.message)
|
557
|
-
e.set_backtrace(err.backtrace)
|
558
|
-
e
|
559
|
-
end
|
560
|
-
end
|
561
|
-
end
|
562
|
-
|
563
|
-
if r.is_a? StandardError
|
564
|
-
raise r
|
565
|
-
end
|
566
|
-
r
|
567
|
-
end
|
568
|
-
|
569
|
-
def list_tasks
|
570
|
-
in_bolt_compiler do |compiler|
|
571
|
-
tasks = compiler.list_tasks
|
572
|
-
tasks.map(&:name).sort.map do |task_name|
|
573
|
-
task_sig = compiler.task_signature(task_name)
|
574
|
-
[task_name, task_sig.task.description]
|
575
|
-
end
|
576
|
-
end
|
577
|
-
end
|
578
|
-
|
579
|
-
def list_plans
|
580
|
-
in_bolt_compiler do |compiler|
|
581
|
-
compiler.list_plans.map { |plan| [plan.name] }.sort
|
582
|
-
end
|
583
|
-
end
|
584
|
-
|
585
|
-
def get_task_info(task_name)
|
586
|
-
task = in_bolt_compiler do |compiler|
|
587
|
-
compiler.task_signature(task_name)
|
588
|
-
end
|
589
|
-
raise Bolt::CLIError, "Could not find task #{task_name} in your modulepath" if task.nil?
|
590
|
-
task.task_hash
|
591
|
-
end
|
592
|
-
|
593
|
-
def run_task(name, targets, args, &block)
|
594
|
-
args = args.merge('_catch_errors' => true)
|
595
|
-
in_bolt_compiler do |compiler|
|
596
|
-
compiler.call_function('run_task', name, targets, args, &block)
|
597
|
-
end
|
598
|
-
end
|
599
|
-
|
600
|
-
def run_plan(plan, args)
|
601
|
-
Dir.mktmpdir('bolt') do |dir|
|
602
|
-
cli = []
|
603
|
-
Puppet::Settings::REQUIRED_APP_SETTINGS.each do |setting|
|
604
|
-
cli << "--#{setting}" << dir
|
605
|
-
end
|
606
|
-
in_bolt_compiler(cli) do |compiler|
|
607
|
-
compiler.call_function('run_plan', plan, args)
|
608
|
-
end
|
609
|
-
end
|
610
|
-
end
|
611
510
|
end
|
612
511
|
end
|
data/lib/bolt/config.rb
CHANGED
@@ -18,17 +18,26 @@ module Bolt
|
|
18
18
|
format: 'human'
|
19
19
|
}.freeze
|
20
20
|
|
21
|
-
TRANSPORT_OPTIONS = %i[
|
22
|
-
key tty tmpdir user connect_timeout cacert
|
21
|
+
TRANSPORT_OPTIONS = %i[host_key_check password run_as sudo_password extensions
|
22
|
+
ssl key tty tmpdir user connect_timeout cacert
|
23
23
|
token_file orch_task_environment service_url].freeze
|
24
24
|
|
25
25
|
TRANSPORT_DEFAULTS = {
|
26
26
|
connect_timeout: 10,
|
27
27
|
orch_task_environment: 'production',
|
28
|
-
insecure: false,
|
29
28
|
tty: false
|
30
29
|
}.freeze
|
31
30
|
|
31
|
+
TRANSPORT_SPECIFIC_DEFAULTS = {
|
32
|
+
ssh: {
|
33
|
+
host_key_check: true
|
34
|
+
},
|
35
|
+
winrm: {
|
36
|
+
ssl: true
|
37
|
+
},
|
38
|
+
pcp: {}
|
39
|
+
}.freeze
|
40
|
+
|
32
41
|
TRANSPORTS = %i[ssh winrm pcp].freeze
|
33
42
|
|
34
43
|
def initialize(**kwargs)
|
@@ -46,6 +55,12 @@ module Bolt
|
|
46
55
|
self[:transports][transport][k] = v
|
47
56
|
end
|
48
57
|
end
|
58
|
+
|
59
|
+
TRANSPORT_SPECIFIC_DEFAULTS[transport].each do |k, v|
|
60
|
+
unless self[:transports][transport].key? k
|
61
|
+
self[:transports][transport][k] = v
|
62
|
+
end
|
63
|
+
end
|
49
64
|
end
|
50
65
|
end
|
51
66
|
|
@@ -100,8 +115,8 @@ module Bolt
|
|
100
115
|
if data['ssh']['private-key']
|
101
116
|
self[:transports][:ssh][:key] = data['ssh']['private-key']
|
102
117
|
end
|
103
|
-
if data['ssh']
|
104
|
-
self[:transports][:ssh][:
|
118
|
+
if data['ssh'].key?('host-key-check')
|
119
|
+
self[:transports][:ssh][:host_key_check] = data['ssh']['host-key-check']
|
105
120
|
end
|
106
121
|
if data['ssh']['connect-timeout']
|
107
122
|
self[:transports][:ssh][:connect_timeout] = data['ssh']['connect-timeout']
|
@@ -118,8 +133,8 @@ module Bolt
|
|
118
133
|
if data['winrm']['connect-timeout']
|
119
134
|
self[:transports][:winrm][:connect_timeout] = data['winrm']['connect-timeout']
|
120
135
|
end
|
121
|
-
if data['winrm']
|
122
|
-
self[:transports][:winrm][:
|
136
|
+
if data['winrm'].key?('ssl')
|
137
|
+
self[:transports][:winrm][:ssl] = data['winrm']['ssl']
|
123
138
|
end
|
124
139
|
if data['winrm']['tmpdir']
|
125
140
|
self[:transports][:winrm][:tmpdir] = data['winrm']['tmpdir']
|
@@ -167,9 +182,20 @@ module Bolt
|
|
167
182
|
end
|
168
183
|
|
169
184
|
TRANSPORT_OPTIONS.each do |key|
|
170
|
-
# TODO: We should eventually make these transport specific
|
171
185
|
TRANSPORTS.each do |transport|
|
172
|
-
|
186
|
+
unless %i[ssl host_key_check].any? { |k| k == key }
|
187
|
+
self[:transports][transport][key] = options[key] if options[key]
|
188
|
+
next
|
189
|
+
end
|
190
|
+
if key == :ssl && transport == :winrm
|
191
|
+
# this defaults to true so we need to check the presence of the key
|
192
|
+
self[:transports][transport][key] = options[key] if options.key?(key)
|
193
|
+
next
|
194
|
+
elsif key == :host_key_check && transport == :ssh
|
195
|
+
# this defaults to true so we need to check the presence of the key
|
196
|
+
self[:transports][transport][key] = options[key] if options.key?(key)
|
197
|
+
next
|
198
|
+
end
|
173
199
|
end
|
174
200
|
end
|
175
201
|
end
|
data/lib/bolt/executor.rb
CHANGED
@@ -10,6 +10,7 @@ require 'bolt/result_set'
|
|
10
10
|
module Bolt
|
11
11
|
class Executor
|
12
12
|
attr_reader :noop
|
13
|
+
attr_accessor :run_as
|
13
14
|
|
14
15
|
def initialize(config = Bolt::Config.new, noop = nil, plan_logging = false)
|
15
16
|
@config = config
|
@@ -21,6 +22,7 @@ module Bolt
|
|
21
22
|
default_log_level = plan_logging ? :info : :notice
|
22
23
|
@logger.level = @config[:log_level] || default_log_level
|
23
24
|
@noop = noop
|
25
|
+
@run_as = nil
|
24
26
|
@notifier = Bolt::Notifier.new
|
25
27
|
end
|
26
28
|
|
@@ -79,14 +81,32 @@ module Bolt
|
|
79
81
|
end
|
80
82
|
private :summary
|
81
83
|
|
82
|
-
def
|
84
|
+
def get_run_as(node, options)
|
85
|
+
if node.run_as.nil? && run_as
|
86
|
+
{ '_run_as' => run_as }.merge(options)
|
87
|
+
else
|
88
|
+
options
|
89
|
+
end
|
90
|
+
end
|
91
|
+
private :get_run_as
|
92
|
+
|
93
|
+
def with_exception_handling(node)
|
94
|
+
yield
|
95
|
+
rescue StandardError => e
|
96
|
+
Bolt::Result.from_exception(node.target, e)
|
97
|
+
end
|
98
|
+
private :with_exception_handling
|
99
|
+
|
100
|
+
def run_command(targets, command, options = {})
|
83
101
|
nodes = from_targets(targets)
|
84
102
|
@logger.info("Starting command run '#{command}' on #{nodes.map(&:uri)}")
|
85
103
|
callback = block_given? ? Proc.new : nil
|
86
104
|
|
87
105
|
r = on(nodes, callback) do |node|
|
88
106
|
@logger.debug("Running command '#{command}' on #{node.uri}")
|
89
|
-
node_result = node
|
107
|
+
node_result = with_exception_handling(node) do
|
108
|
+
node.run_command(command, get_run_as(node, options))
|
109
|
+
end
|
90
110
|
@logger.debug("Result on #{node.uri}: #{JSON.dump(node_result.value)}")
|
91
111
|
node_result
|
92
112
|
end
|
@@ -94,7 +114,7 @@ module Bolt
|
|
94
114
|
r
|
95
115
|
end
|
96
116
|
|
97
|
-
def run_script(targets, script, arguments)
|
117
|
+
def run_script(targets, script, arguments, options = {})
|
98
118
|
nodes = from_targets(targets)
|
99
119
|
@logger.info("Starting script run #{script} on #{nodes.map(&:uri)}")
|
100
120
|
@logger.debug("Arguments: #{arguments}")
|
@@ -102,7 +122,9 @@ module Bolt
|
|
102
122
|
|
103
123
|
r = on(nodes, callback) do |node|
|
104
124
|
@logger.debug { "Running script '#{script}' on #{node.uri}" }
|
105
|
-
node_result = node
|
125
|
+
node_result = with_exception_handling(node) do
|
126
|
+
node.run_script(script, arguments, get_run_as(node, options))
|
127
|
+
end
|
106
128
|
@logger.debug("Result on #{node.uri}: #{JSON.dump(node_result.value)}")
|
107
129
|
node_result
|
108
130
|
end
|
@@ -110,7 +132,7 @@ module Bolt
|
|
110
132
|
r
|
111
133
|
end
|
112
134
|
|
113
|
-
def run_task(targets, task, input_method, arguments)
|
135
|
+
def run_task(targets, task, input_method, arguments, options = {})
|
114
136
|
nodes = from_targets(targets)
|
115
137
|
@logger.info("Starting task #{task} on #{nodes.map(&:uri)}")
|
116
138
|
@logger.debug("Arguments: #{arguments} Input method: #{input_method}")
|
@@ -118,7 +140,9 @@ module Bolt
|
|
118
140
|
|
119
141
|
r = on(nodes, callback) do |node|
|
120
142
|
@logger.debug { "Running task run '#{task}' on #{node.uri}" }
|
121
|
-
node_result = node
|
143
|
+
node_result = with_exception_handling(node) do
|
144
|
+
node.run_task(task, input_method, arguments, get_run_as(node, options))
|
145
|
+
end
|
122
146
|
@logger.debug("Result on #{node.uri}: #{JSON.dump(node_result.value)}")
|
123
147
|
node_result
|
124
148
|
end
|
@@ -133,7 +157,9 @@ module Bolt
|
|
133
157
|
|
134
158
|
r = on(nodes, callback) do |node|
|
135
159
|
@logger.debug { "Uploading: '#{source}' to #{destination} on #{node.uri}" }
|
136
|
-
node_result = node
|
160
|
+
node_result = with_exception_handling(node) do
|
161
|
+
node.upload(source, destination)
|
162
|
+
end
|
137
163
|
@logger.debug("Result on #{node.uri}: #{JSON.dump(node_result.value)}")
|
138
164
|
node_result
|
139
165
|
end
|
data/lib/bolt/node.rb
CHANGED
@@ -22,7 +22,7 @@ module Bolt
|
|
22
22
|
|
23
23
|
def self.initialize_transport(_logger); end
|
24
24
|
|
25
|
-
attr_reader :logger, :user, :password, :connect_timeout, :target
|
25
|
+
attr_reader :logger, :user, :password, :connect_timeout, :target, :run_as
|
26
26
|
|
27
27
|
def initialize(target, config: Bolt::Config.new)
|
28
28
|
@target = target
|
@@ -33,7 +33,8 @@ module Bolt
|
|
33
33
|
@key = transport_conf[:key]
|
34
34
|
@cacert = transport_conf[:cacert]
|
35
35
|
@tty = transport_conf[:tty]
|
36
|
-
@
|
36
|
+
@host_key_check = transport_conf[:host_key_check]
|
37
|
+
@ssl = transport_conf[:ssl]
|
37
38
|
@connect_timeout = transport_conf[:connect_timeout]
|
38
39
|
@sudo_password = transport_conf[:sudo_password]
|
39
40
|
@run_as = transport_conf[:run_as]
|
@@ -49,6 +50,22 @@ module Bolt
|
|
49
50
|
def uri
|
50
51
|
@target.uri
|
51
52
|
end
|
53
|
+
|
54
|
+
def upload(_source, _destination)
|
55
|
+
raise NotImplementedError, 'transports must implement upload(source, destination)'
|
56
|
+
end
|
57
|
+
|
58
|
+
def run_command(_command, _options = nil)
|
59
|
+
raise NotImplementedError, 'transports must implement run_command(command, options = nil)'
|
60
|
+
end
|
61
|
+
|
62
|
+
def run_script(_script, _arguments, _options = nil)
|
63
|
+
raise NotImplementedError, 'transports must implement run_script(script, arguments, options = nil)'
|
64
|
+
end
|
65
|
+
|
66
|
+
def run_task(_task, _input_method, _arguments, _options = nil)
|
67
|
+
raise NotImplementedError, 'transports must implement run_task(task, input_method, arguments, options = nil)'
|
68
|
+
end
|
52
69
|
end
|
53
70
|
end
|
54
71
|
|