bolt 2.11.0 → 2.15.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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +1 -1
  3. data/bolt-modules/boltlib/lib/puppet/datatypes/resourceinstance.rb +3 -2
  4. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +1 -1
  5. data/bolt-modules/boltlib/lib/puppet/functions/get_resources.rb +1 -1
  6. data/bolt-modules/boltlib/lib/puppet/functions/resource.rb +52 -0
  7. data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +65 -0
  8. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +4 -2
  9. data/bolt-modules/boltlib/lib/puppet/functions/run_task_with.rb +8 -2
  10. data/bolt-modules/boltlib/lib/puppet/functions/set_resources.rb +65 -43
  11. data/bolt-modules/file/lib/puppet/functions/file/exists.rb +1 -1
  12. data/bolt-modules/file/lib/puppet/functions/file/read.rb +1 -1
  13. data/bolt-modules/file/lib/puppet/functions/file/readable.rb +1 -1
  14. data/lib/bolt/analytics.rb +21 -2
  15. data/lib/bolt/applicator.rb +19 -7
  16. data/lib/bolt/apply_inventory.rb +4 -0
  17. data/lib/bolt/apply_target.rb +4 -0
  18. data/lib/bolt/bolt_option_parser.rb +4 -3
  19. data/lib/bolt/catalog.rb +81 -68
  20. data/lib/bolt/cli.rb +16 -5
  21. data/lib/bolt/config.rb +216 -75
  22. data/lib/bolt/config/transport/ssh.rb +130 -91
  23. data/lib/bolt/executor.rb +14 -1
  24. data/lib/bolt/inventory/group.rb +1 -1
  25. data/lib/bolt/inventory/inventory.rb +4 -0
  26. data/lib/bolt/inventory/target.rb +4 -0
  27. data/lib/bolt/outputter.rb +3 -0
  28. data/lib/bolt/outputter/rainbow.rb +80 -0
  29. data/lib/bolt/pal.rb +3 -0
  30. data/lib/bolt/project.rb +48 -11
  31. data/lib/bolt/resource_instance.rb +10 -3
  32. data/lib/bolt/shell/powershell/snippets.rb +8 -0
  33. data/lib/bolt/transport/local/connection.rb +2 -1
  34. data/lib/bolt/transport/ssh/connection.rb +35 -0
  35. data/lib/bolt/version.rb +1 -1
  36. data/lib/bolt_spec/bolt_context.rb +1 -1
  37. data/lib/bolt_spec/run.rb +1 -1
  38. metadata +21 -5
@@ -30,8 +30,7 @@ module Bolt
30
30
  @target = resource_hash['target']
31
31
  @type = resource_hash['type'].to_s.capitalize
32
32
  @title = resource_hash['title']
33
- # get_resources() returns observed state under the 'parameters' key
34
- @state = resource_hash['state'] || resource_hash['parameters'] || {}
33
+ @state = resource_hash['state'] || {}
35
34
  @desired_state = resource_hash['desired_state'] || {}
36
35
  @events = resource_hash['events'] || []
37
36
  end
@@ -84,11 +83,19 @@ module Bolt
84
83
  to_hash.to_json(opts)
85
84
  end
86
85
 
86
+ def self.format_reference(type, title)
87
+ "#{type.capitalize}[#{title}]"
88
+ end
89
+
87
90
  def reference
88
- "#{type}[#{title}]"
91
+ self.class.format_reference(@type, @title)
89
92
  end
90
93
  alias to_s reference
91
94
 
95
+ def [](attribute)
96
+ @state[attribute]
97
+ end
98
+
92
99
  def add_event(event)
93
100
  @events << event
94
101
  end
@@ -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
@@ -246,6 +268,19 @@ module Bolt
246
268
  end
247
269
  end
248
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
+
249
284
  def shell
250
285
  @shell ||= if target.options['login-shell'] == 'powershell'
251
286
  Bolt::Shell::Powershell.new(target, self)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bolt
4
- VERSION = '2.11.0'
4
+ VERSION = '2.15.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.11.0
4
+ version: 2.15.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-27 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -178,13 +178,27 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0.4'
181
+ - !ruby/object:Gem::Dependency
182
+ name: paint
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '2.2'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '2.2'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: puppet
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
199
  - - ">="
186
200
  - !ruby/object:Gem::Version
187
- version: 6.15.0
201
+ version: 6.16.0
188
202
  - - "<"
189
203
  - !ruby/object:Gem::Version
190
204
  version: '7'
@@ -194,7 +208,7 @@ dependencies:
194
208
  requirements:
195
209
  - - ">="
196
210
  - !ruby/object:Gem::Version
197
- version: 6.15.0
211
+ version: 6.16.0
198
212
  - - "<"
199
213
  - !ruby/object:Gem::Version
200
214
  version: '7'
@@ -407,6 +421,7 @@ files:
407
421
  - bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb
408
422
  - bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
409
423
  - bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
424
+ - bolt-modules/boltlib/lib/puppet/functions/resource.rb
410
425
  - bolt-modules/boltlib/lib/puppet/functions/run_command.rb
411
426
  - bolt-modules/boltlib/lib/puppet/functions/run_plan.rb
412
427
  - bolt-modules/boltlib/lib/puppet/functions/run_script.rb
@@ -466,6 +481,7 @@ files:
466
481
  - lib/bolt/outputter/human.rb
467
482
  - lib/bolt/outputter/json.rb
468
483
  - lib/bolt/outputter/logger.rb
484
+ - lib/bolt/outputter/rainbow.rb
469
485
  - lib/bolt/pal.rb
470
486
  - lib/bolt/pal/issues.rb
471
487
  - lib/bolt/pal/logging.rb
@@ -588,7 +604,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
588
604
  - !ruby/object:Gem::Version
589
605
  version: '0'
590
606
  requirements: []
591
- rubygems_version: 3.0.6
607
+ rubygems_version: 3.0.8
592
608
  signing_key:
593
609
  specification_version: 4
594
610
  summary: Execute commands remotely over SSH and WinRM