bolt 0.20.2 → 0.20.3
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/puppetdb_fact.rb +1 -5
- data/lib/bolt/cli.rb +4 -6
- data/lib/bolt/config.rb +3 -3
- data/lib/bolt/error.rb +13 -0
- data/lib/bolt/executor.rb +1 -1
- data/lib/bolt/inventory.rb +1 -1
- data/lib/bolt/logger.rb +1 -1
- data/lib/bolt/outputter/human.rb +4 -14
- data/lib/bolt/pal.rb +30 -21
- data/lib/bolt/transport/orch.rb +1 -1
- data/lib/bolt/transport/orch/connection.rb +1 -1
- data/lib/bolt/transport/ssh.rb +3 -3
- data/lib/bolt/transport/winrm.rb +3 -3
- data/lib/bolt/util.rb +3 -3
- data/lib/bolt/version.rb +1 -1
- data/modules/facts/tasks/bash.sh +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 607e97f4d7609e2927f6e055baec22293cefb698
|
4
|
+
data.tar.gz: 7481be4e30655f46ee4908fb735dbcdc6de2383f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82322ab31eaeddbc94d4d50ec10dd494c107de3837e3eaaee1ce727827133a921f92fe794585fc2e9f79126afc4f9a344e7eaffbd23987f55ff8b88340ddb84f
|
7
|
+
data.tar.gz: 1a7918248d6319a32fe7ca5daa73b6c506ea15d5cb66f733f6f562038ffeb228115f725d01e3fdce5a30a3bec20abe02e3ad0f35288d8001995fe801b62a4a8b
|
@@ -29,10 +29,6 @@ Puppet::Functions.create_function(:puppetdb_fact) do
|
|
29
29
|
)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
puppetdb_client.facts_for_node(certnames)
|
34
|
-
rescue StandardError => e
|
35
|
-
raise Bolt::CLIError, "Could not retrieve targets from PuppetDB: #{e}"
|
36
|
-
end
|
32
|
+
puppetdb_client.facts_for_node(certnames)
|
37
33
|
end
|
38
34
|
end
|
data/lib/bolt/cli.rb
CHANGED
@@ -307,7 +307,7 @@ Available options are:
|
|
307
307
|
def read_arg_file(file)
|
308
308
|
File.read(file)
|
309
309
|
rescue StandardError => err
|
310
|
-
raise Bolt::
|
310
|
+
raise Bolt::FileError.new("Error attempting to read #{file}: #{err}", file)
|
311
311
|
end
|
312
312
|
end
|
313
313
|
|
@@ -481,8 +481,6 @@ Available options are:
|
|
481
481
|
|
482
482
|
def query_puppetdb_nodes(query)
|
483
483
|
puppetdb_client.query_certnames(query)
|
484
|
-
rescue StandardError => e
|
485
|
-
raise Bolt::CLIError, "Could not retrieve targets from PuppetDB: #{e}"
|
486
484
|
end
|
487
485
|
|
488
486
|
def execute(options)
|
@@ -618,12 +616,12 @@ Available options are:
|
|
618
616
|
stat = file_stat(path)
|
619
617
|
|
620
618
|
if !stat.readable?
|
621
|
-
raise Bolt::
|
619
|
+
raise Bolt::FileError.new("The #{type} '#{path}' is unreadable", path)
|
622
620
|
elsif !stat.file?
|
623
|
-
raise Bolt::
|
621
|
+
raise Bolt::FileError.new("The #{type} '#{path}' is not a file", path)
|
624
622
|
end
|
625
623
|
rescue Errno::ENOENT
|
626
|
-
raise Bolt::
|
624
|
+
raise Bolt::FileError.new("The #{type} '#{path}' does not exist", path)
|
627
625
|
end
|
628
626
|
|
629
627
|
def file_stat(path)
|
data/lib/bolt/config.rb
CHANGED
@@ -200,16 +200,16 @@ module Bolt
|
|
200
200
|
def validate
|
201
201
|
self[:log].each_pair do |name, params|
|
202
202
|
if params.key?(:level) && !Bolt::Logger.valid_level?(params[:level])
|
203
|
-
raise Bolt::
|
203
|
+
raise Bolt::ValidationError,
|
204
204
|
"level of log #{name} must be one of: #{Bolt::Logger.levels.join(', ')}; received #{params[:level]}"
|
205
205
|
end
|
206
206
|
if params.key?(:append) && params[:append] != true && params[:append] != false
|
207
|
-
raise Bolt::
|
207
|
+
raise Bolt::ValidationError, "append flag of log #{name} must be a Boolean, received #{params[:append]}"
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
211
|
unless %w[human json].include? self[:format]
|
212
|
-
raise Bolt::
|
212
|
+
raise Bolt::ValidationError, "Unsupported format: '#{self[:format]}'"
|
213
213
|
end
|
214
214
|
|
215
215
|
unless self[:transport].nil? || Bolt::TRANSPORTS.include?(self[:transport].to_sym)
|
data/lib/bolt/error.rb
CHANGED
@@ -64,6 +64,7 @@ module Bolt
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
# This class is used to treat a Puppet Error datatype as a ruby error outside PAL
|
67
68
|
class PuppetError < Error
|
68
69
|
def self.from_error(err)
|
69
70
|
new(err.msg, err.kind, err.details, err.issue_code)
|
@@ -78,4 +79,16 @@ module Bolt
|
|
78
79
|
'result_string' => result_str })
|
79
80
|
end
|
80
81
|
end
|
82
|
+
|
83
|
+
class ValidationError < Bolt::Error
|
84
|
+
def initialize(msg)
|
85
|
+
super(msg, 'bolt.transport/validation-error')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class FileError < Bolt::Error
|
90
|
+
def initialize(msg, path)
|
91
|
+
super(msg, 'bolt/file-error', { "path" => path })
|
92
|
+
end
|
93
|
+
end
|
81
94
|
end
|
data/lib/bolt/executor.rb
CHANGED
@@ -27,7 +27,7 @@ module Bolt
|
|
27
27
|
|
28
28
|
@noop = noop
|
29
29
|
@run_as = nil
|
30
|
-
@pool = Concurrent::
|
30
|
+
@pool = Concurrent::ThreadPoolExecutor.new(max_threads: @config[:concurrency])
|
31
31
|
@logger.debug { "Started with #{@config[:concurrency]} max thread(s)" }
|
32
32
|
@notifier = Bolt::Notifier.new
|
33
33
|
end
|
data/lib/bolt/inventory.rb
CHANGED
@@ -45,7 +45,7 @@ module Bolt
|
|
45
45
|
begin
|
46
46
|
data = YAML.safe_load(ENV[ENVIRONMENT_VAR])
|
47
47
|
rescue Psych::Exception
|
48
|
-
raise Bolt::
|
48
|
+
raise Bolt::Error.new("Could not parse inventory from $#{ENVIRONMENT_VAR}", 'bolt/parse-error')
|
49
49
|
end
|
50
50
|
else
|
51
51
|
data = Bolt::Util.read_config_file(config[:inventoryfile], default_paths, 'inventory')
|
data/lib/bolt/logger.rb
CHANGED
@@ -56,7 +56,7 @@ module Bolt
|
|
56
56
|
level: default_level
|
57
57
|
)
|
58
58
|
rescue ArgumentError => e
|
59
|
-
raise Bolt::
|
59
|
+
raise Bolt::Error.new("Failed to open log #{name}: #{e.message}", 'bolt/log-error')
|
60
60
|
end
|
61
61
|
|
62
62
|
root_logger.add_appenders appender
|
data/lib/bolt/outputter/human.rb
CHANGED
@@ -161,22 +161,12 @@ module Bolt
|
|
161
161
|
@stream.puts(plan_info)
|
162
162
|
end
|
163
163
|
|
164
|
-
# @param [
|
165
|
-
def print_plan_result(
|
166
|
-
if
|
164
|
+
# @param [Bolt::PlanResult] A PlanResult object
|
165
|
+
def print_plan_result(plan_result)
|
166
|
+
if plan_result.value.nil?
|
167
167
|
@stream.puts("Plan completed successfully with no result")
|
168
|
-
# Otherwise if object has a json representation display it
|
169
|
-
elsif result.respond_to?(:to_json)
|
170
|
-
# Guard against to_json methods that don't accept options
|
171
|
-
# and don't print empty results on multiple lines
|
172
|
-
if result.method(:to_json).arity == 0 ||
|
173
|
-
(result.respond_to?(:empty?) && result.empty?)
|
174
|
-
@stream.puts(result.to_json)
|
175
|
-
else
|
176
|
-
@stream.puts(::JSON.pretty_generate(result, quirks_mode: true))
|
177
|
-
end
|
178
168
|
else
|
179
|
-
@stream.puts
|
169
|
+
@stream.puts(::JSON.pretty_generate(plan_result, quirks_mode: true))
|
180
170
|
end
|
181
171
|
end
|
182
172
|
|
data/lib/bolt/pal.rb
CHANGED
@@ -9,6 +9,31 @@ module Bolt
|
|
9
9
|
BOLTLIB_PATH = File.join(__FILE__, '../../../bolt-modules')
|
10
10
|
MODULES_PATH = File.join(__FILE__, '../../../modules')
|
11
11
|
|
12
|
+
# PALError is used to convert errors from executing puppet code into
|
13
|
+
# Bolt::Errors
|
14
|
+
class PALError < Bolt::Error
|
15
|
+
# Puppet sometimes rescues exceptions notes the location and reraises.
|
16
|
+
# Return the original error.
|
17
|
+
def self.from_preformatted_error(err)
|
18
|
+
if err.cause&.is_a? Bolt::Error
|
19
|
+
err.cause
|
20
|
+
else
|
21
|
+
from_error(err.cause || err)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Generate a Bolt::Pal::PALError for non-bolt errors
|
26
|
+
def self.from_error(err)
|
27
|
+
e = new(err.message)
|
28
|
+
e.set_backtrace(err.backtrace)
|
29
|
+
e
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(msg)
|
33
|
+
super(msg, 'bolt/pal-error')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
12
37
|
def initialize(config)
|
13
38
|
# Nothing works without initialized this global state. Reinitializing
|
14
39
|
# is safe and in practice only happen in tests
|
@@ -40,7 +65,7 @@ module Bolt
|
|
40
65
|
begin
|
41
66
|
require_relative '../../vendored/require_vendored'
|
42
67
|
rescue LoadError
|
43
|
-
raise Bolt::
|
68
|
+
raise Bolt::Error.new("Puppet must be installed to execute tasks", "bolt/puppet-missing")
|
44
69
|
end
|
45
70
|
|
46
71
|
require 'bolt/pal/logging'
|
@@ -72,25 +97,9 @@ module Bolt
|
|
72
97
|
begin
|
73
98
|
yield compiler
|
74
99
|
rescue Puppet::PreformattedError => err
|
75
|
-
|
76
|
-
# Return the original error.
|
77
|
-
if err.cause
|
78
|
-
if err.cause.is_a? Bolt::Error
|
79
|
-
err.cause
|
80
|
-
else
|
81
|
-
e = Bolt::CLIError.new(err.cause.message)
|
82
|
-
e.set_backtrace(err.cause.backtrace)
|
83
|
-
e
|
84
|
-
end
|
85
|
-
else
|
86
|
-
e = Bolt::CLIError.new(err.message)
|
87
|
-
e.set_backtrace(err.backtrace)
|
88
|
-
e
|
89
|
-
end
|
100
|
+
PALError.from_preformatted_error(err)
|
90
101
|
rescue StandardError => err
|
91
|
-
|
92
|
-
e.set_backtrace(err.backtrace)
|
93
|
-
e
|
102
|
+
PALError.from_preformatted_error(err)
|
94
103
|
end
|
95
104
|
end
|
96
105
|
end
|
@@ -188,7 +197,7 @@ module Bolt
|
|
188
197
|
end
|
189
198
|
|
190
199
|
if task.nil?
|
191
|
-
raise Bolt::
|
200
|
+
raise Bolt::Error.new(Bolt::Error.unknown_task(task_name), 'bolt/unknown-task')
|
192
201
|
end
|
193
202
|
|
194
203
|
task.task_hash
|
@@ -222,7 +231,7 @@ module Bolt
|
|
222
231
|
end
|
223
232
|
|
224
233
|
if plan_info.nil?
|
225
|
-
raise Bolt::
|
234
|
+
raise Bolt::Error.new(Bolt::Error.unknown_plan(plan_name), 'bolt/unknown-plan')
|
226
235
|
end
|
227
236
|
plan_info
|
228
237
|
end
|
data/lib/bolt/transport/orch.rb
CHANGED
@@ -25,7 +25,7 @@ module Bolt
|
|
25
25
|
def self.validate(options)
|
26
26
|
validation_flag = options['local-validation']
|
27
27
|
unless !!validation_flag == validation_flag
|
28
|
-
raise Bolt::
|
28
|
+
raise Bolt::ValidationError, 'local-validation option must be a Boolean true or false'
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -23,11 +23,11 @@ module Bolt
|
|
23
23
|
client_opts = client_keys.each_with_object({}) do |k, acc|
|
24
24
|
acc[k] = opts[k] if opts.include?(k)
|
25
25
|
end
|
26
|
+
client_opts['User-Agent'] = "Bolt/#{VERSION}"
|
26
27
|
logger.debug("Creating orchestrator client for #{client_opts}")
|
27
28
|
|
28
29
|
@client = OrchestratorClient.new(client_opts, true)
|
29
30
|
@plan_job = start_plan(plan_context)
|
30
|
-
|
31
31
|
@environment = opts["task-environment"]
|
32
32
|
end
|
33
33
|
|
data/lib/bolt/transport/ssh.rb
CHANGED
@@ -22,12 +22,12 @@ module Bolt
|
|
22
22
|
|
23
23
|
host_key = options['host-key-check']
|
24
24
|
unless !!host_key == host_key
|
25
|
-
raise Bolt::
|
25
|
+
raise Bolt::ValidationError, 'host-key-check option must be a Boolean true or false'
|
26
26
|
end
|
27
27
|
|
28
28
|
if (key_opt = options['private-key'])
|
29
29
|
unless key_opt.instance_of?(String) || (key_opt.instance_of?(Hash) && key_opt.include?('key-data'))
|
30
|
-
raise Bolt::
|
30
|
+
raise Bolt::ValidationError,
|
31
31
|
"private-key option must be the path to a private key file or a hash containing the 'key-data'"
|
32
32
|
end
|
33
33
|
end
|
@@ -35,7 +35,7 @@ module Bolt
|
|
35
35
|
timeout_value = options['connect-timeout']
|
36
36
|
unless timeout_value.is_a?(Integer) || timeout_value.nil?
|
37
37
|
error_msg = "connect-timeout value must be an Integer, received #{timeout_value}:#{timeout_value.class}"
|
38
|
-
raise Bolt::
|
38
|
+
raise Bolt::ValidationError, error_msg
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
data/lib/bolt/transport/winrm.rb
CHANGED
@@ -16,18 +16,18 @@ module Bolt
|
|
16
16
|
def self.validate(options)
|
17
17
|
ssl_flag = options['ssl']
|
18
18
|
unless !!ssl_flag == ssl_flag
|
19
|
-
raise Bolt::
|
19
|
+
raise Bolt::ValidationError, 'ssl option must be a Boolean true or false'
|
20
20
|
end
|
21
21
|
|
22
22
|
ssl_verify_flag = options['ssl-verify']
|
23
23
|
unless !!ssl_verify_flag == ssl_verify_flag
|
24
|
-
raise Bolt::
|
24
|
+
raise Bolt::ValidationError, 'ssl-verify option must be a Boolean true or false'
|
25
25
|
end
|
26
26
|
|
27
27
|
timeout_value = options['connect-timeout']
|
28
28
|
unless timeout_value.is_a?(Integer) || timeout_value.nil?
|
29
29
|
error_msg = "connect-timeout value must be an Integer, received #{timeout_value}:#{timeout_value.class}"
|
30
|
-
raise Bolt::
|
30
|
+
raise Bolt::ValidationError, error_msg
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
data/lib/bolt/util.rb
CHANGED
@@ -20,12 +20,12 @@ module Bolt
|
|
20
20
|
File.open(path, "r:UTF-8") { |f| YAML.safe_load(f.read) }
|
21
21
|
rescue Errno::ENOENT
|
22
22
|
if path_passed
|
23
|
-
raise Bolt::
|
23
|
+
raise Bolt::FileError.new("Could not read #{file_name} file: #{path}", path)
|
24
24
|
end
|
25
25
|
rescue Psych::Exception
|
26
|
-
raise Bolt::
|
26
|
+
raise Bolt::FileError.new("Could not parse #{file_name} file: #{path}", path)
|
27
27
|
rescue IOError, SystemCallError
|
28
|
-
raise Bolt::
|
28
|
+
raise Bolt::FileError.new("Could not read #{file_name} file: #{path}", path)
|
29
29
|
end
|
30
30
|
|
31
31
|
def deep_merge(hash1, hash2)
|
data/lib/bolt/version.rb
CHANGED
data/modules/facts/tasks/bash.sh
CHANGED
@@ -29,6 +29,24 @@ if [ -z "${name}" ]; then
|
|
29
29
|
fi
|
30
30
|
fi
|
31
31
|
|
32
|
+
# if lsb not available try os-release
|
33
|
+
if [ -z "${name}" ]; then
|
34
|
+
if [ -e /etc/os-release ]; then
|
35
|
+
name=$(grep "^NAME" /etc/os-release | cut -d'=' -f2 | sed "s/\"//g")
|
36
|
+
release=$(grep "^VERSION_ID" /etc/os-release | cut -d'=' -f2 | sed "s/\"//g")
|
37
|
+
elif [-e /usr/lib/os-release ]; then
|
38
|
+
name=$(grep "^NAME" /usr/lib/os-release | cut -d'=' -f2 | sed "s/\"//g")
|
39
|
+
release=$(grep "^VERSION_ID" /usr/lib/os-release | cut -d'=' -f2 | sed "s/\"//g")
|
40
|
+
fi
|
41
|
+
if [ -n "${name}" ]; then
|
42
|
+
if echo "${name}" | egrep -iq "(.*red)(.*hat)"; then
|
43
|
+
name="RedHat"
|
44
|
+
elif echo "${name}" | egrep -iq "debian"; then
|
45
|
+
name="Debian"
|
46
|
+
fi
|
47
|
+
fi
|
48
|
+
fi
|
49
|
+
|
32
50
|
if [ -z "${name}" ]; then
|
33
51
|
name=$(uname)
|
34
52
|
release=$(uname -r)
|
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: 0.20.
|
4
|
+
version: 0.20.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|