bolt 0.17.2 → 0.18.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/datatypes/result.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/resultset.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/target.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +30 -0
- data/bolt-modules/boltlib/lib/puppet/functions/facts.rb +30 -0
- data/bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb +4 -2
- data/bolt-modules/boltlib/lib/puppet/functions/file_upload.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_targets.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +3 -2
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +2 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_var.rb +8 -0
- data/bolt-modules/boltlib/lib/puppet/functions/vars.rb +9 -1
- data/exe/bolt +1 -0
- data/exe/bolt-inventory-pdb +1 -0
- data/lib/bolt.rb +2 -0
- data/lib/bolt/cli.rb +40 -34
- data/lib/bolt/config.rb +9 -2
- data/lib/bolt/error.rb +2 -0
- data/lib/bolt/executor.rb +2 -0
- data/lib/bolt/inventory.rb +36 -28
- data/lib/bolt/inventory/group.rb +14 -10
- data/lib/bolt/logger.rb +2 -0
- data/lib/bolt/node/errors.rb +2 -0
- data/lib/bolt/node/output.rb +2 -0
- data/lib/bolt/notifier.rb +2 -0
- data/lib/bolt/outputter.rb +2 -0
- data/lib/bolt/outputter/human.rb +28 -34
- data/lib/bolt/outputter/json.rb +7 -5
- data/lib/bolt/pal.rb +66 -30
- data/lib/bolt/puppetdb.rb +2 -0
- data/lib/bolt/puppetdb/client.rb +5 -3
- data/lib/bolt/puppetdb/config.rb +2 -0
- data/lib/bolt/result.rb +2 -0
- data/lib/bolt/result_set.rb +2 -0
- data/lib/bolt/target.rb +2 -0
- data/lib/bolt/transport/base.rb +4 -2
- data/lib/bolt/transport/local.rb +2 -0
- data/lib/bolt/transport/local/shell.rb +2 -0
- data/lib/bolt/transport/orch.rb +3 -1
- data/lib/bolt/transport/ssh.rb +3 -1
- data/lib/bolt/transport/ssh/connection.rb +3 -1
- data/lib/bolt/transport/winrm.rb +9 -2
- data/lib/bolt/transport/winrm/connection.rb +11 -3
- data/lib/bolt/util.rb +9 -7
- data/lib/bolt/version.rb +3 -1
- data/lib/bolt_ext/puppetdb_inventory.rb +3 -2
- data/modules/aggregate/lib/puppet/functions/aggregate/count.rb +2 -0
- data/modules/aggregate/lib/puppet/functions/aggregate/nodes.rb +2 -0
- data/modules/canary/lib/puppet/functions/canary/merge.rb +2 -0
- data/modules/canary/lib/puppet/functions/canary/random_split.rb +2 -0
- data/modules/canary/lib/puppet/functions/canary/skip.rb +2 -0
- metadata +37 -35
data/lib/bolt/puppetdb.rb
CHANGED
data/lib/bolt/puppetdb/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'uri'
|
3
5
|
require 'httpclient'
|
@@ -41,11 +43,11 @@ module Bolt
|
|
41
43
|
raise Bolt::PuppetDBError, "Failed to query PuppetDB: #{response.body}"
|
42
44
|
else
|
43
45
|
results = JSON.parse(response.body)
|
44
|
-
if results
|
45
|
-
fields = results.first
|
46
|
+
if results&.first && !results.first&.key?('certname')
|
47
|
+
fields = results.first&.keys
|
46
48
|
raise Bolt::PuppetDBError, "Query results did not contain a 'certname' field: got #{fields.join(', ')}"
|
47
49
|
end
|
48
|
-
results
|
50
|
+
results&.map { |result| result['certname'] }.uniq
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
data/lib/bolt/puppetdb/config.rb
CHANGED
data/lib/bolt/result.rb
CHANGED
data/lib/bolt/result_set.rb
CHANGED
data/lib/bolt/target.rb
CHANGED
data/lib/bolt/transport/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'logging'
|
2
4
|
|
3
5
|
module Bolt
|
@@ -53,7 +55,7 @@ module Bolt
|
|
53
55
|
end
|
54
56
|
|
55
57
|
def with_events(target, callback)
|
56
|
-
callback
|
58
|
+
callback&.call(type: :node_start, target: target)
|
57
59
|
|
58
60
|
result = begin
|
59
61
|
yield
|
@@ -61,7 +63,7 @@ module Bolt
|
|
61
63
|
Bolt::Result.from_exception(target, ex)
|
62
64
|
end
|
63
65
|
|
64
|
-
callback
|
66
|
+
callback&.call(type: :node_result, result: result)
|
65
67
|
result
|
66
68
|
end
|
67
69
|
|
data/lib/bolt/transport/local.rb
CHANGED
data/lib/bolt/transport/orch.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'base64'
|
2
4
|
require 'concurrent'
|
3
5
|
require 'json'
|
@@ -122,7 +124,7 @@ module Bolt
|
|
122
124
|
end
|
123
125
|
end
|
124
126
|
results.each do |result|
|
125
|
-
callback
|
127
|
+
callback&.call(type: :node_result, result: result)
|
126
128
|
end
|
127
129
|
end
|
128
130
|
|
data/lib/bolt/transport/ssh.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bolt/node/errors'
|
2
4
|
require 'bolt/transport/base'
|
3
5
|
require 'json'
|
@@ -57,7 +59,7 @@ module Bolt
|
|
57
59
|
yield conn
|
58
60
|
ensure
|
59
61
|
begin
|
60
|
-
conn
|
62
|
+
conn&.disconnect
|
61
63
|
rescue StandardError => ex
|
62
64
|
logger.info("Failed to close connection to #{target.uri} : #{ex.message}")
|
63
65
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'logging'
|
2
4
|
require 'shellwords'
|
3
5
|
require 'bolt/node/errors'
|
@@ -274,7 +276,7 @@ module Bolt
|
|
274
276
|
dir = make_tempdir
|
275
277
|
yield dir
|
276
278
|
ensure
|
277
|
-
dir
|
279
|
+
dir&.delete
|
278
280
|
end
|
279
281
|
|
280
282
|
def write_remote_executable(dir, file, filename = nil)
|
data/lib/bolt/transport/winrm.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bolt/transport/base'
|
2
4
|
|
3
5
|
module Bolt
|
@@ -8,7 +10,7 @@ module Bolt
|
|
8
10
|
].freeze
|
9
11
|
|
10
12
|
def self.options
|
11
|
-
%w[port user password connect-timeout ssl tmpdir cacert extensions]
|
13
|
+
%w[port user password connect-timeout ssl ssl-verify tmpdir cacert extensions]
|
12
14
|
end
|
13
15
|
|
14
16
|
def self.validate(options)
|
@@ -17,6 +19,11 @@ module Bolt
|
|
17
19
|
raise Bolt::CLIError, 'ssl option must be a Boolean true or false'
|
18
20
|
end
|
19
21
|
|
22
|
+
ssl_verify_flag = options['ssl-verify']
|
23
|
+
unless !!ssl_verify_flag == ssl_verify_flag
|
24
|
+
raise Bolt::CLIError, 'ssl-verify option must be a Boolean true or false'
|
25
|
+
end
|
26
|
+
|
20
27
|
timeout_value = options['connect-timeout']
|
21
28
|
unless timeout_value.is_a?(Integer) || timeout_value.nil?
|
22
29
|
error_msg = "connect-timeout value must be an Integer, received #{timeout_value}:#{timeout_value.class}"
|
@@ -36,7 +43,7 @@ module Bolt
|
|
36
43
|
yield conn
|
37
44
|
ensure
|
38
45
|
begin
|
39
|
-
conn
|
46
|
+
conn&.disconnect
|
40
47
|
rescue StandardError => ex
|
41
48
|
logger.info("Failed to close connection to #{target.uri} : #{ex.message}")
|
42
49
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bolt/node/errors'
|
2
4
|
require 'bolt/node/output'
|
3
5
|
|
@@ -40,7 +42,8 @@ module Bolt
|
|
40
42
|
password: target.password,
|
41
43
|
retry_limit: 1,
|
42
44
|
transport: transport,
|
43
|
-
ca_trust_path: target.options['cacert']
|
45
|
+
ca_trust_path: target.options['cacert'],
|
46
|
+
no_ssl_peer_verification: !target.options['ssl-verify'] }
|
44
47
|
|
45
48
|
Timeout.timeout(target.options['connect-timeout']) do
|
46
49
|
@connection = ::WinRM::Connection.new(options)
|
@@ -72,6 +75,11 @@ module Bolt
|
|
72
75
|
if target.options['ssl'] && @port == HTTP_PORT
|
73
76
|
theres_your_problem = "\nAre you using SSL to connect to a non-SSL port?"
|
74
77
|
end
|
78
|
+
if target.options['ssl-verify'] && e.message.include?('certificate verify failed')
|
79
|
+
theres_your_problem = "\nIs the remote host using a self-signed SSL"\
|
80
|
+
"certificate? Use --no-ssl-verify to disable "\
|
81
|
+
"remote host SSL verification."
|
82
|
+
end
|
75
83
|
raise Bolt::Node::ConnectError.new(
|
76
84
|
"Failed to connect to #{endpoint}: #{e.message}#{theres_your_problem}",
|
77
85
|
"CONNECT_ERROR"
|
@@ -84,7 +92,7 @@ module Bolt
|
|
84
92
|
end
|
85
93
|
|
86
94
|
def disconnect
|
87
|
-
@session
|
95
|
+
@session&.close
|
88
96
|
@logger.debug { "Closed session" }
|
89
97
|
end
|
90
98
|
|
@@ -377,7 +385,7 @@ PS
|
|
377
385
|
@shell_initialized = true
|
378
386
|
end
|
379
387
|
|
380
|
-
def execute(command
|
388
|
+
def execute(command)
|
381
389
|
result_output = Bolt::Node::Output.new
|
382
390
|
|
383
391
|
@logger.debug { "Executing command: #{command}" }
|
data/lib/bolt/util.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Bolt
|
2
4
|
module Util
|
3
5
|
# CODEREVIEW I hate mixing in random modules
|
@@ -15,17 +17,11 @@ module Bolt
|
|
15
17
|
end
|
16
18
|
|
17
19
|
path = File.expand_path(path)
|
18
|
-
|
19
|
-
# The user controls the configfile so this isn't a problem
|
20
|
-
# rubocop:disable YAMLLoad
|
21
|
-
File.open(path, "r:UTF-8") { |f| YAML.load(f.read) }
|
20
|
+
File.open(path, "r:UTF-8") { |f| YAML.safe_load(f.read) }
|
22
21
|
rescue Errno::ENOENT
|
23
22
|
if path_passed
|
24
23
|
raise Bolt::CLIError, "Could not read #{file_name} file: #{path}"
|
25
24
|
end
|
26
|
-
# In older releases of psych SyntaxError is not a subclass of Exception
|
27
|
-
rescue Psych::SyntaxError
|
28
|
-
raise Bolt::CLIError, "Could not parse #{file_name} file: #{path}"
|
29
25
|
rescue Psych::Exception
|
30
26
|
raise Bolt::CLIError, "Could not parse #{file_name} file: #{path}"
|
31
27
|
rescue IOError, SystemCallError
|
@@ -43,6 +39,12 @@ module Bolt
|
|
43
39
|
hash1.merge(hash2, &recursive_merge)
|
44
40
|
end
|
45
41
|
|
42
|
+
def map_vals(hash)
|
43
|
+
hash.each_with_object({}) do |(k, v), acc|
|
44
|
+
acc[k] = yield(v)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
46
48
|
# Accepts a Data object and returns a copy with all hash keys
|
47
49
|
# modifed by block. use &:to_s to stringify keys or :to_sym to symbolize them
|
48
50
|
def walk_keys(data, &block)
|
data/lib/bolt/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'bolt/puppetdb/config'
|
4
5
|
require 'json'
|
@@ -99,11 +100,11 @@ query results.
|
|
99
100
|
puts result
|
100
101
|
end
|
101
102
|
|
102
|
-
|
103
|
+
0
|
103
104
|
rescue StandardError => e
|
104
105
|
puts "Error: #{e}"
|
105
106
|
puts e.backtrace if @trace
|
106
|
-
|
107
|
+
1
|
107
108
|
end
|
108
109
|
|
109
110
|
def resolve_group(group)
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bolt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.5
|
19
|
+
version: '2.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.5
|
26
|
+
version: '2.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: concurrent-ruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: logging
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.2'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: net-scp
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +86,28 @@ dependencies:
|
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.2
|
89
|
+
version: '0.2'
|
76
90
|
type: :runtime
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.2
|
96
|
+
version: '0.2'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: terminal-table
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.8
|
103
|
+
version: '1.8'
|
90
104
|
type: :runtime
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.8
|
110
|
+
version: '1.8'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: winrm
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,28 +128,14 @@ dependencies:
|
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.1
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 1.1.0
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: logging
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '2.2'
|
131
|
+
version: '1.1'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '1.1'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: CFPropertyList
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,14 +190,14 @@ dependencies:
|
|
190
190
|
requirements:
|
191
191
|
- - "~>"
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version: 0.6
|
193
|
+
version: '0.6'
|
194
194
|
type: :runtime
|
195
195
|
prerelease: false
|
196
196
|
version_requirements: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
198
|
- - "~>"
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version: 0.6
|
200
|
+
version: '0.6'
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: win32-dir
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -255,33 +255,33 @@ dependencies:
|
|
255
255
|
- !ruby/object:Gem::Version
|
256
256
|
version: 0.8.8
|
257
257
|
- !ruby/object:Gem::Dependency
|
258
|
-
name:
|
258
|
+
name: bundler
|
259
259
|
requirement: !ruby/object:Gem::Requirement
|
260
260
|
requirements:
|
261
261
|
- - "~>"
|
262
262
|
- !ruby/object:Gem::Version
|
263
|
-
version: '
|
263
|
+
version: '1.14'
|
264
264
|
type: :development
|
265
265
|
prerelease: false
|
266
266
|
version_requirements: !ruby/object:Gem::Requirement
|
267
267
|
requirements:
|
268
268
|
- - "~>"
|
269
269
|
- !ruby/object:Gem::Version
|
270
|
-
version: '
|
270
|
+
version: '1.14'
|
271
271
|
- !ruby/object:Gem::Dependency
|
272
|
-
name:
|
272
|
+
name: puppetlabs_spec_helper
|
273
273
|
requirement: !ruby/object:Gem::Requirement
|
274
274
|
requirements:
|
275
275
|
- - "~>"
|
276
276
|
- !ruby/object:Gem::Version
|
277
|
-
version: '
|
277
|
+
version: '2.6'
|
278
278
|
type: :development
|
279
279
|
prerelease: false
|
280
280
|
version_requirements: !ruby/object:Gem::Requirement
|
281
281
|
requirements:
|
282
282
|
- - "~>"
|
283
283
|
- !ruby/object:Gem::Version
|
284
|
-
version: '
|
284
|
+
version: '2.6'
|
285
285
|
- !ruby/object:Gem::Dependency
|
286
286
|
name: rake
|
287
287
|
requirement: !ruby/object:Gem::Requirement
|
@@ -322,6 +322,8 @@ files:
|
|
322
322
|
- bolt-modules/boltlib/lib/puppet/datatypes/result.rb
|
323
323
|
- bolt-modules/boltlib/lib/puppet/datatypes/resultset.rb
|
324
324
|
- bolt-modules/boltlib/lib/puppet/datatypes/target.rb
|
325
|
+
- bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
|
326
|
+
- bolt-modules/boltlib/lib/puppet/functions/facts.rb
|
325
327
|
- bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb
|
326
328
|
- bolt-modules/boltlib/lib/puppet/functions/file_upload.rb
|
327
329
|
- bolt-modules/boltlib/lib/puppet/functions/get_targets.rb
|
@@ -1622,7 +1624,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1622
1624
|
requirements:
|
1623
1625
|
- - "~>"
|
1624
1626
|
- !ruby/object:Gem::Version
|
1625
|
-
version: '2.
|
1627
|
+
version: '2.3'
|
1626
1628
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1627
1629
|
requirements:
|
1628
1630
|
- - ">="
|