bolt 0.16.4 → 0.17.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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb +2 -3
  3. data/bolt-modules/boltlib/lib/puppet/functions/file_upload.rb +2 -2
  4. data/bolt-modules/boltlib/lib/puppet/functions/get_targets.rb +2 -3
  5. data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +2 -2
  6. data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +2 -2
  7. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +2 -2
  8. data/bolt-modules/boltlib/lib/puppet/functions/set_var.rb +29 -0
  9. data/bolt-modules/boltlib/lib/puppet/functions/vars.rb +27 -0
  10. data/lib/bolt/cli.rb +220 -184
  11. data/lib/bolt/config.rb +95 -13
  12. data/lib/bolt/executor.rb +12 -5
  13. data/lib/bolt/inventory.rb +48 -11
  14. data/lib/bolt/inventory/group.rb +22 -2
  15. data/lib/bolt/logger.rb +56 -8
  16. data/lib/bolt/outputter/human.rb +18 -1
  17. data/lib/bolt/pal.rb +6 -1
  18. data/lib/bolt/target.rb +1 -1
  19. data/lib/bolt/transport/base.rb +3 -0
  20. data/lib/bolt/transport/local.rb +90 -0
  21. data/lib/bolt/transport/local/shell.rb +29 -0
  22. data/lib/bolt/transport/orch.rb +2 -2
  23. data/lib/bolt/transport/ssh.rb +0 -3
  24. data/lib/bolt/transport/winrm.rb +0 -3
  25. data/lib/bolt/util.rb +31 -4
  26. data/lib/bolt/version.rb +1 -1
  27. data/lib/bolt_ext/puppetdb_inventory.rb +9 -2
  28. data/modules/aggregate/lib/puppet/functions/aggregate/count.rb +19 -0
  29. data/modules/aggregate/lib/puppet/functions/aggregate/nodes.rb +19 -0
  30. data/modules/aggregate/plans/count.pp +35 -0
  31. data/modules/aggregate/plans/nodes.pp +35 -0
  32. data/modules/canary/lib/puppet/functions/canary/merge.rb +11 -0
  33. data/modules/canary/lib/puppet/functions/canary/random_split.rb +20 -0
  34. data/modules/canary/lib/puppet/functions/canary/skip.rb +23 -0
  35. data/modules/canary/plans/init.pp +52 -0
  36. metadata +14 -16
@@ -0,0 +1,35 @@
1
+ plan aggregate::nodes(
2
+ Optional[String[0]] $task = undef,
3
+ Optional[String[0]] $command = undef,
4
+ Optional[String[0]] $script = undef,
5
+ TargetSpec $nodes,
6
+ Hash[String, Data] $params = {}
7
+ ) {
8
+
9
+ # Validation
10
+ $type_count = [$task, $command, $script].reduce(0) |$acc, $v| {
11
+ if ($v) {
12
+ $acc + 1
13
+ } else {
14
+ $acc
15
+ }
16
+ }
17
+
18
+ if ($type_count == 0) {
19
+ fail_plan("Must specify a command, script, or task to run", 'canary/invalid-params')
20
+ }
21
+
22
+ if ($type_count > 1) {
23
+ fail_plan("Must specify only one command, script, or task to run", 'canary/invalid-params')
24
+ }
25
+
26
+ $res = if ($task) {
27
+ run_task($task, $nodes, $params)
28
+ } elsif ($command) {
29
+ run_command($command, $nodes, $params)
30
+ } elsif ($script) {
31
+ run_script($script, $nodes, $params)
32
+ }
33
+
34
+ aggregate::nodes($res)
35
+ }
@@ -0,0 +1,11 @@
1
+ # Merges two ResultSets into a new ResultSet
2
+ Puppet::Functions.create_function(:'canary::merge') do
3
+ dispatch :merge_results do
4
+ param 'ResultSet', :merger
5
+ param 'ResultSet', :mergee
6
+ end
7
+
8
+ def merge_results(merger, mergee)
9
+ Bolt::ResultSet.new(merger.results + mergee.results)
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ # Splits an array into two groups, where the 1st group is a randomly selected
2
+ # sample of the input (of the specified size) and the 2nd group is the remainder.
3
+ #
4
+ # This function takes 2 parameters:
5
+ # * The array to split (Array)
6
+ # * The number of items to sample from the array (Integer)
7
+ #
8
+ # Returns an array of [<sample>, <remainder>].
9
+ Puppet::Functions.create_function(:'canary::random_split') do
10
+ dispatch :rand do
11
+ param 'Array', :arr
12
+ param 'Integer', :size
13
+ end
14
+
15
+ def rand(arr, size)
16
+ canaries = arr.sample(size)
17
+ rest = arr.reject { |r| canaries.include?(r) }
18
+ [canaries, rest]
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ # Returns a ResultSet with canary/skipped-node errors for each Target provided.
2
+ #
3
+ # This function takes a single parameter:
4
+ # * List of nodes (Array[Variant[Target,String]])
5
+ #
6
+ # Returns a ResultSet.
7
+ Puppet::Functions.create_function(:'canary::skip') do
8
+ dispatch :skip_result do
9
+ param 'Array[Variant[Target,String]]', :nodes
10
+ end
11
+
12
+ def skip_result(nodes)
13
+ results = nodes.map do |node|
14
+ node = Bolt::Target.new(node) unless node.is_a? Bolt::Target
15
+ Bolt::Result.new(node, value: { '_error' => {
16
+ 'msg' => "Skipped #{node.name} because of a previous failure",
17
+ 'kind' => 'canary/skipped-node',
18
+ 'details' => {}
19
+ } })
20
+ end
21
+ Bolt::ResultSet.new(results)
22
+ end
23
+ end
@@ -0,0 +1,52 @@
1
+ plan canary(
2
+ Optional[String[0]] $task = undef,
3
+ Optional[String[0]] $command = undef,
4
+ Optional[String[0]] $script = undef,
5
+ TargetSpec $nodes,
6
+ Hash[String, Data] $params = {},
7
+ Integer $canary_size = 1
8
+ ) {
9
+
10
+ # Validation
11
+ $type_count = [$task, $command, $script].reduce(0) |$acc, $v| {
12
+ if ($v) {
13
+ $acc + 1
14
+ } else {
15
+ $acc
16
+ }
17
+ }
18
+
19
+ if ($type_count == 0) {
20
+ fail_plan("Must specify a command, script, or task to run", 'canary/invalid-params')
21
+ }
22
+
23
+ if ($type_count > 1) {
24
+ fail_plan("Must specify only one command, script, or task to run", 'canary/invalid-params')
25
+ }
26
+
27
+ [$canaries, $rest] = canary::random_split(get_targets($nodes), $canary_size)
28
+ $catch_params = $params + { '_catch_errors' => true }
29
+
30
+ if ($task) {
31
+ $canr = run_task($task, $canaries, $catch_params)
32
+ if ($canr.ok) {
33
+ $restr = run_task($task, $rest, $catch_params)
34
+ }
35
+ } elsif ($command) {
36
+ $canr = run_command($command, $canaries, $catch_params)
37
+ if ($canr.ok) {
38
+ $restr = run_command($command, $rest, $catch_params)
39
+ }
40
+ } elsif ($script) {
41
+ $canr = run_script($script, $canaries, $catch_params)
42
+ if ($canr.ok) {
43
+ $restr = run_script($script, $rest, $catch_params)
44
+ }
45
+ }
46
+
47
+ unless ($canr.ok) {
48
+ $restr = canary::skip($rest)
49
+ }
50
+
51
+ canary::merge($canr, $restr)
52
+ }
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: 0.16.4
4
+ version: 0.17.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-02-26 00:00:00.000000000 Z
11
+ date: 2018-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -254,20 +254,6 @@ dependencies:
254
254
  - - '='
255
255
  - !ruby/object:Gem::Version
256
256
  version: 0.8.8
257
- - !ruby/object:Gem::Dependency
258
- name: ffi
259
- requirement: !ruby/object:Gem::Requirement
260
- requirements:
261
- - - "<="
262
- - !ruby/object:Gem::Version
263
- version: 1.9.18
264
- type: :runtime
265
- prerelease: false
266
- version_requirements: !ruby/object:Gem::Requirement
267
- requirements:
268
- - - "<="
269
- - !ruby/object:Gem::Version
270
- version: 1.9.18
271
257
  - !ruby/object:Gem::Dependency
272
258
  name: puppetlabs_spec_helper
273
259
  requirement: !ruby/object:Gem::Requirement
@@ -343,6 +329,8 @@ files:
343
329
  - bolt-modules/boltlib/lib/puppet/functions/run_plan.rb
344
330
  - bolt-modules/boltlib/lib/puppet/functions/run_script.rb
345
331
  - bolt-modules/boltlib/lib/puppet/functions/run_task.rb
332
+ - bolt-modules/boltlib/lib/puppet/functions/set_var.rb
333
+ - bolt-modules/boltlib/lib/puppet/functions/vars.rb
346
334
  - bolt-modules/boltlib/types/targetspec.pp
347
335
  - exe/bolt
348
336
  - exe/bolt-inventory-pdb
@@ -365,6 +353,8 @@ files:
365
353
  - lib/bolt/result_set.rb
366
354
  - lib/bolt/target.rb
367
355
  - lib/bolt/transport/base.rb
356
+ - lib/bolt/transport/local.rb
357
+ - lib/bolt/transport/local/shell.rb
368
358
  - lib/bolt/transport/orch.rb
369
359
  - lib/bolt/transport/ssh.rb
370
360
  - lib/bolt/transport/ssh/connection.rb
@@ -373,6 +363,14 @@ files:
373
363
  - lib/bolt/util.rb
374
364
  - lib/bolt/version.rb
375
365
  - lib/bolt_ext/puppetdb_inventory.rb
366
+ - modules/aggregate/lib/puppet/functions/aggregate/count.rb
367
+ - modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
368
+ - modules/aggregate/plans/count.pp
369
+ - modules/aggregate/plans/nodes.pp
370
+ - modules/canary/lib/puppet/functions/canary/merge.rb
371
+ - modules/canary/lib/puppet/functions/canary/random_split.rb
372
+ - modules/canary/lib/puppet/functions/canary/skip.rb
373
+ - modules/canary/plans/init.pp
376
374
  - vendored/facter/lib/facter.rb
377
375
  - vendored/facter/lib/facter/Cfkey.rb
378
376
  - vendored/facter/lib/facter/application.rb