bolt 2.10.0 → 2.14.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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +1 -1
  3. data/bolt-modules/boltlib/lib/puppet/datatypes/applyresult.rb +2 -0
  4. data/bolt-modules/boltlib/lib/puppet/datatypes/resourceinstance.rb +3 -2
  5. data/bolt-modules/boltlib/lib/puppet/datatypes/result.rb +2 -0
  6. data/bolt-modules/boltlib/lib/puppet/datatypes/resultset.rb +2 -0
  7. data/bolt-modules/boltlib/lib/puppet/datatypes/target.rb +2 -2
  8. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +1 -1
  9. data/bolt-modules/boltlib/lib/puppet/functions/get_resources.rb +1 -1
  10. data/bolt-modules/boltlib/lib/puppet/functions/resource.rb +52 -0
  11. data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +65 -0
  12. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +4 -2
  13. data/bolt-modules/boltlib/lib/puppet/functions/run_task_with.rb +8 -2
  14. data/bolt-modules/boltlib/lib/puppet/functions/set_resources.rb +65 -43
  15. data/lib/bolt/analytics.rb +21 -2
  16. data/lib/bolt/applicator.rb +8 -2
  17. data/lib/bolt/apply_inventory.rb +4 -0
  18. data/lib/bolt/apply_result.rb +1 -1
  19. data/lib/bolt/apply_target.rb +4 -0
  20. data/lib/bolt/bolt_option_parser.rb +5 -4
  21. data/lib/bolt/catalog.rb +81 -68
  22. data/lib/bolt/cli.rb +16 -5
  23. data/lib/bolt/config.rb +62 -29
  24. data/lib/bolt/config/transport/ssh.rb +130 -91
  25. data/lib/bolt/executor.rb +14 -1
  26. data/lib/bolt/inventory/group.rb +1 -1
  27. data/lib/bolt/inventory/inventory.rb +4 -0
  28. data/lib/bolt/inventory/target.rb +4 -0
  29. data/lib/bolt/pal.rb +3 -0
  30. data/lib/bolt/project.rb +55 -11
  31. data/lib/bolt/resource_instance.rb +10 -3
  32. data/lib/bolt/shell/bash.rb +1 -1
  33. data/lib/bolt/shell/powershell/snippets.rb +8 -0
  34. data/lib/bolt/transport/local/connection.rb +2 -1
  35. data/lib/bolt/transport/ssh/connection.rb +39 -0
  36. data/lib/bolt/transport/winrm/connection.rb +4 -0
  37. data/lib/bolt/version.rb +1 -1
  38. data/lib/bolt_spec/bolt_context.rb +1 -1
  39. data/lib/bolt_spec/run.rb +1 -1
  40. metadata +6 -5
@@ -353,9 +353,9 @@ module Bolt
353
353
  # Chunks of this size will be read in one iteration
354
354
  index = 0
355
355
  timeout = 0.1
356
+ result_output = Bolt::Node::Output.new
356
357
 
357
358
  inp, out, err, t = conn.execute(command_str)
358
- result_output = Bolt::Node::Output.new
359
359
  read_streams = { out => String.new,
360
360
  err => String.new }
361
361
  write_stream = in_buffer.empty? ? [] : [inp]
@@ -20,6 +20,14 @@ module Bolt
20
20
  PS
21
21
  end
22
22
 
23
+ def exit_with_code(command)
24
+ <<~PS
25
+ #{command}
26
+ if (-not $? -and ($LASTEXITCODE -eq $null)) { exit 1 }
27
+ exit $LASTEXITCODE
28
+ PS
29
+ end
30
+
23
31
  def make_tmpdir(parent)
24
32
  <<~PS
25
33
  $parent = #{parent}
@@ -50,7 +50,8 @@ module Bolt
50
50
  # If it's already a powershell command then invoke it normally.
51
51
  # Otherwise, wrap it in powershell.exe.
52
52
  unless command.start_with?('powershell.exe')
53
- command = ['powershell.exe', *Bolt::Shell::Powershell::PS_ARGS, '-Command', command]
53
+ cmd = Bolt::Shell::Powershell::Snippets.exit_with_code(command)
54
+ command = ['powershell.exe', *Bolt::Shell::Powershell::PS_ARGS, '-Command', cmd]
54
55
  end
55
56
  end
56
57
 
@@ -78,6 +78,28 @@ module Bolt
78
78
 
79
79
  options[:proxy] = Net::SSH::Proxy::Jump.new(target.options['proxyjump']) if target.options['proxyjump']
80
80
 
81
+ # Override the default supported algorithms for net-ssh. By default, a subset of supported algorithms
82
+ # are enabled in 6.x, while several are deprecated and not enabled by default. The *-algorithms
83
+ # options can be used to specify a list of algorithms to enable in net-ssh. Any algorithms not in the
84
+ # list are disabled, including ones that are normally enabled by default. Support for deprecated
85
+ # algorithms will be removed in 7.x.
86
+ # https://github.com/net-ssh/net-ssh#supported-algorithms
87
+ if target.options['encryption-algorithms']
88
+ options[:encryption] = net_ssh_algorithms(:encryption, target.options['encryption-algorithms'])
89
+ end
90
+
91
+ if target.options['host-key-algorithms']
92
+ options[:host_key] = net_ssh_algorithms(:host_key, target.options['host-key-algorithms'])
93
+ end
94
+
95
+ if target.options['kex-algorithms']
96
+ options[:kex] = net_ssh_algorithms(:kex, target.options['kex-algorithms'])
97
+ end
98
+
99
+ if target.options['mac-algorithms']
100
+ options[:hmac] = net_ssh_algorithms(:hmac, target.options['mac-algorithms'])
101
+ end
102
+
81
103
  # This option was to address discrepency betwen net-ssh host-key-check and ssh(1)
82
104
  # For the net-ssh 5.x series it defaults to true, in 6.x it will default to false, and will be removed in 7.x
83
105
  # https://github.com/net-ssh/net-ssh/pull/663#issuecomment-469979931
@@ -207,6 +229,10 @@ module Bolt
207
229
  err_wr.close
208
230
  end
209
231
  [in_wr, out_rd, err_rd, th]
232
+ rescue Errno::EMFILE => e
233
+ msg = "#{e.message}. This may be resolved by increasing your user limit "\
234
+ "with 'ulimit -n 1024'. See https://puppet.com/docs/bolt/latest/bolt_known_issues.html for details."
235
+ raise Bolt::Error.new(msg, 'bolt/too-many-files')
210
236
  end
211
237
 
212
238
  def copy_file(source, destination)
@@ -242,6 +268,19 @@ module Bolt
242
268
  end
243
269
  end
244
270
 
271
+ # Add all default algorithms if the 'defaults' key is present and filter
272
+ # out any unsupported algorithms.
273
+ def net_ssh_algorithms(type, algorithms)
274
+ if algorithms.include?('defaults')
275
+ defaults = Net::SSH::Transport::Algorithms::DEFAULT_ALGORITHMS[type]
276
+ algorithms += defaults
277
+ end
278
+
279
+ known = Net::SSH::Transport::Algorithms::ALGORITHMS[type]
280
+
281
+ algorithms & known
282
+ end
283
+
245
284
  def shell
246
285
  @shell ||= if target.options['login-shell'] == 'powershell'
247
286
  Bolt::Shell::Powershell.new(target, self)
@@ -120,6 +120,10 @@ module Bolt
120
120
  end
121
121
 
122
122
  [inp, out_rd, err_rd, th]
123
+ rescue Errno::EMFILE => e
124
+ msg = "#{e.message}. This may be resolved by increasing your user limit "\
125
+ "with 'ulimit -n 1024'. See https://puppet.com/docs/bolt/latest/bolt_known_issues.html for details."
126
+ raise Bolt::Error.new(msg, 'bolt/too-many-files')
123
127
  rescue StandardError
124
128
  @logger.debug { "Command aborted" }
125
129
  raise
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bolt
4
- VERSION = '2.10.0'
4
+ VERSION = '2.14.0'
5
5
  end
@@ -138,7 +138,7 @@ module BoltSpec
138
138
  # Override in your tests
139
139
  def config
140
140
  @config ||= begin
141
- conf = Bolt::Config.new(Bolt::Project.new('.'), {})
141
+ conf = Bolt::Config.default
142
142
  conf.modulepath = [modulepath].flatten
143
143
  conf
144
144
  end
@@ -144,7 +144,7 @@ module BoltSpec
144
144
  end
145
145
 
146
146
  def config
147
- @config ||= Bolt::Config.new(Bolt::Project.new(@project_path), @config_data)
147
+ @config ||= Bolt::Config.new(Bolt::Project.create_project(@project_path), @config_data)
148
148
  end
149
149
 
150
150
  def inventory
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.10.0
4
+ version: 2.14.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-05-18 00:00:00.000000000 Z
11
+ date: 2020-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -184,7 +184,7 @@ dependencies:
184
184
  requirements:
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
- version: 6.15.0
187
+ version: 6.16.0
188
188
  - - "<"
189
189
  - !ruby/object:Gem::Version
190
190
  version: '7'
@@ -194,7 +194,7 @@ dependencies:
194
194
  requirements:
195
195
  - - ">="
196
196
  - !ruby/object:Gem::Version
197
- version: 6.15.0
197
+ version: 6.16.0
198
198
  - - "<"
199
199
  - !ruby/object:Gem::Version
200
200
  version: '7'
@@ -407,6 +407,7 @@ files:
407
407
  - bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb
408
408
  - bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
409
409
  - bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
410
+ - bolt-modules/boltlib/lib/puppet/functions/resource.rb
410
411
  - bolt-modules/boltlib/lib/puppet/functions/run_command.rb
411
412
  - bolt-modules/boltlib/lib/puppet/functions/run_plan.rb
412
413
  - bolt-modules/boltlib/lib/puppet/functions/run_script.rb
@@ -588,7 +589,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
588
589
  - !ruby/object:Gem::Version
589
590
  version: '0'
590
591
  requirements: []
591
- rubygems_version: 3.0.6
592
+ rubygems_version: 3.0.8
592
593
  signing_key:
593
594
  specification_version: 4
594
595
  summary: Execute commands remotely over SSH and WinRM