bolt 0.5.1 → 0.6.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/exe/bolt +1 -1
- data/lib/bolt.rb +0 -3
- data/lib/bolt/cli.rb +66 -32
- data/lib/bolt/config.rb +19 -0
- data/lib/bolt/executor.rb +21 -16
- data/lib/bolt/node.rb +13 -10
- data/lib/bolt/node/errors.rb +22 -0
- data/lib/bolt/node/ssh.rb +25 -2
- data/lib/bolt/node/winrm.rb +14 -2
- data/lib/bolt/node_uri.rb +15 -14
- data/lib/bolt/result.rb +22 -0
- data/lib/bolt/version.rb +1 -1
- data/vendored/puppet/lib/puppet/application/script.rb +7 -1
- data/vendored/puppet/lib/puppet/configurer.rb +1 -1
- data/vendored/puppet/lib/puppet/defaults.rb +18 -1
- data/vendored/puppet/lib/puppet/functions/run_command.rb +5 -2
- data/vendored/puppet/lib/puppet/functions/run_script.rb +5 -2
- data/vendored/puppet/lib/puppet/functions/run_task.rb +7 -2
- data/vendored/puppet/lib/puppet/gettext/config.rb +47 -26
- data/vendored/puppet/lib/puppet/graph/relationship_graph.rb +6 -0
- data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +19 -3
- data/vendored/puppet/lib/puppet/module.rb +8 -7
- data/vendored/puppet/lib/puppet/network/http/webrick.rb +1 -0
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +9 -0
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +8 -0
- data/vendored/puppet/lib/puppet/pops/types/p_error_type.rb +12 -0
- data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +9 -3
- data/vendored/puppet/lib/puppet/pops/types/ruby_generator.rb +65 -24
- data/vendored/puppet/lib/puppet/provider/mount.rb +25 -8
- 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/pkg.rb +3 -0
- data/vendored/puppet/lib/puppet/provider/service/launchd.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +20 -1
- data/vendored/puppet/lib/puppet/type/mount.rb +6 -2
- data/vendored/puppet/lib/puppet/type/yumrepo.rb +9 -0
- data/vendored/puppet/lib/puppet/version.rb +1 -1
- data/vendored/puppet/lib/puppet_pal.rb +33 -7
- metadata +45 -83
- data/.gitignore +0 -33
- data/.gitmodules +0 -12
- data/.rspec +0 -2
- data/.rubocop.yml +0 -61
- data/.travis.yml +0 -18
- data/CODE_OF_CONDUCT.md +0 -46
- data/CONTRIBUTING.md +0 -27
- data/Gemfile +0 -9
- data/INSTALL.md +0 -70
- data/LICENSE +0 -201
- data/README.md +0 -353
- data/Rakefile +0 -27
- data/Vagrantfile +0 -13
- data/appveyor.yml +0 -29
- data/bolt.gemspec +0 -50
- data/docs/writing_tasks_and_plans.pdf +0 -0
- data/metadata.json +0 -13
- data/tasks/init.json +0 -3
- data/tasks/init.rb +0 -44
- data/ux/bolt-CLI-spec.md +0 -186
- data/vendored/puppet/lib/puppet/external/nagios/grammar.ry +0 -248
- data/vendored/puppet/lib/puppet/external/nagios/makefile +0 -9
- data/vendored/puppet/lib/puppet/face/help/action.erb +0 -86
- data/vendored/puppet/lib/puppet/face/help/face.erb +0 -114
- data/vendored/puppet/lib/puppet/face/help/global.erb +0 -16
- data/vendored/puppet/lib/puppet/face/help/man.erb +0 -152
- data/vendored/puppet/lib/puppet/generate/templates/type/pcore.erb +0 -42
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.fixtures.yml.erb +0 -7
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.gitignore +0 -18
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.rubocop.yml +0 -42
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.yardopts +0 -1
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +0 -18
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +0 -89
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +0 -32
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/examples/init.pp.erb +0 -12
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +0 -48
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +0 -1
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +0 -6
- data/vendored/puppet/lib/puppet/pops/model/ast.pp +0 -695
- data/vendored/puppet/lib/puppet/pops/parser/egrammar.ra +0 -937
- data/vendored/puppet/lib/puppet/pops/resource/resource_type_set.pcore +0 -22
- data/vendored/puppet/lib/puppet/util/libuser.conf +0 -15
- data/vendored/puppet/lib/puppet/vendor/deep_merge/CHANGELOG +0 -45
- data/vendored/puppet/lib/puppet/vendor/deep_merge/Gemfile +0 -3
- data/vendored/puppet/lib/puppet/vendor/deep_merge/LICENSE +0 -21
- data/vendored/puppet/lib/puppet/vendor/deep_merge/PUPPET_README.md +0 -6
- data/vendored/puppet/lib/puppet/vendor/deep_merge/README.md +0 -113
- data/vendored/puppet/lib/puppet/vendor/deep_merge/Rakefile +0 -19
- data/vendored/puppet/lib/puppet/vendor/deep_merge/deep_merge.gemspec +0 -35
- data/vendored/puppet/lib/puppet/vendor/pathspec/CHANGELOG.md +0 -2
- data/vendored/puppet/lib/puppet/vendor/pathspec/LICENSE +0 -201
- data/vendored/puppet/lib/puppet/vendor/pathspec/PUPPET_README.md +0 -6
- data/vendored/puppet/lib/puppet/vendor/pathspec/README.md +0 -53
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/locales/config.yaml +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f2d9129386dc3a217bf9af861ea74bce3ab86dd
|
4
|
+
data.tar.gz: d5dc3738a58d8eb61b014f1fb4f51d06bf604558
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55407e4f976256368488f4c17a6d1cfacd909f7334052a152f89868f7d4103e7dc7e3e10344bbc8b2dfcfb39805fab908bc89ae40cc83c3d056bd70b62436fbc
|
7
|
+
data.tar.gz: '03808cd73c73b89ad00583e05539ca669302a30011c2c051b8abfd6947685c1269472c8a62b5a4def7bdcf94cec3902f4521a00743804146e05754faf29ab17a'
|
data/exe/bolt
CHANGED
data/lib/bolt.rb
CHANGED
data/lib/bolt/cli.rb
CHANGED
@@ -6,6 +6,8 @@ require 'json'
|
|
6
6
|
require 'bolt/node'
|
7
7
|
require 'bolt/version'
|
8
8
|
require 'bolt/executor'
|
9
|
+
require 'bolt/config'
|
10
|
+
require 'io/console'
|
9
11
|
|
10
12
|
module Bolt
|
11
13
|
class CLIError < RuntimeError
|
@@ -26,18 +28,18 @@ Usage: bolt <subcommand> <action> [options]
|
|
26
28
|
Available subcommands:
|
27
29
|
bolt command run <command> Run a command remotely
|
28
30
|
bolt script run <script> Upload a local script and run it remotely
|
29
|
-
bolt task run <task> [params] Run a Puppet
|
30
|
-
bolt plan run <plan> [params] Run a plan
|
31
|
+
bolt task run <task> [params] Run a Puppet task
|
32
|
+
bolt plan run <plan> [params] Run a Puppet task plan
|
31
33
|
bolt file upload <src> <dest> Upload a local file
|
32
34
|
|
33
35
|
where [options] are:
|
34
36
|
HELP
|
35
37
|
|
36
38
|
TASK_HELP = <<-HELP.freeze
|
37
|
-
Usage: bolt task <action> [options] [parameters]
|
39
|
+
Usage: bolt task <action> <task> [options] [parameters]
|
38
40
|
|
39
41
|
Available actions are:
|
40
|
-
run Run a task
|
42
|
+
run Run a Puppet task
|
41
43
|
|
42
44
|
Parameters are of the form <parameter>=<value>.
|
43
45
|
|
@@ -66,7 +68,7 @@ HELP
|
|
66
68
|
Usage: bolt plan <action> <plan> [options] [parameters]
|
67
69
|
|
68
70
|
Available actions are:
|
69
|
-
run Run a plan
|
71
|
+
run Run a Puppet task plan
|
70
72
|
|
71
73
|
Parameters are of the form <parameter>=<value>.
|
72
74
|
|
@@ -98,24 +100,33 @@ HELP
|
|
98
100
|
def create_option_parser(results)
|
99
101
|
OptionParser.new('') do |opts|
|
100
102
|
opts.on(
|
101
|
-
'-n', '--nodes
|
103
|
+
'-n', '--nodes NODES',
|
102
104
|
'Node(s) to connect to in URI format [protocol://]host[:port]',
|
103
105
|
'Eg. --nodes bolt.puppet.com',
|
104
106
|
'Eg. --nodes localhost,ssh://nix.com:2222,winrm://windows.puppet.com',
|
105
107
|
"\n",
|
108
|
+
'* NODES can either be comma-separated, \'@<file>\' to read',
|
109
|
+
'* nodes from a file, or \'-\' to read from stdin',
|
106
110
|
'* Windows nodes must specify protocol with winrm://',
|
107
111
|
'* protocol is `ssh` by default, may be `ssh` or `winrm`',
|
108
112
|
'* port is `22` by default for SSH, `5985` for winrm (Optional)'
|
109
113
|
) do |nodes|
|
110
|
-
results[:nodes] = nodes
|
114
|
+
results[:nodes] = parse_nodes(nodes)
|
111
115
|
end
|
112
116
|
opts.on('-u', '--user USER',
|
113
117
|
"User to authenticate as (Optional)") do |user|
|
114
118
|
results[:user] = user
|
115
119
|
end
|
116
|
-
opts.on('-p', '--password PASSWORD',
|
117
|
-
|
118
|
-
|
120
|
+
opts.on('-p', '--password [PASSWORD]',
|
121
|
+
'Password to authenticate with (Optional).',
|
122
|
+
'Omit the value to prompt for the password.') do |password|
|
123
|
+
if password.nil?
|
124
|
+
STDOUT.print "Please enter your password: "
|
125
|
+
results[:password] = STDIN.noecho(&:gets).chomp
|
126
|
+
STDOUT.puts
|
127
|
+
else
|
128
|
+
results[:password] = password
|
129
|
+
end
|
119
130
|
end
|
120
131
|
results[:concurrency] = 100
|
121
132
|
opts.on('-c', '--concurrency CONCURRENCY', Integer,
|
@@ -130,6 +141,11 @@ HELP
|
|
130
141
|
"Parameters to a task or plan") do |params|
|
131
142
|
results[:task_options] = parse_params(params)
|
132
143
|
end
|
144
|
+
results[:insecure] = false
|
145
|
+
opts.on('-k', '--insecure',
|
146
|
+
"Whether to connect insecurely ") do |insecure|
|
147
|
+
results[:insecure] = insecure
|
148
|
+
end
|
133
149
|
opts.on_tail('--[no-]tty',
|
134
150
|
"Request a pseudo TTY on nodes that support it") do |tty|
|
135
151
|
results[:tty] = tty
|
@@ -138,10 +154,10 @@ HELP
|
|
138
154
|
results[:help] = true
|
139
155
|
end
|
140
156
|
opts.on_tail('--verbose', 'Display verbose logging') do |_|
|
141
|
-
|
157
|
+
results[:verbose] = true
|
142
158
|
end
|
143
159
|
opts.on_tail('--debug', 'Display debug logging') do |_|
|
144
|
-
|
160
|
+
results[:debug] = true
|
145
161
|
end
|
146
162
|
opts.on_tail('--version', 'Display the version') do |_|
|
147
163
|
puts Bolt::VERSION
|
@@ -171,6 +187,12 @@ HELP
|
|
171
187
|
options[:action] = remaining.shift
|
172
188
|
options[:object] = remaining.shift
|
173
189
|
|
190
|
+
if options[:debug]
|
191
|
+
Bolt.log_level = Logger::DEBUG
|
192
|
+
elsif options[:verbose]
|
193
|
+
Bolt.log_level = Logger::INFO
|
194
|
+
end
|
195
|
+
|
174
196
|
if options[:help]
|
175
197
|
print_help(options[:mode])
|
176
198
|
raise Bolt::CLIExit
|
@@ -212,6 +234,11 @@ HELP
|
|
212
234
|
puts parser.help
|
213
235
|
end
|
214
236
|
|
237
|
+
def parse_nodes(nodes)
|
238
|
+
list = get_arg_input(nodes)
|
239
|
+
list.split(/[[:space:],]+/).reject(&:empty?).uniq
|
240
|
+
end
|
241
|
+
|
215
242
|
def parse_params(params)
|
216
243
|
json = get_arg_input(params)
|
217
244
|
JSON.parse(json)
|
@@ -238,12 +265,15 @@ HELP
|
|
238
265
|
|
239
266
|
def validate(options)
|
240
267
|
unless MODES.include?(options[:mode])
|
241
|
-
raise Bolt::CLIError,
|
268
|
+
raise Bolt::CLIError,
|
269
|
+
"Expected subcommand '#{options[:mode]}' to be one of " \
|
270
|
+
"#{MODES.join(', ')}"
|
242
271
|
end
|
243
272
|
|
244
273
|
unless ACTIONS.include?(options[:action])
|
245
274
|
raise Bolt::CLIError,
|
246
|
-
"Expected action to be one of
|
275
|
+
"Expected action '#{options[:action]}' to be one of " \
|
276
|
+
"#{ACTIONS.join(', ')}"
|
247
277
|
end
|
248
278
|
|
249
279
|
if options[:mode] != 'file' && !options[:leftovers].empty?
|
@@ -280,23 +310,26 @@ HELP
|
|
280
310
|
end
|
281
311
|
end
|
282
312
|
|
313
|
+
config = Bolt::Config.new(concurrency: options[:concurrency],
|
314
|
+
user: options[:user],
|
315
|
+
password: options[:password],
|
316
|
+
tty: options[:tty],
|
317
|
+
insecure: options[:insecure])
|
318
|
+
executor = Bolt::Executor.new(config)
|
319
|
+
|
283
320
|
if options[:mode] == 'plan'
|
284
|
-
execute_plan(options)
|
321
|
+
execute_plan(executor, options)
|
285
322
|
else
|
286
|
-
nodes = options[:nodes]
|
287
|
-
Bolt::Node.from_uri(node, options[:user], options[:password],
|
288
|
-
tty: options[:tty])
|
289
|
-
end
|
323
|
+
nodes = executor.from_uris(options[:nodes])
|
290
324
|
|
291
325
|
results = nil
|
292
326
|
elapsed_time = Benchmark.realtime do
|
293
|
-
executor = Bolt::Executor.new(nodes, options[:concurrency])
|
294
327
|
results =
|
295
328
|
case options[:mode]
|
296
329
|
when 'command'
|
297
|
-
executor.run_command(options[:object])
|
330
|
+
executor.run_command(nodes, options[:object])
|
298
331
|
when 'script'
|
299
|
-
executor.run_script(options[:object])
|
332
|
+
executor.run_script(nodes, options[:object])
|
300
333
|
when 'task'
|
301
334
|
task_name = options[:object]
|
302
335
|
|
@@ -304,7 +337,9 @@ HELP
|
|
304
337
|
input_method = metadata['input_method']
|
305
338
|
|
306
339
|
input_method ||= 'both'
|
307
|
-
executor.run_task(
|
340
|
+
executor.run_task(
|
341
|
+
nodes, path, input_method, options[:task_options]
|
342
|
+
)
|
308
343
|
when 'file'
|
309
344
|
src = options[:object]
|
310
345
|
dest = options[:leftovers].first
|
@@ -315,7 +350,7 @@ HELP
|
|
315
350
|
raise Bolt::CLIError, "The source file '#{src}' does not exist"
|
316
351
|
end
|
317
352
|
|
318
|
-
executor.file_upload(src, dest)
|
353
|
+
executor.file_upload(nodes, src, dest)
|
319
354
|
end
|
320
355
|
end
|
321
356
|
|
@@ -323,16 +358,15 @@ HELP
|
|
323
358
|
end
|
324
359
|
end
|
325
360
|
|
326
|
-
def execute_plan(options)
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
options[:modules])
|
332
|
-
rescue Puppet::Error
|
333
|
-
raise Bolt::CLIError, "Exiting because of an error in Puppet code"
|
361
|
+
def execute_plan(executor, options)
|
362
|
+
result = Puppet.override(bolt_executor: executor) do
|
363
|
+
run_plan(options[:object],
|
364
|
+
options[:task_options],
|
365
|
+
options[:modules])
|
334
366
|
end
|
335
367
|
puts result
|
368
|
+
rescue Puppet::Error
|
369
|
+
raise Bolt::CLIError, "Exiting because of an error in Puppet code"
|
336
370
|
end
|
337
371
|
|
338
372
|
def colorize(result, stream)
|
data/lib/bolt/config.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Bolt
|
2
|
+
Config = Struct.new(:concurrency,
|
3
|
+
:user,
|
4
|
+
:password,
|
5
|
+
:tty,
|
6
|
+
:insecure) do
|
7
|
+
|
8
|
+
DEFAULTS = {
|
9
|
+
concurrency: 100,
|
10
|
+
tty: false,
|
11
|
+
insecure: false
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
def initialize(**kwargs)
|
15
|
+
super()
|
16
|
+
DEFAULTS.merge(kwargs).each { |k, v| self[k] = v }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/bolt/executor.rb
CHANGED
@@ -1,27 +1,32 @@
|
|
1
1
|
require 'concurrent'
|
2
2
|
require 'bolt/result'
|
3
|
+
require 'bolt/config'
|
3
4
|
|
4
5
|
module Bolt
|
5
6
|
class Executor
|
6
|
-
def
|
7
|
-
|
7
|
+
def initialize(config = Bolt::Config.new)
|
8
|
+
@config = config
|
8
9
|
end
|
9
10
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
11
|
+
def from_uris(nodes)
|
12
|
+
nodes.map do |node|
|
13
|
+
Bolt::Node.from_uri(node, config: @config)
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
|
-
def
|
17
|
+
def on(nodes)
|
16
18
|
results = Concurrent::Map.new
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
+
poolsize = [nodes.length, @config[:concurrency]].min
|
21
|
+
pool = Concurrent::FixedThreadPool.new(poolsize)
|
22
|
+
nodes.each { |node|
|
20
23
|
pool.post do
|
21
24
|
results[node] =
|
22
25
|
begin
|
23
26
|
node.connect
|
24
27
|
yield node
|
28
|
+
rescue Bolt::Node::BaseError => ex
|
29
|
+
Bolt::ErrorResult.new(ex.message, ex.issue_code, ex.kind)
|
25
30
|
rescue StandardError => ex
|
26
31
|
node.logger.error(ex)
|
27
32
|
Bolt::ExceptionResult.new(ex)
|
@@ -36,26 +41,26 @@ module Bolt
|
|
36
41
|
results_to_hash(results)
|
37
42
|
end
|
38
43
|
|
39
|
-
def run_command(command)
|
40
|
-
|
44
|
+
def run_command(nodes, command)
|
45
|
+
on(nodes) do |node|
|
41
46
|
node.run_command(command)
|
42
47
|
end
|
43
48
|
end
|
44
49
|
|
45
|
-
def run_script(script)
|
46
|
-
|
50
|
+
def run_script(nodes, script)
|
51
|
+
on(nodes) do |node|
|
47
52
|
node.run_script(script)
|
48
53
|
end
|
49
54
|
end
|
50
55
|
|
51
|
-
def run_task(task, input_method, arguments)
|
52
|
-
|
56
|
+
def run_task(nodes, task, input_method, arguments)
|
57
|
+
on(nodes) do |node|
|
53
58
|
node.run_task(task, input_method, arguments)
|
54
59
|
end
|
55
60
|
end
|
56
61
|
|
57
|
-
def file_upload(source, destination)
|
58
|
-
|
62
|
+
def file_upload(nodes, source, destination)
|
63
|
+
on(nodes) do |node|
|
59
64
|
node.upload(source, destination)
|
60
65
|
end
|
61
66
|
end
|
data/lib/bolt/node.rb
CHANGED
@@ -2,14 +2,14 @@ require 'logger'
|
|
2
2
|
require 'bolt/node_uri'
|
3
3
|
require 'bolt/node/formatter'
|
4
4
|
require 'bolt/result'
|
5
|
+
require 'bolt/config'
|
5
6
|
|
6
7
|
module Bolt
|
7
8
|
class Node
|
8
9
|
STDIN_METHODS = %w[both stdin].freeze
|
9
10
|
ENVIRONMENT_METHODS = %w[both environment].freeze
|
10
11
|
|
11
|
-
def self.from_uri(uri_string,
|
12
|
-
**kwargs)
|
12
|
+
def self.from_uri(uri_string, **kwargs)
|
13
13
|
uri = NodeURI.new(uri_string)
|
14
14
|
klass = case uri.scheme
|
15
15
|
when 'winrm'
|
@@ -21,21 +21,23 @@ module Bolt
|
|
21
21
|
end
|
22
22
|
klass.new(uri.hostname,
|
23
23
|
uri.port,
|
24
|
-
uri.user
|
25
|
-
uri.password
|
26
|
-
uri: uri_string,
|
24
|
+
uri.user,
|
25
|
+
uri.password,
|
26
|
+
uri: uri_string,
|
27
|
+
**kwargs)
|
27
28
|
end
|
28
29
|
|
29
30
|
attr_reader :logger, :host, :uri, :user, :password
|
30
31
|
|
31
|
-
def initialize(host, port = nil, user = nil,
|
32
|
-
|
32
|
+
def initialize(host, port = nil, user = nil, password = nil, uri: nil,
|
33
|
+
config: Bolt::Config.new,
|
33
34
|
log_level: Bolt.log_level || Logger::WARN)
|
34
35
|
@host = host
|
35
|
-
@user = user
|
36
36
|
@port = port
|
37
|
-
@
|
38
|
-
@
|
37
|
+
@user = user || config[:user]
|
38
|
+
@password = password || config[:password]
|
39
|
+
@tty = config[:tty]
|
40
|
+
@insecure = config[:insecure]
|
39
41
|
@uri = uri
|
40
42
|
|
41
43
|
@logger = init_logger(level: log_level)
|
@@ -74,6 +76,7 @@ module Bolt
|
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
79
|
+
require 'bolt/node/errors'
|
77
80
|
require 'bolt/node/ssh'
|
78
81
|
require 'bolt/node/winrm'
|
79
82
|
require 'bolt/node/orch'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Bolt
|
2
|
+
class Node
|
3
|
+
class BaseError < StandardError
|
4
|
+
attr_reader :issue_code
|
5
|
+
|
6
|
+
def initialize(message, issue_code)
|
7
|
+
super(message)
|
8
|
+
@issue_code = issue_code
|
9
|
+
end
|
10
|
+
|
11
|
+
def kind
|
12
|
+
'puppetlabs.tasks/node-error'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class ConnectError < BaseError
|
17
|
+
def kind
|
18
|
+
'puppetlabs.tasks/connect-error'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/bolt/node/ssh.rb
CHANGED
@@ -6,13 +6,36 @@ require 'bolt/node/result'
|
|
6
6
|
module Bolt
|
7
7
|
class SSH < Node
|
8
8
|
def connect
|
9
|
-
options = {
|
10
|
-
|
9
|
+
options = {
|
10
|
+
logger: @transport_logger,
|
11
|
+
non_interactive: true
|
12
|
+
}
|
13
|
+
|
11
14
|
options[:port] = @port if @port
|
12
15
|
options[:password] = @password if @password
|
16
|
+
options[:verify_host_key] = if @insecure
|
17
|
+
Net::SSH::Verifiers::Lenient.new
|
18
|
+
else
|
19
|
+
Net::SSH::Verifiers::Secure.new
|
20
|
+
end
|
13
21
|
|
14
22
|
@session = Net::SSH.start(@host, @user, options)
|
15
23
|
@logger.debug { "Opened session" }
|
24
|
+
rescue Net::SSH::AuthenticationFailed => e
|
25
|
+
raise Bolt::Node::ConnectError.new(
|
26
|
+
e.message,
|
27
|
+
'AUTH_ERROR'
|
28
|
+
)
|
29
|
+
rescue Net::SSH::HostKeyError => e
|
30
|
+
raise Bolt::Node::ConnectError.new(
|
31
|
+
"Host key verification failed for #{@uri}: #{e.message}",
|
32
|
+
'HOST_KEY_ERROR'
|
33
|
+
)
|
34
|
+
rescue StandardError => e
|
35
|
+
raise Bolt::Node::ConnectError.new(
|
36
|
+
"Failed to connect to #{@uri}: #{e.message}",
|
37
|
+
'CONNECT_ERROR'
|
38
|
+
)
|
16
39
|
end
|
17
40
|
|
18
41
|
def disconnect
|