bolt 0.17.1 → 0.17.2
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/run_task.rb +25 -13
- data/lib/bolt/cli.rb +45 -15
- data/lib/bolt/config.rb +48 -132
- data/lib/bolt/executor.rb +3 -10
- data/lib/bolt/inventory.rb +15 -1
- data/lib/bolt/puppetdb.rb +11 -0
- data/lib/bolt/puppetdb/client.rb +68 -0
- data/lib/bolt/puppetdb/config.rb +76 -0
- data/lib/bolt/target.rb +5 -4
- data/lib/bolt/transport/base.rb +11 -2
- data/lib/bolt/transport/local.rb +11 -5
- data/lib/bolt/transport/orch.rb +16 -5
- data/lib/bolt/transport/ssh.rb +32 -1
- data/lib/bolt/transport/ssh/connection.rb +17 -10
- data/lib/bolt/transport/winrm.rb +18 -1
- data/lib/bolt/transport/winrm/connection.rb +15 -16
- data/lib/bolt/util.rb +15 -0
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_ext/puppetdb_inventory.rb +5 -135
- data/vendored/facter/lib/facter/ec2/rest.rb +1 -1
- data/vendored/hiera/lib/hiera/version.rb +1 -1
- data/vendored/puppet/lib/puppet/application/agent.rb +1 -3
- data/vendored/puppet/lib/puppet/application/apply.rb +2 -4
- data/vendored/puppet/lib/puppet/application/cert.rb +6 -1
- data/vendored/puppet/lib/puppet/application/device.rb +100 -13
- data/vendored/puppet/lib/puppet/application/facts.rb +5 -0
- data/vendored/puppet/lib/puppet/application/lookup.rb +11 -1
- data/vendored/puppet/lib/puppet/configurer.rb +17 -4
- data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +1 -1
- data/vendored/puppet/lib/puppet/datatypes.rb +1 -1
- data/vendored/puppet/lib/puppet/defaults.rb +1 -1
- data/vendored/puppet/lib/puppet/environments.rb +2 -2
- data/vendored/puppet/lib/puppet/error.rb +6 -3
- data/vendored/puppet/lib/puppet/external/dot.rb +0 -7
- data/vendored/puppet/lib/puppet/external/nagios/parser.rb +1 -1
- data/vendored/puppet/lib/puppet/face/config.rb +41 -8
- data/vendored/puppet/lib/puppet/face/epp.rb +30 -5
- data/vendored/puppet/lib/puppet/face/facts.rb +49 -0
- data/vendored/puppet/lib/puppet/face/help.rb +33 -35
- data/vendored/puppet/lib/puppet/face/man.rb +55 -12
- data/vendored/puppet/lib/puppet/face/parser.rb +30 -3
- data/vendored/puppet/lib/puppet/file_bucket/file.rb +0 -2
- data/vendored/puppet/lib/puppet/file_serving/base.rb +10 -10
- data/vendored/puppet/lib/puppet/functions.rb +1 -3
- data/vendored/puppet/lib/puppet/functions/alert.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/all.rb +6 -6
- data/vendored/puppet/lib/puppet/functions/annotate.rb +10 -10
- data/vendored/puppet/lib/puppet/functions/any.rb +6 -6
- data/vendored/puppet/lib/puppet/functions/assert_type.rb +4 -4
- data/vendored/puppet/lib/puppet/functions/binary_file.rb +14 -2
- data/vendored/puppet/lib/puppet/functions/break.rb +31 -2
- data/vendored/puppet/lib/puppet/functions/call.rb +4 -4
- data/vendored/puppet/lib/puppet/functions/contain.rb +19 -3
- data/vendored/puppet/lib/puppet/functions/convert_to.rb +6 -5
- data/vendored/puppet/lib/puppet/functions/crit.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/debug.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/defined.rb +11 -9
- data/vendored/puppet/lib/puppet/functions/dig.rb +26 -2
- data/vendored/puppet/lib/puppet/functions/each.rb +8 -8
- data/vendored/puppet/lib/puppet/functions/emerg.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/empty.rb +79 -0
- data/vendored/puppet/lib/puppet/functions/err.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/filter.rb +7 -7
- data/vendored/puppet/lib/puppet/functions/find_file.rb +15 -1
- data/vendored/puppet/lib/puppet/functions/flatten.rb +64 -0
- data/vendored/puppet/lib/puppet/functions/hiera.rb +6 -6
- data/vendored/puppet/lib/puppet/functions/hiera_array.rb +6 -6
- data/vendored/puppet/lib/puppet/functions/hiera_hash.rb +6 -6
- data/vendored/puppet/lib/puppet/functions/hiera_include.rb +8 -8
- data/vendored/puppet/lib/puppet/functions/include.rb +28 -2
- data/vendored/puppet/lib/puppet/functions/info.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/inline_epp.rb +2 -2
- data/vendored/puppet/lib/puppet/functions/join.rb +56 -0
- data/vendored/puppet/lib/puppet/functions/keys.rb +25 -0
- data/vendored/puppet/lib/puppet/functions/length.rb +44 -0
- data/vendored/puppet/lib/puppet/functions/lest.rb +39 -1
- data/vendored/puppet/lib/puppet/functions/map.rb +10 -9
- data/vendored/puppet/lib/puppet/functions/match.rb +6 -6
- data/vendored/puppet/lib/puppet/functions/new.rb +995 -2
- data/vendored/puppet/lib/puppet/functions/next.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/notice.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/reduce.rb +6 -6
- data/vendored/puppet/lib/puppet/functions/regsubst.rb +9 -3
- data/vendored/puppet/lib/puppet/functions/require.rb +36 -2
- data/vendored/puppet/lib/puppet/functions/return.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/reverse_each.rb +71 -2
- data/vendored/puppet/lib/puppet/functions/slice.rb +23 -9
- data/vendored/puppet/lib/puppet/functions/split.rb +12 -10
- data/vendored/puppet/lib/puppet/functions/step.rb +73 -1
- data/vendored/puppet/lib/puppet/functions/strftime.rb +176 -2
- data/vendored/puppet/lib/puppet/functions/then.rb +65 -2
- data/vendored/puppet/lib/puppet/functions/tree_each.rb +19 -19
- data/vendored/puppet/lib/puppet/functions/type.rb +42 -1
- data/vendored/puppet/lib/puppet/functions/unique.rb +13 -13
- data/vendored/puppet/lib/puppet/functions/unwrap.rb +8 -4
- data/vendored/puppet/lib/puppet/functions/values.rb +25 -0
- data/vendored/puppet/lib/puppet/functions/versioncmp.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/warning.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/with.rb +6 -4
- data/vendored/puppet/lib/puppet/indirector/certificate_status/file.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/facts/facter.rb +1 -3
- data/vendored/puppet/lib/puppet/indirector/facts/rest.rb +21 -0
- data/vendored/puppet/lib/puppet/indirector/facts/yaml.rb +0 -4
- data/vendored/puppet/lib/puppet/indirector/file_content/http.rb +3 -1
- data/vendored/puppet/lib/puppet/indirector/indirection.rb +5 -3
- data/vendored/puppet/lib/puppet/indirector/request.rb +6 -2
- data/vendored/puppet/lib/puppet/module/task.rb +2 -2
- data/vendored/puppet/lib/puppet/module_tool/tar/mini.rb +57 -4
- data/vendored/puppet/lib/puppet/network/authconfig.rb +1 -1
- data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +1 -0
- data/vendored/puppet/lib/puppet/network/resolver.rb +1 -2
- data/vendored/puppet/lib/puppet/node.rb +4 -3
- data/vendored/puppet/lib/puppet/parser/compiler.rb +12 -5
- data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/fqdn_rand.rb +15 -4
- data/vendored/puppet/lib/puppet/parser/functions/new.rb +31 -46
- data/vendored/puppet/lib/puppet/parser/parser_factory.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/resource.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/type_loader.rb +11 -11
- data/vendored/puppet/lib/puppet/pops/evaluator/closure.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/collector_transformer.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/epp_evaluator.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_resource_support.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +5 -2
- data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/issue_reporter.rb +18 -1
- data/vendored/puppet/lib/puppet/pops/issues.rb +6 -3
- data/vendored/puppet/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +1 -2
- data/vendored/puppet/lib/puppet/pops/loader/ruby_function_instantiator.rb +1 -2
- data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +4 -4
- data/vendored/puppet/lib/puppet/pops/loader/type_definition_instantiator.rb +4 -1
- data/vendored/puppet/lib/puppet/pops/loaders.rb +18 -7
- data/vendored/puppet/lib/puppet/pops/lookup/global_data_provider.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/model/factory.rb +6 -3
- data/vendored/puppet/lib/puppet/pops/model/model_tree_dumper.rb +4 -0
- data/vendored/puppet/lib/puppet/pops/model/pn_transformer.rb +400 -0
- data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/parser/heredoc_support.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/parser/lexer_support.rb +3 -2
- data/vendored/puppet/lib/puppet/pops/parser/locator.rb +0 -2
- data/vendored/puppet/lib/puppet/pops/parser/pn_parser.rb +316 -0
- data/vendored/puppet/lib/puppet/pops/pcore.rb +17 -17
- data/vendored/puppet/lib/puppet/pops/pn.rb +236 -0
- data/vendored/puppet/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/types/class_loader.rb +6 -3
- data/vendored/puppet/lib/puppet/pops/types/implementation_registry.rb +28 -35
- data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +3 -3
- data/vendored/puppet/lib/puppet/pops/types/p_timespan_type.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/types/p_type_set_type.rb +24 -1
- data/vendored/puppet/lib/puppet/pops/types/ruby_generator.rb +3 -4
- data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +0 -4
- data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +14 -7
- data/vendored/puppet/lib/puppet/pops/types/types.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/utils.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +6 -2
- data/vendored/puppet/lib/puppet/provider/group/groupadd.rb +3 -1
- data/vendored/puppet/lib/puppet/provider/group/windows_adsi.rb +4 -7
- data/vendored/puppet/lib/puppet/provider/nameservice.rb +3 -3
- data/vendored/puppet/lib/puppet/provider/package/dnf.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/gem.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/pacman.rb +4 -4
- data/vendored/puppet/lib/puppet/provider/package/pip.rb +3 -3
- data/vendored/puppet/lib/puppet/provider/package/pkgdmg.rb +3 -3
- data/vendored/puppet/lib/puppet/provider/package/pkgutil.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/package/portage.rb +9 -9
- data/vendored/puppet/lib/puppet/provider/package/zypper.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/service/base.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/service/smf.rb +3 -2
- data/vendored/puppet/lib/puppet/provider/user/useradd.rb +6 -2
- data/vendored/puppet/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +3 -2
- data/vendored/puppet/lib/puppet/reference/configuration.rb +2 -0
- data/vendored/puppet/lib/puppet/reference/type.rb +11 -11
- data/vendored/puppet/lib/puppet/resource.rb +1 -1
- data/vendored/puppet/lib/puppet/resource/capability_finder.rb +2 -2
- data/vendored/puppet/lib/puppet/resource/catalog.rb +2 -2
- data/vendored/puppet/lib/puppet/resource/status.rb +9 -2
- data/vendored/puppet/lib/puppet/resource/type.rb +1 -1
- data/vendored/puppet/lib/puppet/settings.rb +31 -19
- data/vendored/puppet/lib/puppet/settings/base_setting.rb +5 -0
- data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -1
- data/vendored/puppet/lib/puppet/settings/ttl_setting.rb +5 -0
- data/vendored/puppet/lib/puppet/ssl/certificate_factory.rb +2 -2
- data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +0 -2
- data/vendored/puppet/lib/puppet/transaction/additional_resource_generator.rb +2 -2
- data/vendored/puppet/lib/puppet/transaction/event.rb +1 -1
- data/vendored/puppet/lib/puppet/transaction/report.rb +1 -1
- data/vendored/puppet/lib/puppet/type.rb +9 -13
- data/vendored/puppet/lib/puppet/type/augeas.rb +2 -2
- data/vendored/puppet/lib/puppet/type/cron.rb +11 -6
- data/vendored/puppet/lib/puppet/type/exec.rb +1 -1
- data/vendored/puppet/lib/puppet/type/file.rb +4 -5
- data/vendored/puppet/lib/puppet/type/host.rb +1 -1
- data/vendored/puppet/lib/puppet/type/k5login.rb +30 -54
- data/vendored/puppet/lib/puppet/type/package.rb +3 -3
- data/vendored/puppet/lib/puppet/type/schedule.rb +12 -12
- data/vendored/puppet/lib/puppet/type/scheduled_task.rb +2 -2
- data/vendored/puppet/lib/puppet/type/ssh_authorized_key.rb +5 -5
- data/vendored/puppet/lib/puppet/type/sshkey.rb +2 -2
- data/vendored/puppet/lib/puppet/type/tidy.rb +9 -2
- data/vendored/puppet/lib/puppet/type/user.rb +1 -1
- data/vendored/puppet/lib/puppet/type/yumrepo.rb +25 -4
- data/vendored/puppet/lib/puppet/type/zfs.rb +4 -0
- data/vendored/puppet/lib/puppet/util.rb +0 -4
- data/vendored/puppet/lib/puppet/util/backups.rb +1 -1
- data/vendored/puppet/lib/puppet/util/http_proxy.rb +4 -2
- data/vendored/puppet/lib/puppet/util/inifile.rb +3 -4
- data/vendored/puppet/lib/puppet/util/log.rb +2 -5
- data/vendored/puppet/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/vendored/puppet/lib/puppet/util/reference.rb +1 -8
- data/vendored/puppet/lib/puppet/util/tagging.rb +1 -1
- data/vendored/puppet/lib/puppet/util/warnings.rb +0 -2
- data/vendored/puppet/lib/puppet/util/windows/adsi.rb +15 -18
- data/vendored/puppet/lib/puppet/util/windows/com.rb +2 -1
- data/vendored/puppet/lib/puppet/util/windows/file.rb +2 -2
- data/vendored/puppet/lib/puppet/util/windows/principal.rb +7 -6
- data/vendored/puppet/lib/puppet/util/windows/sid.rb +60 -7
- data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +0 -9
- data/vendored/puppet/lib/puppet/version.rb +1 -1
- data/vendored/puppet/lib/puppet_pal.rb +53 -48
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9ea02d63dd2b45747f5eda9d07187f39842332f
|
4
|
+
data.tar.gz: 3768ff96fafe4b6cb9d05fdad94c17ce3809e2be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26863769817e4f0b644041dc32b2eda8c961d75ab34bc805db0ff497ff8c624672c5d3d6051cdd6add2fa921e862310d9236879cacf61aa35144fd795f159c03
|
7
|
+
data.tar.gz: 6b767b8e2dab9368e0bd5bc7feee4b397f18a39005eca646d2bad44e3a400bdca5009f1e6d1e51d1688ab8265e02996a2b127840e918cdd405c618a6fe00a52c
|
@@ -41,12 +41,6 @@ Puppet::Functions.create_function(:run_task) do
|
|
41
41
|
)
|
42
42
|
end
|
43
43
|
|
44
|
-
# TODO: use the compiler injection once PUP-8237 lands
|
45
|
-
task_signature = Puppet::Pal::ScriptCompiler.new(closure_scope.compiler).task_signature(task_name)
|
46
|
-
if task_signature.nil?
|
47
|
-
raise with_stack(:UNKNOWN_TASK, Bolt::Error.unknown_task(task_name))
|
48
|
-
end
|
49
|
-
|
50
44
|
executor = Puppet.lookup(:bolt_executor) { nil }
|
51
45
|
inventory = Puppet.lookup(:bolt_inventory) { nil }
|
52
46
|
unless executor && inventory && Puppet.features.bolt?
|
@@ -55,18 +49,38 @@ Puppet::Functions.create_function(:run_task) do
|
|
55
49
|
)
|
56
50
|
end
|
57
51
|
|
52
|
+
# Ensure that given targets are all Target instances
|
53
|
+
targets = inventory.get_targets(targets)
|
54
|
+
|
58
55
|
use_args = task_args.reject { |k, _| k.start_with?('_') }
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
# Don't bother loading the local task definition if all targets use the 'pcp' transport
|
58
|
+
# and the local-validation option is set to false for all of them
|
59
|
+
if !targets.empty? && targets.all? { |t| t.protocol == 'pcp' && t.options['local-validation'] == false }
|
60
|
+
# create a fake task
|
61
|
+
task = Puppet::Pops::Types::TypeFactory.task.from_hash(
|
62
|
+
'name' => task_name,
|
63
|
+
'executable' => '',
|
64
|
+
'supports_noop' => true
|
65
|
+
)
|
66
|
+
else
|
67
|
+
# TODO: use the compiler injection once PUP-8237 lands
|
68
|
+
task_signature = Puppet::Pal::ScriptCompiler.new(closure_scope.compiler).task_signature(task_name)
|
69
|
+
if task_signature.nil?
|
70
|
+
raise with_stack(:UNKNOWN_TASK, Bolt::Error.unknown_task(task_name))
|
71
|
+
end
|
72
|
+
|
73
|
+
task_signature.runnable_with?(use_args) do |mismatch_message|
|
74
|
+
raise with_stack(:TYPE_MISMATCH, mismatch_message)
|
75
|
+
end || (raise with_stack(:TYPE_MISMATCH, 'Task parameters do not match'))
|
76
|
+
|
77
|
+
task = task_signature.task
|
78
|
+
end
|
63
79
|
|
64
80
|
unless Puppet::Pops::Types::TypeFactory.data.instance?(use_args)
|
65
81
|
raise with_stack(:TYPE_NOT_DATA, 'Task parameters is not of type Data')
|
66
82
|
end
|
67
83
|
|
68
|
-
task = task_signature.task
|
69
|
-
|
70
84
|
if executor.noop
|
71
85
|
if task.supports_noop
|
72
86
|
use_args['_noop'] = true
|
@@ -75,8 +89,6 @@ Puppet::Functions.create_function(:run_task) do
|
|
75
89
|
end
|
76
90
|
end
|
77
91
|
|
78
|
-
# Ensure that given targets are all Target instances
|
79
|
-
targets = inventory.get_targets(targets)
|
80
92
|
if targets.empty?
|
81
93
|
Bolt::ResultSet.new([])
|
82
94
|
else
|
data/lib/bolt/cli.rb
CHANGED
@@ -10,6 +10,7 @@ require 'bolt/executor'
|
|
10
10
|
require 'bolt/inventory'
|
11
11
|
require 'bolt/logger'
|
12
12
|
require 'bolt/outputter'
|
13
|
+
require 'bolt/puppetdb'
|
13
14
|
require 'bolt/pal'
|
14
15
|
require 'bolt/target'
|
15
16
|
require 'bolt/version'
|
@@ -129,6 +130,10 @@ Available options are:
|
|
129
130
|
'* port defaults to `5985` or `5986` for WinRM, based on the --[no-]ssl setting') do |nodes|
|
130
131
|
@options[:nodes] << get_arg_input(nodes)
|
131
132
|
end.extend(SwitchHider)
|
133
|
+
@query = define('-q', '--query QUERY',
|
134
|
+
'Query PuppetDB to determine the targets') do |query|
|
135
|
+
@options[:query] = query
|
136
|
+
end.extend(SwitchHider)
|
132
137
|
define('-u', '--user USER',
|
133
138
|
'User to authenticate as (Optional)') do |user|
|
134
139
|
@options[:user] = user
|
@@ -146,7 +151,7 @@ Available options are:
|
|
146
151
|
end
|
147
152
|
define('--private-key KEY',
|
148
153
|
'Private ssh key to authenticate with (Optional)') do |key|
|
149
|
-
@options[:key] = key
|
154
|
+
@options[:'private-key'] = key
|
150
155
|
end
|
151
156
|
define('--tmpdir DIR',
|
152
157
|
'The directory to upload and execute temporary files on the target (Optional)') do |tmpdir|
|
@@ -159,7 +164,7 @@ Available options are:
|
|
159
164
|
end
|
160
165
|
define('--connect-timeout TIMEOUT', Integer,
|
161
166
|
'Connection timeout (Optional)') do |timeout|
|
162
|
-
@options[:
|
167
|
+
@options[:'connect-timeout'] = timeout
|
163
168
|
end
|
164
169
|
define('--modulepath MODULES',
|
165
170
|
'List of directories containing modules, ' \
|
@@ -177,28 +182,28 @@ Available options are:
|
|
177
182
|
end
|
178
183
|
define('--[no-]host-key-check',
|
179
184
|
'Check host keys with SSH') do |host_key_check|
|
180
|
-
@options[:
|
185
|
+
@options[:'host-key-check'] = host_key_check
|
181
186
|
end
|
182
187
|
define('--[no-]ssl',
|
183
188
|
'Use SSL with WinRM') do |ssl|
|
184
189
|
@options[:ssl] = ssl
|
185
190
|
end
|
186
|
-
define('--transport TRANSPORT', TRANSPORTS.map(&:to_s),
|
187
|
-
'Specify a default transport: ' << TRANSPORTS.join(', ')) do |t|
|
191
|
+
define('--transport TRANSPORT', TRANSPORTS.keys.map(&:to_s),
|
192
|
+
'Specify a default transport: ' << TRANSPORTS.keys.join(', ')) do |t|
|
188
193
|
@options[:transport] = t
|
189
194
|
end
|
190
195
|
define('--run-as USER',
|
191
196
|
'User to run as using privilege escalation') do |user|
|
192
|
-
@options[:
|
197
|
+
@options[:'run-as'] = user
|
193
198
|
end
|
194
199
|
define('--sudo-password [PASSWORD]',
|
195
200
|
'Password for privilege escalation') do |password|
|
196
201
|
if password.nil?
|
197
202
|
STDOUT.print "Please enter your privilege escalation password: "
|
198
|
-
@options[:
|
203
|
+
@options[:'sudo-password'] = STDIN.noecho(&:gets).chomp
|
199
204
|
STDOUT.puts
|
200
205
|
else
|
201
|
-
@options[:
|
206
|
+
@options[:'sudo-password'] = password
|
202
207
|
end
|
203
208
|
end
|
204
209
|
define('--configfile CONFIG_PATH',
|
@@ -207,6 +212,9 @@ Available options are:
|
|
207
212
|
end
|
208
213
|
define('--inventoryfile INVENTORY_PATH',
|
209
214
|
'Specify where to load the inventory file from') do |path|
|
215
|
+
if ENV.include?(Bolt::Inventory::ENVIRONMENT_VAR)
|
216
|
+
raise Bolt::CLIError, "Cannot pass inventory file when #{Bolt::Inventory::ENVIRONMENT_VAR} is set"
|
217
|
+
end
|
210
218
|
@options[:inventoryfile] = path
|
211
219
|
end
|
212
220
|
define_tail('--[no-]tty',
|
@@ -235,9 +243,14 @@ Available options are:
|
|
235
243
|
end
|
236
244
|
|
237
245
|
def update
|
246
|
+
# show the --nodes and --query switches by default
|
247
|
+
@nodes.hide = @query.hide = false
|
248
|
+
|
238
249
|
# Update the banner according to the mode
|
239
250
|
self.banner = case @options[:mode]
|
240
251
|
when 'plan'
|
252
|
+
# don't show the --nodes and --query switches in the plan help
|
253
|
+
@nodes.hide = @query.hide = true
|
241
254
|
PLAN_HELP
|
242
255
|
when 'command'
|
243
256
|
COMMAND_HELP
|
@@ -250,10 +263,6 @@ Available options are:
|
|
250
263
|
else
|
251
264
|
BANNER
|
252
265
|
end
|
253
|
-
|
254
|
-
# Only show the --nodes switch in the help message produced by
|
255
|
-
# the #help method when not dealing with plans
|
256
|
-
@nodes.hide = (@options[:mode] == 'plan')
|
257
266
|
end
|
258
267
|
|
259
268
|
def parse_params(params)
|
@@ -367,7 +376,12 @@ Available options are:
|
|
367
376
|
|
368
377
|
# After validation, initialize inventory and targets. Errors here are better to catch early.
|
369
378
|
unless options[:action] == 'show' || options[:mode] == 'plan'
|
370
|
-
|
379
|
+
if options[:query]
|
380
|
+
nodes = query_puppetdb_nodes(options[:query])
|
381
|
+
options[:targets] = inventory.get_targets(nodes)
|
382
|
+
else
|
383
|
+
options[:targets] = inventory.get_targets(options[:nodes])
|
384
|
+
end
|
371
385
|
end
|
372
386
|
|
373
387
|
options
|
@@ -412,8 +426,12 @@ Available options are:
|
|
412
426
|
end
|
413
427
|
end
|
414
428
|
|
415
|
-
if options[:
|
416
|
-
|
429
|
+
if options[:mode] != 'plan' && options[:action] != 'show'
|
430
|
+
if options[:nodes].empty? && options[:query].nil?
|
431
|
+
raise Bolt::CLIError, "Targets must be specified with '--nodes' or '--query'"
|
432
|
+
elsif options[:nodes].any? && options[:query]
|
433
|
+
raise Bolt::CLIError, "Only one of '--nodes' or '--query' may be specified"
|
434
|
+
end
|
417
435
|
end
|
418
436
|
|
419
437
|
if options[:noop] && (options[:mode] != 'task' || options[:action] != 'run')
|
@@ -432,6 +450,18 @@ Available options are:
|
|
432
450
|
raise Bolt::CLIError, "Unknown argument '#{e.args.first}'"
|
433
451
|
end
|
434
452
|
|
453
|
+
def puppetdb_client
|
454
|
+
return @puppetdb_client if @puppetdb_client
|
455
|
+
puppetdb_config = Bolt::PuppetDB::Config.new(nil, config.puppetdb)
|
456
|
+
@puppetdb_client = Bolt::PuppetDB::Client.from_config(puppetdb_config)
|
457
|
+
end
|
458
|
+
|
459
|
+
def query_puppetdb_nodes(query)
|
460
|
+
puppetdb_client.query_certnames(query)
|
461
|
+
rescue StandardError => e
|
462
|
+
raise Bolt::CLIError, "Could not retrieve targets from PuppetDB: #{e}"
|
463
|
+
end
|
464
|
+
|
435
465
|
def execute(options)
|
436
466
|
message = nil
|
437
467
|
|
data/lib/bolt/config.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require 'bolt/cli'
|
3
2
|
require 'logging'
|
3
|
+
require 'bolt/cli'
|
4
|
+
require 'bolt/transport/ssh'
|
5
|
+
require 'bolt/transport/winrm'
|
6
|
+
require 'bolt/transport/orch'
|
7
|
+
require 'bolt/transport/local'
|
4
8
|
|
5
9
|
module Bolt
|
6
|
-
TRANSPORTS =
|
10
|
+
TRANSPORTS = {
|
11
|
+
ssh: Bolt::Transport::SSH,
|
12
|
+
winrm: Bolt::Transport::WinRM,
|
13
|
+
pcp: Bolt::Transport::Orch,
|
14
|
+
local: Bolt::Transport::Local
|
15
|
+
}.freeze
|
7
16
|
|
8
17
|
Config = Struct.new(
|
9
18
|
:concurrency,
|
@@ -12,6 +21,7 @@ module Bolt
|
|
12
21
|
:log_level,
|
13
22
|
:log,
|
14
23
|
:modulepath,
|
24
|
+
:puppetdb,
|
15
25
|
:transport,
|
16
26
|
:transports
|
17
27
|
) do
|
@@ -20,27 +30,29 @@ module Bolt
|
|
20
30
|
concurrency: 100,
|
21
31
|
transport: 'ssh',
|
22
32
|
format: 'human',
|
23
|
-
modulepath: []
|
33
|
+
modulepath: [],
|
34
|
+
puppetdb: {}
|
24
35
|
}.freeze
|
25
36
|
|
26
|
-
TRANSPORT_OPTIONS = %i[
|
27
|
-
|
28
|
-
token-file
|
37
|
+
TRANSPORT_OPTIONS = %i[password run-as sudo-password extensions
|
38
|
+
private-key tty tmpdir user connect-timeout
|
39
|
+
cacert token-file service-url].freeze
|
29
40
|
|
30
41
|
TRANSPORT_DEFAULTS = {
|
31
|
-
|
32
|
-
tty
|
42
|
+
'connect-timeout' => 10,
|
43
|
+
'tty' => false
|
33
44
|
}.freeze
|
34
45
|
|
35
46
|
TRANSPORT_SPECIFIC_DEFAULTS = {
|
36
47
|
ssh: {
|
37
|
-
|
48
|
+
'host-key-check' => true
|
38
49
|
},
|
39
50
|
winrm: {
|
40
|
-
ssl
|
51
|
+
'ssl' => true
|
41
52
|
},
|
42
53
|
pcp: {
|
43
|
-
|
54
|
+
'task-environment' => 'production',
|
55
|
+
'local-validation' => false
|
44
56
|
},
|
45
57
|
local: {}
|
46
58
|
}.freeze
|
@@ -55,10 +67,9 @@ module Bolt
|
|
55
67
|
self[:log]['console'] ||= {}
|
56
68
|
|
57
69
|
self[:transports] ||= {}
|
58
|
-
TRANSPORTS.
|
59
|
-
|
60
|
-
|
61
|
-
end
|
70
|
+
TRANSPORTS.each_key do |transport|
|
71
|
+
self[:transports][transport] ||= {}
|
72
|
+
|
62
73
|
TRANSPORT_DEFAULTS.each do |k, v|
|
63
74
|
unless self[:transports][transport][k]
|
64
75
|
self[:transports][transport][k] = v
|
@@ -109,74 +120,16 @@ module Bolt
|
|
109
120
|
self[:modulepath] = data['modulepath'].split(File::PATH_SEPARATOR)
|
110
121
|
end
|
111
122
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
if data['concurrency']
|
117
|
-
self[:concurrency] = data['concurrency']
|
118
|
-
end
|
119
|
-
|
120
|
-
if data['format']
|
121
|
-
self[:format] = data['format']
|
122
|
-
end
|
123
|
-
|
124
|
-
if data['ssh']
|
125
|
-
if data['ssh']['private-key']
|
126
|
-
self[:transports][:ssh][:key] = data['ssh']['private-key']
|
127
|
-
end
|
128
|
-
if data['ssh'].key?('host-key-check')
|
129
|
-
self[:transports][:ssh][:host_key_check] = data['ssh']['host-key-check']
|
130
|
-
end
|
131
|
-
if data['ssh']['connect-timeout']
|
132
|
-
self[:transports][:ssh][:connect_timeout] = data['ssh']['connect-timeout']
|
133
|
-
end
|
134
|
-
if data['ssh']['tmpdir']
|
135
|
-
self[:transports][:ssh][:tmpdir] = data['ssh']['tmpdir']
|
136
|
-
end
|
137
|
-
if data['ssh']['run-as']
|
138
|
-
self[:transports][:ssh][:run_as] = data['ssh']['run-as']
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
if data['winrm']
|
143
|
-
if data['winrm']['connect-timeout']
|
144
|
-
self[:transports][:winrm][:connect_timeout] = data['winrm']['connect-timeout']
|
145
|
-
end
|
146
|
-
if data['winrm'].key?('ssl')
|
147
|
-
self[:transports][:winrm][:ssl] = data['winrm']['ssl']
|
148
|
-
end
|
149
|
-
if data['winrm']['tmpdir']
|
150
|
-
self[:transports][:winrm][:tmpdir] = data['winrm']['tmpdir']
|
151
|
-
end
|
152
|
-
if data['winrm']['cacert']
|
153
|
-
self[:transports][:winrm][:cacert] = data['winrm']['cacert']
|
154
|
-
end
|
155
|
-
if data['winrm']['extensions']
|
156
|
-
# Accept a single entry or a list, ensure each is prefixed with '.'
|
157
|
-
self[:transports][:winrm][:extensions] =
|
158
|
-
[data['winrm']['extensions']].flatten.map { |ext| ext[0] != '.' ? '.' + ext : ext }
|
123
|
+
%w[inventoryfile concurrency format puppetdb].each do |key|
|
124
|
+
if data[key]
|
125
|
+
self[key.to_sym] = data[key]
|
159
126
|
end
|
160
127
|
end
|
161
128
|
|
162
|
-
|
163
|
-
if data[
|
164
|
-
|
165
|
-
|
166
|
-
if data['pcp']['cacert']
|
167
|
-
self[:transports][:pcp][:cacert] = data['pcp']['cacert']
|
168
|
-
end
|
169
|
-
if data['pcp']['token-file']
|
170
|
-
self[:transports][:pcp][:"token-file"] = data['pcp']['token-file']
|
171
|
-
end
|
172
|
-
if data['pcp']['task-environment']
|
173
|
-
self[:transports][:pcp][:"task-environment"] = data['pcp']['task-environment']
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
if data['local']
|
178
|
-
if data['local']['tmpdir']
|
179
|
-
self[:transports][:local][:tmpdir] = data['local']['tmpdir']
|
129
|
+
TRANSPORTS.each do |key, impl|
|
130
|
+
if data[key.to_s]
|
131
|
+
selected = data[key.to_s].select { |k| impl.options.include?(k) }
|
132
|
+
self[:transports][key].merge!(selected)
|
180
133
|
end
|
181
134
|
end
|
182
135
|
end
|
@@ -198,23 +151,22 @@ module Bolt
|
|
198
151
|
self[:log]['console'][:level] = :info
|
199
152
|
end
|
200
153
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
end
|
207
|
-
if key == :ssl && transport == :winrm
|
208
|
-
# this defaults to true so we need to check the presence of the key
|
209
|
-
self[:transports][transport][key] = options[key] if options.key?(key)
|
210
|
-
next
|
211
|
-
elsif key == :host_key_check && transport == :ssh
|
212
|
-
# this defaults to true so we need to check the presence of the key
|
213
|
-
self[:transports][transport][key] = options[key] if options.key?(key)
|
214
|
-
next
|
154
|
+
TRANSPORTS.each_key do |transport|
|
155
|
+
transport = self[:transports][transport]
|
156
|
+
TRANSPORT_OPTIONS.each do |key|
|
157
|
+
if options[key]
|
158
|
+
transport[key.to_s] = Bolt::Util.walk_keys(options[key], &:to_s)
|
215
159
|
end
|
216
160
|
end
|
217
161
|
end
|
162
|
+
|
163
|
+
if options.key?(:ssl) # this defaults to true so we need to check the presence of the key
|
164
|
+
self[:transports][:winrm]['ssl'] = options[:ssl]
|
165
|
+
end
|
166
|
+
|
167
|
+
if options.key?(:'host-key-check') # this defaults to true so we need to check the presence of the key
|
168
|
+
self[:transports][:ssh]['host-key-check'] = options[:'host-key-check']
|
169
|
+
end
|
218
170
|
end
|
219
171
|
|
220
172
|
def update_from_inventory(data)
|
@@ -223,19 +175,6 @@ module Bolt
|
|
223
175
|
if data['transport']
|
224
176
|
self[:transport] = data['transport']
|
225
177
|
end
|
226
|
-
|
227
|
-
# Add options that aren't allowed in a config file, but are allowed in inventory
|
228
|
-
%w[user password port].each do |opt|
|
229
|
-
(TRANSPORTS - [:pcp]).each do |transport|
|
230
|
-
if data[transport.to_s] && data[transport.to_s][opt]
|
231
|
-
self[:transports][transport][opt.to_sym] = data[transport.to_s][opt]
|
232
|
-
end
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
if data['ssh'] && data['ssh']['sudo-password']
|
237
|
-
self[:transports][:ssh][:sudo_password] = data['ssh']['sudo-password']
|
238
|
-
end
|
239
178
|
end
|
240
179
|
|
241
180
|
def transport_conf
|
@@ -244,10 +183,6 @@ module Bolt
|
|
244
183
|
end
|
245
184
|
|
246
185
|
def validate
|
247
|
-
TRANSPORTS.each do |transport|
|
248
|
-
self[:transports][transport]
|
249
|
-
end
|
250
|
-
|
251
186
|
self[:log].each_pair do |name, params|
|
252
187
|
if params.key?(:level) && !Bolt::Logger.valid_level?(params[:level])
|
253
188
|
raise Bolt::CLIError,
|
@@ -262,27 +197,8 @@ module Bolt
|
|
262
197
|
raise Bolt::CLIError, "Unsupported format: '#{self[:format]}'"
|
263
198
|
end
|
264
199
|
|
265
|
-
|
266
|
-
|
267
|
-
"user to escalate to with --run-as")
|
268
|
-
end
|
269
|
-
|
270
|
-
host_key = self[:transports][:ssh][:host_key_check]
|
271
|
-
unless !!host_key == host_key
|
272
|
-
raise Bolt::CLIError, 'host-key-check option must be a Boolean true or false'
|
273
|
-
end
|
274
|
-
|
275
|
-
ssl_flag = self[:transports][:winrm][:ssl]
|
276
|
-
unless !!ssl_flag == ssl_flag
|
277
|
-
raise Bolt::CLIError, 'ssl option must be a Boolean true or false'
|
278
|
-
end
|
279
|
-
|
280
|
-
self[:transports].each_value do |v|
|
281
|
-
timeout_value = v[:connect_timeout]
|
282
|
-
unless timeout_value.is_a?(Integer) || timeout_value.nil?
|
283
|
-
error_msg = "connect-timeout value must be an Integer, received #{timeout_value}:#{timeout_value.class}"
|
284
|
-
raise Bolt::CLIError, error_msg
|
285
|
-
end
|
200
|
+
TRANSPORTS.each do |transport, impl|
|
201
|
+
impl.validate(self[:transports][transport])
|
286
202
|
end
|
287
203
|
end
|
288
204
|
end
|