bolt 1.22.0 → 1.23.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/catch_errors.rb +57 -0
- data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +6 -6
- data/lib/bolt/bolt_option_parser.rb +2 -2
- data/lib/bolt/config.rb +1 -1
- data/lib/bolt/executor.rb +5 -1
- data/lib/bolt/transport/local_windows.rb +5 -3
- data/lib/bolt/transport/powershell.rb +4 -4
- data/lib/bolt/transport/winrm/connection.rb +1 -1
- data/lib/bolt/version.rb +1 -1
- data/modules/canary/plans/init.pp +27 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0387b7b6348b7003f02a2433a92e90c73464ac6a7d1cf135c847142bc44cb52
|
4
|
+
data.tar.gz: 502dc3c14c15925ff40604763b4cf5dc1e83d222e37b6c0a47cb5827f696e236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c89fe321fc1c14d00cc011fa346241aa140d5da3cce8f6ea9624e46df8e35a61a5cc4055371d94b61b2d53c46868f1a8dcbdf69ac1f05e065955b65ad36c3dd
|
7
|
+
data.tar.gz: 4a1ed6da115e53825f75f5a27a7452e57037874d0665244d8bf2a35aa7ab591765bbc8a879d3bbcf8737b20500b29dca1a60f7a46860bc22a71047f48a248fe9
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Catches errors in a given block and returns them. This will return the
|
4
|
+
# output of the block if no errors are raised. Accepts an optional list of
|
5
|
+
# error kinds to catch.
|
6
|
+
#
|
7
|
+
# **NOTE:** Not available in apply block
|
8
|
+
Puppet::Functions.create_function(:catch_errors) do
|
9
|
+
# @param error_types An array of error types to catch
|
10
|
+
# @param block The block of steps to catch errors on
|
11
|
+
# @return Undef If an error is raised in the block then the error will be
|
12
|
+
# returned, otherwise the result will be returned
|
13
|
+
# @example Catch errors for a block
|
14
|
+
# catch_errors() || {
|
15
|
+
# run_command("whoami", $nodes)
|
16
|
+
# run_command("adduser ryan", $nodes)
|
17
|
+
# }
|
18
|
+
# @example Catch parse errors for a block of code
|
19
|
+
# catch_errors(['bolt/parse-error']) || {
|
20
|
+
# run_plan('canary', $nodes)
|
21
|
+
# run_plan('other_plan)
|
22
|
+
# apply($nodes) || {
|
23
|
+
# notify { "Hello": }
|
24
|
+
# }
|
25
|
+
# }
|
26
|
+
dispatch :catch_errors do
|
27
|
+
optional_param 'Array[String[1]]', :error_types
|
28
|
+
block_param 'Callable[0, 0]', :block
|
29
|
+
end
|
30
|
+
|
31
|
+
def catch_errors(error_types = nil)
|
32
|
+
unless Puppet[:tasks]
|
33
|
+
raise Puppet::ParseErrorWithIssue
|
34
|
+
.from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
|
35
|
+
action: self.class.name)
|
36
|
+
end
|
37
|
+
|
38
|
+
executor = Puppet.lookup(:bolt_executor)
|
39
|
+
executor.report_function_call(self.class.name)
|
40
|
+
|
41
|
+
begin
|
42
|
+
yield
|
43
|
+
rescue Puppet::PreformattedError => e
|
44
|
+
if e.cause.is_a?(Bolt::Error)
|
45
|
+
if error_types.nil?
|
46
|
+
return e.cause.to_puppet_error
|
47
|
+
elsif error_types.include?(e.cause.to_h['kind'])
|
48
|
+
return e.cause.to_puppet_error
|
49
|
+
else
|
50
|
+
raise e
|
51
|
+
end
|
52
|
+
else
|
53
|
+
raise e
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -7,9 +7,9 @@ require 'bolt/error'
|
|
7
7
|
#
|
8
8
|
# **NOTE:** Not available in apply block
|
9
9
|
Puppet::Functions.create_function(:upload_file, Puppet::Functions::InternalFunction) do
|
10
|
-
# Upload a file.
|
11
|
-
# @param source A source path, either an absolute path or a modulename/filename selector for a
|
12
|
-
# <moduleroot>/files.
|
10
|
+
# Upload a file or directory.
|
11
|
+
# @param source A source path, either an absolute path or a modulename/filename selector for a
|
12
|
+
# file or directory in <moduleroot>/files.
|
13
13
|
# @param destination An absolute path on the target(s).
|
14
14
|
# @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
|
15
15
|
# @param options Additional options: '_catch_errors', '_run_as'.
|
@@ -27,9 +27,9 @@ Puppet::Functions.create_function(:upload_file, Puppet::Functions::InternalFunct
|
|
27
27
|
return_type 'ResultSet'
|
28
28
|
end
|
29
29
|
|
30
|
-
# Upload a file, logging the provided description.
|
31
|
-
# @param source A source path, either an absolute path or a modulename/filename selector for a
|
32
|
-
# <moduleroot>/files.
|
30
|
+
# Upload a file or directory, logging the provided description.
|
31
|
+
# @param source A source path, either an absolute path or a modulename/filename selector for a
|
32
|
+
# file or directory in <moduleroot>/files.
|
33
33
|
# @param destination An absolute path on the target(s).
|
34
34
|
# @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
|
35
35
|
# @param description A description to be output when calling this function.
|
@@ -22,7 +22,7 @@ Usage: bolt <subcommand> <action> [options]
|
|
22
22
|
|
23
23
|
Available subcommands:
|
24
24
|
bolt command run <command> Run a command remotely
|
25
|
-
bolt file upload <src> <dest> Upload a local file
|
25
|
+
bolt file upload <src> <dest> Upload a local file or directory
|
26
26
|
bolt script run <script> Upload a local script and run it remotely
|
27
27
|
bolt task show Show list of available tasks
|
28
28
|
bolt task show <task> Show documentation for task
|
@@ -93,7 +93,7 @@ Available options are:
|
|
93
93
|
Usage: bolt file <action> [options]
|
94
94
|
|
95
95
|
Available actions are:
|
96
|
-
upload <src> <dest> Upload local file <src> to <dest> on each node
|
96
|
+
upload <src> <dest> Upload local file or directory <src> to <dest> on each node
|
97
97
|
|
98
98
|
#{examples('file upload /tmp/source /etc/profile.d/login.sh', 'upload a file to')}
|
99
99
|
Available options are:
|
data/lib/bolt/config.rb
CHANGED
@@ -40,7 +40,7 @@ module Bolt
|
|
40
40
|
private-key tty tmpdir user connect-timeout
|
41
41
|
cacert token-file service-url interpreters file-protocol smb-port].freeze
|
42
42
|
|
43
|
-
PUPPETFILE_OPTIONS = %w[proxy].freeze
|
43
|
+
PUPPETFILE_OPTIONS = %w[proxy forge].freeze
|
44
44
|
|
45
45
|
def self.default
|
46
46
|
new(Bolt::Boltdir.new('.'), {})
|
data/lib/bolt/executor.rb
CHANGED
@@ -292,7 +292,11 @@ module Bolt
|
|
292
292
|
wait_until(wait_time, retry_interval) { transport.batch_connected?(batch) }
|
293
293
|
batch.map { |target| Result.new(target) }
|
294
294
|
rescue TimeoutError => e
|
295
|
-
batch.
|
295
|
+
available, unavailable = batch.partition { |target| transport.batch_connected?([target]) }
|
296
|
+
(
|
297
|
+
available.map { |target| Result.new(target) } +
|
298
|
+
unavailable.map { |target| Result.from_exception(target, e) }
|
299
|
+
)
|
296
300
|
end
|
297
301
|
end
|
298
302
|
end
|
@@ -63,7 +63,8 @@ module Bolt
|
|
63
63
|
private :with_tmpscript
|
64
64
|
|
65
65
|
def execute(*command, options)
|
66
|
-
|
66
|
+
# Interpreter can be an array or string. It will be appended to the command array.
|
67
|
+
command.unshift(options[:interpreter]).flatten! if options[:interpreter]
|
67
68
|
command = [options[:env]] + command if options[:env]
|
68
69
|
|
69
70
|
if options[:stdin]
|
@@ -106,7 +107,8 @@ module Bolt
|
|
106
107
|
arguments = unwrap_sensitive_args(arguments)
|
107
108
|
if Powershell.powershell_file?(file)
|
108
109
|
command = Powershell.run_script(arguments, file)
|
109
|
-
|
110
|
+
interpreter = ['powershell.exe', *Powershell.ps_args]
|
111
|
+
output = execute(command, dir: dir, interpreter: interpreter)
|
110
112
|
else
|
111
113
|
path, args = *Powershell.process_from_extension(file)
|
112
114
|
args += Powershell.escape_arguments(arguments)
|
@@ -166,7 +168,7 @@ module Bolt
|
|
166
168
|
if Powershell.powershell_file?(script) && stdin.nil?
|
167
169
|
command = Powershell.run_ps_task(arguments, script, input_method)
|
168
170
|
command = environment_params + Powershell.shell_init + command
|
169
|
-
interpreter ||= 'powershell.exe'
|
171
|
+
interpreter ||= ['powershell.exe', *Powershell.ps_args]
|
170
172
|
output =
|
171
173
|
if input_method == 'powershell'
|
172
174
|
execute(command, dir: dir, interpreter: interpreter)
|
@@ -4,9 +4,9 @@ module Bolt
|
|
4
4
|
module Transport
|
5
5
|
module Powershell
|
6
6
|
class << self
|
7
|
-
|
8
|
-
-NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass
|
9
|
-
|
7
|
+
def ps_args
|
8
|
+
%w[-NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass]
|
9
|
+
end
|
10
10
|
|
11
11
|
def powershell_file?(path)
|
12
12
|
Pathname(path).extname.casecmp('.ps1').zero?
|
@@ -22,7 +22,7 @@ module Bolt
|
|
22
22
|
when '.ps1'
|
23
23
|
[
|
24
24
|
'powershell.exe',
|
25
|
-
[*
|
25
|
+
[*ps_args, '-File', "\"#{path}\""]
|
26
26
|
]
|
27
27
|
when '.pp'
|
28
28
|
[
|
@@ -77,7 +77,7 @@ module Bolt
|
|
77
77
|
theres_your_problem = "\nAre you using SSL to connect to a non-SSL port?"
|
78
78
|
end
|
79
79
|
if target.options['ssl-verify'] && e.message.include?('certificate verify failed')
|
80
|
-
theres_your_problem = "\nIs the remote host using a self-signed SSL"\
|
80
|
+
theres_your_problem = "\nIs the remote host using a self-signed SSL "\
|
81
81
|
"certificate? Use --no-ssl-verify to disable "\
|
82
82
|
"remote host SSL verification."
|
83
83
|
end
|
data/lib/bolt/version.rb
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
# @summary
|
2
|
+
# Run a task, command or script on canary nodes before running it on all nodes.
|
3
|
+
#
|
4
|
+
# This plan accepts a action and a $nodes parameter. The action can be the name
|
5
|
+
# of a task, a script or a command to run. It will run the action on a canary
|
6
|
+
# group of nodes and only continue to the rest of the nodes if it succeeds on
|
7
|
+
# all canaries. This returns a ResultSet object with a Result for every node.
|
8
|
+
# Any skipped nodes will have a 'canary/skipped-node' error kind.
|
9
|
+
#
|
10
|
+
# @param task
|
11
|
+
# The name of the task to run. Mutually exclusive with command and script.
|
12
|
+
# @param command
|
13
|
+
# The command to run. Mutually exclusive with task and script.
|
14
|
+
# @param script
|
15
|
+
# The script to run. Mutually exclusive with task and command.
|
16
|
+
# @param nodes
|
17
|
+
# The target to run on.
|
18
|
+
# @param params
|
19
|
+
# The parameters to use for the task.
|
20
|
+
# @param canary_size
|
21
|
+
# How many targets to use in the canary group.
|
22
|
+
#
|
23
|
+
# @return ResultSet a merged resultset from running the action on all targets
|
24
|
+
#
|
25
|
+
# @example Run a command
|
26
|
+
# run_plan(canary, command => 'whoami', nodes => $mynodes)
|
27
|
+
|
1
28
|
plan canary(
|
2
29
|
Optional[String[0]] $task = undef,
|
3
30
|
Optional[String[0]] $command = undef,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bolt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -326,6 +326,7 @@ files:
|
|
326
326
|
- bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
|
327
327
|
- bolt-modules/boltlib/lib/puppet/functions/add_to_group.rb
|
328
328
|
- bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb
|
329
|
+
- bolt-modules/boltlib/lib/puppet/functions/catch_errors.rb
|
329
330
|
- bolt-modules/boltlib/lib/puppet/functions/facts.rb
|
330
331
|
- bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
|
331
332
|
- bolt-modules/boltlib/lib/puppet/functions/get_resources.rb
|