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.

Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +1 -1
  3. data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +1 -0
  4. data/bolt-modules/boltlib/lib/puppet/functions/add_to_group.rb +1 -0
  5. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +20 -9
  6. data/bolt-modules/boltlib/lib/puppet/functions/catch_errors.rb +1 -0
  7. data/bolt-modules/boltlib/lib/puppet/functions/facts.rb +1 -0
  8. data/bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb +1 -0
  9. data/bolt-modules/boltlib/lib/puppet/functions/get_resources.rb +1 -0
  10. data/bolt-modules/boltlib/lib/puppet/functions/get_target.rb +1 -0
  11. data/bolt-modules/boltlib/lib/puppet/functions/get_targets.rb +1 -0
  12. data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb +1 -0
  13. data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb +1 -0
  14. data/bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb +1 -0
  15. data/bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb +1 -0
  16. data/bolt-modules/boltlib/lib/puppet/functions/resource.rb +1 -0
  17. data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +3 -0
  18. data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +2 -1
  19. data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +7 -4
  20. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +2 -1
  21. data/bolt-modules/boltlib/lib/puppet/functions/set_config.rb +1 -0
  22. data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +1 -0
  23. data/bolt-modules/boltlib/lib/puppet/functions/set_resources.rb +1 -0
  24. data/bolt-modules/boltlib/lib/puppet/functions/set_var.rb +1 -0
  25. data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -0
  26. data/bolt-modules/boltlib/lib/puppet/functions/vars.rb +1 -0
  27. data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +1 -0
  28. data/bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb +1 -0
  29. data/bolt-modules/boltlib/lib/puppet/functions/write_file.rb +1 -0
  30. data/bolt-modules/ctrl/lib/puppet/functions/ctrl/do_until.rb +2 -0
  31. data/bolt-modules/ctrl/lib/puppet/functions/ctrl/sleep.rb +2 -0
  32. data/bolt-modules/file/lib/puppet/functions/file/exists.rb +2 -1
  33. data/bolt-modules/file/lib/puppet/functions/file/join.rb +2 -0
  34. data/bolt-modules/file/lib/puppet/functions/file/read.rb +3 -1
  35. data/bolt-modules/file/lib/puppet/functions/file/readable.rb +3 -1
  36. data/bolt-modules/file/lib/puppet/functions/file/write.rb +2 -0
  37. data/bolt-modules/out/lib/puppet/functions/out/message.rb +2 -0
  38. data/bolt-modules/prompt/lib/puppet/functions/prompt.rb +1 -0
  39. data/bolt-modules/system/lib/puppet/functions/system/env.rb +2 -0
  40. data/lib/bolt/applicator.rb +34 -20
  41. data/lib/bolt/apply_result.rb +1 -1
  42. data/lib/bolt/bolt_option_parser.rb +30 -18
  43. data/lib/bolt/cli.rb +78 -56
  44. data/lib/bolt/config.rb +158 -128
  45. data/lib/bolt/config/options.rb +474 -0
  46. data/lib/bolt/config/transport/base.rb +16 -16
  47. data/lib/bolt/config/transport/docker.rb +9 -23
  48. data/lib/bolt/config/transport/local.rb +6 -44
  49. data/lib/bolt/config/transport/options.rb +460 -0
  50. data/lib/bolt/config/transport/orch.rb +9 -18
  51. data/lib/bolt/config/transport/remote.rb +3 -6
  52. data/lib/bolt/config/transport/ssh.rb +74 -154
  53. data/lib/bolt/config/transport/winrm.rb +18 -47
  54. data/lib/bolt/inventory/group.rb +1 -1
  55. data/lib/bolt/inventory/inventory.rb +0 -14
  56. data/lib/bolt/inventory/target.rb +18 -5
  57. data/lib/bolt/logger.rb +24 -1
  58. data/lib/bolt/outputter.rb +3 -0
  59. data/lib/bolt/outputter/rainbow.rb +90 -0
  60. data/lib/bolt/pal.rb +23 -9
  61. data/lib/bolt/pal/yaml_plan/evaluator.rb +1 -1
  62. data/lib/bolt/plugin/module.rb +2 -4
  63. data/lib/bolt/project.rb +41 -52
  64. data/lib/bolt/shell/bash.rb +30 -42
  65. data/lib/bolt/shell/powershell.rb +13 -8
  66. data/lib/bolt/shell/powershell/snippets.rb +15 -6
  67. data/lib/bolt/transport/docker.rb +9 -5
  68. data/lib/bolt/transport/orch.rb +8 -0
  69. data/lib/bolt/transport/ssh.rb +7 -1
  70. data/lib/bolt/transport/ssh/exec_connection.rb +1 -1
  71. data/lib/bolt/version.rb +1 -1
  72. metadata +18 -15
@@ -71,8 +71,10 @@ module Bolt
71
71
  end
72
72
  end
73
73
 
74
- def set_env(arg, val)
75
- "[Environment]::SetEnvironmentVariable('#{arg}', @'\n#{val}\n'@)"
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
- mkdir_command = "mkdir -Force #{dirs.uniq.sort.join(',')}"
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, _options = {})
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, _options = {})
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).map do |(arg, val)|
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
- $ENV:PATH += ";${ENV:ProgramFiles}\\Puppet Labs\\Puppet\\bin\\;" +
89
- "${ENV:ProgramFiles}\\Puppet Labs\\Puppet\\puppet\\bin;" +
90
- "${ENV:ProgramFiles}\\Puppet Labs\\Puppet\\sys\\ruby\\bin\\"
91
- $ENV:RUBYLIB = "${ENV:ProgramFiles}\\Puppet Labs\\Puppet\\puppet\\lib;" +
92
- "${ENV:ProgramFiles}\\Puppet Labs\\Puppet\\facter\\lib;" +
93
- "${ENV:ProgramFiles}\\Puppet Labs\\Puppet\\hiera\\lib;" +
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(destination)
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
- options[:tty] = target.options['tty']
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), options)
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, _options = {})
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
@@ -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 = {
@@ -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
- conn = if target.transport_config['ssh-command']
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)
@@ -58,7 +58,7 @@ module Bolt
58
58
  end
59
59
 
60
60
  def build_ssh_command(command)
61
- ssh_conf = @target.transport_config['ssh-command']
61
+ ssh_conf = @target.transport_config['ssh-command'] || 'ssh'
62
62
  ssh_cmd = Array(ssh_conf)
63
63
  ssh_cmd += ssh_opts
64
64
  ssh_cmd << userhost
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bolt
4
- VERSION = '2.14.0'
4
+ VERSION = '2.19.0'
5
5
  end
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.14.0
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-06-15 00:00:00.000000000 Z
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: puppet-resource_api
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.8.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.8.1
214
+ version: 0.1.0
215
215
  - !ruby/object:Gem::Dependency
216
- name: puppet-strings
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: '2.3'
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: '2.3'
228
+ version: 1.8.1
229
229
  - !ruby/object:Gem::Dependency
230
- name: puppetfile-resolver
230
+ name: puppet-strings
231
231
  requirement: !ruby/object:Gem::Requirement
232
232
  requirements:
233
233
  - - "~>"
234
234
  - !ruby/object:Gem::Version
235
- version: 0.1.0
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: 0.1.0
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