bolt 2.14.0 → 2.19.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/Puppetfile +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/add_to_group.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +20 -9
- data/bolt-modules/boltlib/lib/puppet/functions/catch_errors.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/facts.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_resources.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_target.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_targets.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/resource.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +3 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +2 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +7 -4
- data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +2 -1
- data/bolt-modules/boltlib/lib/puppet/functions/set_config.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_resources.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_var.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/vars.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/write_file.rb +1 -0
- data/bolt-modules/ctrl/lib/puppet/functions/ctrl/do_until.rb +2 -0
- data/bolt-modules/ctrl/lib/puppet/functions/ctrl/sleep.rb +2 -0
- data/bolt-modules/file/lib/puppet/functions/file/exists.rb +2 -1
- data/bolt-modules/file/lib/puppet/functions/file/join.rb +2 -0
- data/bolt-modules/file/lib/puppet/functions/file/read.rb +3 -1
- data/bolt-modules/file/lib/puppet/functions/file/readable.rb +3 -1
- data/bolt-modules/file/lib/puppet/functions/file/write.rb +2 -0
- data/bolt-modules/out/lib/puppet/functions/out/message.rb +2 -0
- data/bolt-modules/prompt/lib/puppet/functions/prompt.rb +1 -0
- data/bolt-modules/system/lib/puppet/functions/system/env.rb +2 -0
- data/lib/bolt/applicator.rb +34 -20
- data/lib/bolt/apply_result.rb +1 -1
- data/lib/bolt/bolt_option_parser.rb +30 -18
- data/lib/bolt/cli.rb +78 -56
- data/lib/bolt/config.rb +158 -128
- data/lib/bolt/config/options.rb +474 -0
- data/lib/bolt/config/transport/base.rb +16 -16
- data/lib/bolt/config/transport/docker.rb +9 -23
- data/lib/bolt/config/transport/local.rb +6 -44
- data/lib/bolt/config/transport/options.rb +460 -0
- data/lib/bolt/config/transport/orch.rb +9 -18
- data/lib/bolt/config/transport/remote.rb +3 -6
- data/lib/bolt/config/transport/ssh.rb +74 -154
- data/lib/bolt/config/transport/winrm.rb +18 -47
- data/lib/bolt/inventory/group.rb +1 -1
- data/lib/bolt/inventory/inventory.rb +0 -14
- data/lib/bolt/inventory/target.rb +18 -5
- data/lib/bolt/logger.rb +24 -1
- data/lib/bolt/outputter.rb +3 -0
- data/lib/bolt/outputter/rainbow.rb +90 -0
- data/lib/bolt/pal.rb +23 -9
- data/lib/bolt/pal/yaml_plan/evaluator.rb +1 -1
- data/lib/bolt/plugin/module.rb +2 -4
- data/lib/bolt/project.rb +41 -52
- data/lib/bolt/shell/bash.rb +30 -42
- data/lib/bolt/shell/powershell.rb +13 -8
- data/lib/bolt/shell/powershell/snippets.rb +15 -6
- data/lib/bolt/transport/docker.rb +9 -5
- data/lib/bolt/transport/orch.rb +8 -0
- data/lib/bolt/transport/ssh.rb +7 -1
- data/lib/bolt/transport/ssh/exec_connection.rb +1 -1
- data/lib/bolt/version.rb +1 -1
- metadata +18 -15
@@ -71,8 +71,10 @@ module Bolt
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
75
|
-
|
74
|
+
def env_declarations(env_vars)
|
75
|
+
env_vars.map do |var, val|
|
76
|
+
"[Environment]::SetEnvironmentVariable('#{var}', @'\n#{val}\n'@)"
|
77
|
+
end
|
76
78
|
end
|
77
79
|
|
78
80
|
def quote_string(string)
|
@@ -111,7 +113,8 @@ module Bolt
|
|
111
113
|
end
|
112
114
|
|
113
115
|
def mkdirs(dirs)
|
114
|
-
|
116
|
+
paths = dirs.uniq.sort.join('","')
|
117
|
+
mkdir_command = "mkdir -Force -Path (\"#{paths}\")"
|
115
118
|
result = execute(mkdir_command)
|
116
119
|
if result.exit_code != 0
|
117
120
|
message = "Could not create directories: #{result.stderr.string}"
|
@@ -165,7 +168,9 @@ module Bolt
|
|
165
168
|
Bolt::Result.for_upload(target, source, destination)
|
166
169
|
end
|
167
170
|
|
168
|
-
def run_command(command,
|
171
|
+
def run_command(command, options = {})
|
172
|
+
command = [*env_declarations(options[:env_vars]), command].join("\r\n") if options[:env_vars]
|
173
|
+
|
169
174
|
output = execute(command)
|
170
175
|
Bolt::Result.for_command(target,
|
171
176
|
output.stdout.string,
|
@@ -174,7 +179,7 @@ module Bolt
|
|
174
179
|
'command', command)
|
175
180
|
end
|
176
181
|
|
177
|
-
def run_script(script, arguments,
|
182
|
+
def run_script(script, arguments, options = {})
|
178
183
|
# unpack any Sensitive data
|
179
184
|
arguments = unwrap_sensitive_args(arguments)
|
180
185
|
with_tmpdir do |dir|
|
@@ -186,6 +191,8 @@ module Bolt
|
|
186
191
|
args += escape_arguments(arguments)
|
187
192
|
execute_process(path, args)
|
188
193
|
end
|
194
|
+
command = [*env_declarations(options[:env_vars]), command].join("\r\n") if options[:env_vars]
|
195
|
+
|
189
196
|
output = execute(command)
|
190
197
|
Bolt::Result.for_command(target,
|
191
198
|
output.stdout.string,
|
@@ -236,9 +243,7 @@ module Bolt
|
|
236
243
|
end
|
237
244
|
|
238
245
|
env_assignments = if Bolt::Task::ENVIRONMENT_METHODS.include?(input_method)
|
239
|
-
envify_params(arguments)
|
240
|
-
set_env(arg, val)
|
241
|
-
end
|
246
|
+
env_declarations(envify_params(arguments))
|
242
247
|
else
|
243
248
|
[]
|
244
249
|
end
|
@@ -85,12 +85,21 @@ module Bolt
|
|
85
85
|
|
86
86
|
def shell_init
|
87
87
|
<<~PS
|
88
|
-
$
|
89
|
-
|
90
|
-
|
91
|
-
$
|
92
|
-
|
93
|
-
|
88
|
+
$installRegKey = Get-ItemProperty -Path "HKLM:\\Software\\Puppet Labs\\Puppet" -ErrorAction 0
|
89
|
+
if(![string]::IsNullOrEmpty($installRegKey.RememberedInstallDir64)){
|
90
|
+
$boltBaseDir = $installRegKey.RememberedInstallDir64
|
91
|
+
}elseif(![string]::IsNullOrEmpty($installRegKey.RememberedInstallDir)){
|
92
|
+
$boltBaseDir = $installRegKey.RememberedInstallDir
|
93
|
+
}else{
|
94
|
+
$boltBaseDir = "${ENV:ProgramFiles}\\Puppet Labs\\Puppet"
|
95
|
+
}
|
96
|
+
|
97
|
+
$ENV:PATH += ";${boltBaseDir}\\bin\\;" +
|
98
|
+
"${boltBaseDir}\\puppet\\bin;" +
|
99
|
+
"${boltBaseDir}\\sys\\ruby\\bin\\"
|
100
|
+
$ENV:RUBYLIB = "${boltBaseDir}\\puppet\\lib;" +
|
101
|
+
"${boltBaseDir}\\facter\\lib;" +
|
102
|
+
"${boltBaseDir}\\hiera\\lib;" +
|
94
103
|
$ENV:RUBYLIB
|
95
104
|
|
96
105
|
Add-Type -AssemblyName System.ServiceModel.Web, System.Runtime.Serialization
|
@@ -20,7 +20,7 @@ module Bolt
|
|
20
20
|
def upload(target, source, destination, _options = {})
|
21
21
|
with_connection(target) do |conn|
|
22
22
|
conn.with_remote_tmpdir do |dir|
|
23
|
-
basename = File.basename(
|
23
|
+
basename = File.basename(source)
|
24
24
|
tmpfile = "#{dir}/#{basename}"
|
25
25
|
if File.directory?(source)
|
26
26
|
conn.write_remote_directory(source, tmpfile)
|
@@ -39,7 +39,9 @@ module Bolt
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def run_command(target, command, options = {})
|
42
|
-
|
42
|
+
execute_options = {}
|
43
|
+
execute_options[:tty] = target.options['tty']
|
44
|
+
execute_options[:environment] = options[:env_vars]
|
43
45
|
|
44
46
|
if target.options['shell-command'] && !target.options['shell-command'].empty?
|
45
47
|
# escape any double quotes in command
|
@@ -47,19 +49,21 @@ module Bolt
|
|
47
49
|
command = "#{target.options['shell-command']} \" #{command}\""
|
48
50
|
end
|
49
51
|
with_connection(target) do |conn|
|
50
|
-
stdout, stderr, exitcode = conn.execute(*Shellwords.split(command),
|
52
|
+
stdout, stderr, exitcode = conn.execute(*Shellwords.split(command), execute_options)
|
51
53
|
Bolt::Result.for_command(target, stdout, stderr, exitcode, 'command', command)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
|
-
def run_script(target, script, arguments,
|
57
|
+
def run_script(target, script, arguments, options = {})
|
56
58
|
# unpack any Sensitive data
|
57
59
|
arguments = unwrap_sensitive_args(arguments)
|
60
|
+
execute_options = {}
|
61
|
+
execute_options[:environment] = options[:env_vars]
|
58
62
|
|
59
63
|
with_connection(target) do |conn|
|
60
64
|
conn.with_remote_tmpdir do |dir|
|
61
65
|
remote_path = conn.write_remote_executable(dir, script)
|
62
|
-
stdout, stderr, exitcode = conn.execute(remote_path, *arguments,
|
66
|
+
stdout, stderr, exitcode = conn.execute(remote_path, *arguments, execute_options)
|
63
67
|
Bolt::Result.for_command(target, stdout, stderr, exitcode, 'script', script)
|
64
68
|
end
|
65
69
|
end
|
data/lib/bolt/transport/orch.rb
CHANGED
@@ -82,6 +82,10 @@ module Bolt
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def batch_command(targets, command, options = {}, &callback)
|
85
|
+
if options[:env_vars] && !options[:env_vars].empty?
|
86
|
+
raise NotImplementedError, "pcp transport does not support setting environment variables"
|
87
|
+
end
|
88
|
+
|
85
89
|
params = {
|
86
90
|
'command' => command
|
87
91
|
}
|
@@ -98,6 +102,10 @@ module Bolt
|
|
98
102
|
end
|
99
103
|
|
100
104
|
def batch_script(targets, script, arguments, options = {}, &callback)
|
105
|
+
if options[:env_vars] && !options[:env_vars].empty?
|
106
|
+
raise NotImplementedError, "pcp transport does not support setting environment variables"
|
107
|
+
end
|
108
|
+
|
101
109
|
content = File.open(script, &:read)
|
102
110
|
content = Base64.encode64(content)
|
103
111
|
params = {
|
data/lib/bolt/transport/ssh.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'bolt/logger'
|
3
4
|
require 'bolt/node/errors'
|
4
5
|
require 'bolt/transport/simple'
|
5
6
|
|
@@ -21,7 +22,12 @@ module Bolt
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def with_connection(target)
|
24
|
-
|
25
|
+
if target.transport_config['ssh-command'] && !target.transport_config['native-ssh']
|
26
|
+
Bolt::Logger.warn_once("ssh-command and native-ssh conflict",
|
27
|
+
"native-ssh must be true to use ssh-command")
|
28
|
+
end
|
29
|
+
|
30
|
+
conn = if target.transport_config['native-ssh']
|
25
31
|
ExecConnection.new(target)
|
26
32
|
else
|
27
33
|
Connection.new(target, @transport_logger)
|
data/lib/bolt/version.rb
CHANGED
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: 2.
|
4
|
+
version: 2.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -199,47 +199,47 @@ dependencies:
|
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: '7'
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
|
-
name:
|
202
|
+
name: puppetfile-resolver
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
204
204
|
requirements:
|
205
|
-
- - "
|
205
|
+
- - "~>"
|
206
206
|
- !ruby/object:Gem::Version
|
207
|
-
version: 1.
|
207
|
+
version: 0.1.0
|
208
208
|
type: :runtime
|
209
209
|
prerelease: false
|
210
210
|
version_requirements: !ruby/object:Gem::Requirement
|
211
211
|
requirements:
|
212
|
-
- - "
|
212
|
+
- - "~>"
|
213
213
|
- !ruby/object:Gem::Version
|
214
|
-
version: 1.
|
214
|
+
version: 0.1.0
|
215
215
|
- !ruby/object:Gem::Dependency
|
216
|
-
name: puppet-
|
216
|
+
name: puppet-resource_api
|
217
217
|
requirement: !ruby/object:Gem::Requirement
|
218
218
|
requirements:
|
219
|
-
- - "
|
219
|
+
- - ">="
|
220
220
|
- !ruby/object:Gem::Version
|
221
|
-
version:
|
221
|
+
version: 1.8.1
|
222
222
|
type: :runtime
|
223
223
|
prerelease: false
|
224
224
|
version_requirements: !ruby/object:Gem::Requirement
|
225
225
|
requirements:
|
226
|
-
- - "
|
226
|
+
- - ">="
|
227
227
|
- !ruby/object:Gem::Version
|
228
|
-
version:
|
228
|
+
version: 1.8.1
|
229
229
|
- !ruby/object:Gem::Dependency
|
230
|
-
name:
|
230
|
+
name: puppet-strings
|
231
231
|
requirement: !ruby/object:Gem::Requirement
|
232
232
|
requirements:
|
233
233
|
- - "~>"
|
234
234
|
- !ruby/object:Gem::Version
|
235
|
-
version:
|
235
|
+
version: '2.3'
|
236
236
|
type: :runtime
|
237
237
|
prerelease: false
|
238
238
|
version_requirements: !ruby/object:Gem::Requirement
|
239
239
|
requirements:
|
240
240
|
- - "~>"
|
241
241
|
- !ruby/object:Gem::Version
|
242
|
-
version:
|
242
|
+
version: '2.3'
|
243
243
|
- !ruby/object:Gem::Dependency
|
244
244
|
name: r10k
|
245
245
|
requirement: !ruby/object:Gem::Requirement
|
@@ -446,9 +446,11 @@ files:
|
|
446
446
|
- lib/bolt/catalog/logging.rb
|
447
447
|
- lib/bolt/cli.rb
|
448
448
|
- lib/bolt/config.rb
|
449
|
+
- lib/bolt/config/options.rb
|
449
450
|
- lib/bolt/config/transport/base.rb
|
450
451
|
- lib/bolt/config/transport/docker.rb
|
451
452
|
- lib/bolt/config/transport/local.rb
|
453
|
+
- lib/bolt/config/transport/options.rb
|
452
454
|
- lib/bolt/config/transport/orch.rb
|
453
455
|
- lib/bolt/config/transport/remote.rb
|
454
456
|
- lib/bolt/config/transport/ssh.rb
|
@@ -467,6 +469,7 @@ files:
|
|
467
469
|
- lib/bolt/outputter/human.rb
|
468
470
|
- lib/bolt/outputter/json.rb
|
469
471
|
- lib/bolt/outputter/logger.rb
|
472
|
+
- lib/bolt/outputter/rainbow.rb
|
470
473
|
- lib/bolt/pal.rb
|
471
474
|
- lib/bolt/pal/issues.rb
|
472
475
|
- lib/bolt/pal/logging.rb
|