bolt 1.49.0 → 2.0.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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +6 -6
  3. data/bolt-modules/boltlib/lib/puppet/datatypes/target.rb +24 -45
  4. data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +3 -3
  5. data/bolt-modules/boltlib/lib/puppet/functions/add_to_group.rb +1 -1
  6. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +10 -12
  7. data/bolt-modules/boltlib/lib/puppet/functions/catch_errors.rb +1 -1
  8. data/bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb +3 -3
  9. data/bolt-modules/boltlib/lib/puppet/functions/get_resources.rb +5 -4
  10. data/bolt-modules/boltlib/lib/puppet/functions/get_target.rb +1 -3
  11. data/bolt-modules/boltlib/lib/puppet/functions/get_targets.rb +1 -2
  12. data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb +2 -2
  13. data/bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb +2 -2
  14. data/bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb +1 -1
  15. data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +7 -3
  16. data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +15 -31
  17. data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +9 -5
  18. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +9 -3
  19. data/bolt-modules/boltlib/lib/puppet/functions/set_config.rb +4 -3
  20. data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +6 -6
  21. data/bolt-modules/boltlib/lib/puppet/functions/set_var.rb +2 -2
  22. data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +7 -3
  23. data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +6 -2
  24. data/bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb +2 -2
  25. data/bolt-modules/ctrl/lib/puppet/functions/ctrl/do_until.rb +2 -1
  26. data/bolt-modules/file/lib/puppet/functions/file/exists.rb +2 -1
  27. data/bolt-modules/file/lib/puppet/functions/file/join.rb +1 -0
  28. data/bolt-modules/file/lib/puppet/functions/file/read.rb +1 -0
  29. data/bolt-modules/file/lib/puppet/functions/file/readable.rb +2 -1
  30. data/bolt-modules/out/lib/puppet/functions/out/message.rb +1 -1
  31. data/bolt-modules/system/lib/puppet/functions/system/env.rb +1 -0
  32. data/lib/bolt/applicator.rb +70 -118
  33. data/lib/bolt/apply_target.rb +1 -1
  34. data/lib/bolt/bolt_option_parser.rb +21 -37
  35. data/lib/bolt/catalog.rb +5 -22
  36. data/lib/bolt/catalog/logging.rb +1 -1
  37. data/lib/bolt/cli.rb +33 -44
  38. data/lib/bolt/config.rb +15 -18
  39. data/lib/bolt/error.rb +2 -2
  40. data/lib/bolt/executor.rb +32 -40
  41. data/lib/bolt/inventory.rb +9 -367
  42. data/lib/bolt/inventory/group.rb +293 -182
  43. data/lib/bolt/inventory/{inventory2.rb → inventory.rb} +25 -14
  44. data/lib/bolt/inventory/target.rb +1 -1
  45. data/lib/bolt/module.rb +4 -4
  46. data/lib/bolt/outputter/human.rb +11 -6
  47. data/lib/bolt/outputter/json.rb +3 -11
  48. data/lib/bolt/pal.rb +1 -2
  49. data/lib/bolt/pal/yaml_plan/step/resources.rb +1 -1
  50. data/lib/bolt/plugin.rb +1 -1
  51. data/lib/bolt/plugin/module.rb +19 -36
  52. data/lib/bolt/plugin/prompt.rb +2 -4
  53. data/lib/bolt/puppetdb/config.rb +1 -3
  54. data/lib/bolt/result.rb +3 -6
  55. data/lib/bolt/secret/base.rb +0 -6
  56. data/lib/bolt/target.rb +8 -219
  57. data/lib/bolt/transport/local/shell.rb +9 -13
  58. data/lib/bolt/transport/orch.rb +3 -5
  59. data/lib/bolt/transport/ssh.rb +1 -0
  60. data/lib/bolt/transport/ssh/connection.rb +1 -4
  61. data/lib/bolt/transport/winrm/connection.rb +1 -1
  62. data/lib/bolt/util.rb +2 -8
  63. data/lib/bolt/version.rb +1 -1
  64. data/lib/bolt_server/transport_app.rb +35 -17
  65. data/lib/bolt_spec/plans.rb +8 -2
  66. data/libexec/bolt_catalog +19 -5
  67. metadata +4 -8
  68. data/exe/bolt-inventory-pdb +0 -13
  69. data/lib/bolt/inventory/group2.rb +0 -403
  70. data/lib/bolt_ext/puppetdb_inventory.rb +0 -129
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf6891d9f3f208d516d962db7af3e26df0b8de95312c465f3cc8add22948730a
4
- data.tar.gz: d58605a7bff94d170ab8c95f3b9a024eb60173f60d5bda83cd29c5084baa7450
3
+ metadata.gz: 741454338908333d9dfe5a093cd7bc441f5ba64968ca8b24f44c221b6cdd3b18
4
+ data.tar.gz: 5143668d78e8c4067868cbb2f4c0fc6b9f118472b658b9720325679a70b744e7
5
5
  SHA512:
6
- metadata.gz: 742d7bd9cf8f7943412e8fbcb363541b787cccfb019e52c913690a00cfe567787fbe16aa20fd5c4a7b0095724f5b5a124c5d4026879c7b3e0f58d342c5c24124
7
- data.tar.gz: 436bb36efdefc26efc08de99769af0d9912c1a34caaf0e9255950e4738a92b65ebcf05df20a4add6b47a54add18c1757d11643fb426c214ce840d83dbd80fd86
6
+ metadata.gz: d2a1789c74010115a7f05ae78bb4a638f1efe9f36ffa5fb7ae13faf4a293bacd51cb00fbde3b42a9356039e0fb5112990fb82883ecae917ef51d36c098b9c1a9
7
+ data.tar.gz: 07513d68070432a1c48141dfd9f40936d6735edf91d5ebfb954083e459d7a7ba7e2e9a906a338f2452732817893c9cb5ccaac691961810f557055ebabecb2cce
data/Puppetfile CHANGED
@@ -6,7 +6,7 @@ moduledir File.join(File.dirname(__FILE__), 'modules')
6
6
 
7
7
  # Core modules used by 'apply'
8
8
  mod 'puppetlabs-service', '1.1.0'
9
- mod 'puppetlabs-puppet_agent', '3.0.1'
9
+ mod 'puppetlabs-puppet_agent', '3.0.2'
10
10
  mod 'puppetlabs-facts', '1.0.0'
11
11
 
12
12
  # Core types and providers for Puppet 6
@@ -30,11 +30,11 @@ mod 'puppetlabs-ruby_task_helper', '0.4.0'
30
30
  mod 'puppetlabs-ruby_plugin_helper', '0.1.0'
31
31
 
32
32
  # Plugin modules
33
- mod 'puppetlabs-azure_inventory', '0.2.0'
34
- mod 'puppetlabs-terraform', '0.3.0'
35
- mod 'puppetlabs-vault', '0.2.2'
36
- mod 'puppetlabs-aws_inventory', '0.3.0'
37
- mod 'puppetlabs-yaml', '0.1.0'
33
+ mod 'puppetlabs-azure_inventory', '0.3.0'
34
+ mod 'puppetlabs-terraform', '0.4.0'
35
+ mod 'puppetlabs-vault', '0.3.0'
36
+ mod 'puppetlabs-aws_inventory', '0.4.0'
37
+ mod 'puppetlabs-yaml', '0.2.0'
38
38
 
39
39
  # If we don't list these modules explicitly, r10k will purge them
40
40
  mod 'canary', local: true
@@ -3,54 +3,33 @@
3
3
  Puppet::DataTypes.create_type('Target') do
4
4
  begin
5
5
  inventory = Puppet.lookup(:bolt_inventory)
6
-
7
- inventory_version = inventory.version
8
- if inventory_version != 1
9
- target_implementation_class = inventory.target_implementation_class
10
- end
6
+ target_implementation_class = inventory.target_implementation_class
11
7
  rescue Puppet::Context::UndefinedBindingError
12
- inventory_version = 1
8
+ target_implementation_class = Bolt::Target
13
9
  end
10
+
14
11
  require 'bolt/target'
15
12
 
16
- if inventory_version == 1
17
- interface <<-PUPPET
18
- attributes => {
19
- uri => String[1],
20
- options => { type => Hash[String[1], Data], value => {} }
21
- },
22
- functions => {
23
- name => Callable[[], String[1]],
24
- host => Callable[[], Optional[String]],
25
- password => Callable[[], Optional[String[1]]],
26
- port => Callable[[], Optional[Integer]],
27
- protocol => Callable[[], Optional[String[1]]],
28
- user => Callable[[], Optional[String[1]]],
29
- }
30
- PUPPET
31
- implementation_class Bolt::Target
32
- else
33
- interface <<-PUPPET
34
- attributes => {
35
- uri => { type => Optional[String[1]], kind => given_or_derived },
36
- name => { type => Optional[String[1]] , kind => given_or_derived },
37
- safe_name => { type => Optional[String[1]], kind => given_or_derived },
38
- target_alias => { type => Optional[Variant[String[1], Array[String[1]]]], kind => given_or_derived },
39
- config => { type => Optional[Hash[String[1], Data]], kind => given_or_derived },
40
- vars => { type => Optional[Hash[String[1], Data]], kind => given_or_derived },
41
- facts => { type => Optional[Hash[String[1], Data]], kind => given_or_derived },
42
- features => { type => Optional[Array[String[1]]], kind => given_or_derived },
43
- plugin_hooks => { type => Optional[Hash[String[1], Data]], kind => given_or_derived }
44
- },
45
- functions => {
46
- host => Callable[[], Optional[String]],
47
- password => Callable[[], Optional[String[1]]],
48
- port => Callable[[], Optional[Integer]],
49
- protocol => Callable[[], Optional[String[1]]],
50
- user => Callable[[], Optional[String[1]]],
51
- }
52
- PUPPET
13
+ interface <<-PUPPET
14
+ attributes => {
15
+ uri => { type => Optional[String[1]], kind => given_or_derived },
16
+ name => { type => Optional[String[1]] , kind => given_or_derived },
17
+ safe_name => { type => Optional[String[1]], kind => given_or_derived },
18
+ target_alias => { type => Optional[Variant[String[1], Array[String[1]]]], kind => given_or_derived },
19
+ config => { type => Optional[Hash[String[1], Data]], kind => given_or_derived },
20
+ vars => { type => Optional[Hash[String[1], Data]], kind => given_or_derived },
21
+ facts => { type => Optional[Hash[String[1], Data]], kind => given_or_derived },
22
+ features => { type => Optional[Array[String[1]]], kind => given_or_derived },
23
+ plugin_hooks => { type => Optional[Hash[String[1], Data]], kind => given_or_derived }
24
+ },
25
+ functions => {
26
+ host => Callable[[], Optional[String]],
27
+ password => Callable[[], Optional[String[1]]],
28
+ port => Callable[[], Optional[Integer]],
29
+ protocol => Callable[[], Optional[String[1]]],
30
+ user => Callable[[], Optional[String[1]]],
31
+ }
32
+ PUPPET
53
33
 
54
- implementation_class target_implementation_class
55
- end
34
+ implementation_class target_implementation_class
56
35
  end
@@ -4,17 +4,17 @@ require 'bolt/error'
4
4
 
5
5
  # Deep merges a hash of facts with the existing facts on a target.
6
6
  #
7
- # **NOTE:** Not available in apply block
7
+ # > **Note:** Not available in apply block
8
8
  Puppet::Functions.create_function(:add_facts) do
9
9
  # @param target A target.
10
10
  # @param facts A hash of fact names to values that may include structured facts.
11
- # @return The target's new facts or a `Target` object if the `future` flag is set to true
11
+ # @return A `Target` object.
12
12
  # @example Adding facts to a target
13
13
  # add_facts($target, { 'os' => { 'family' => 'windows', 'name' => 'windows' } })
14
14
  dispatch :add_facts do
15
15
  param 'Target', :target
16
16
  param 'Hash', :facts
17
- return_type 'Variant[Target, Hash[String, Data]]'
17
+ return_type 'Target'
18
18
  end
19
19
 
20
20
  def add_facts(target, facts)
@@ -4,7 +4,7 @@ require 'bolt/error'
4
4
 
5
5
  # Adds a target to specified inventory group.
6
6
  #
7
- # **NOTE:** Not available in apply block
7
+ # > **Note:** Not available in apply block
8
8
  Puppet::Functions.create_function(:add_to_group) do
9
9
  # @param targets A pattern or array of patterns identifying a set of targets.
10
10
  # @param group The name of the group to add targets to.
@@ -2,15 +2,15 @@
2
2
 
3
3
  require 'bolt/task'
4
4
 
5
- # Installs the puppet-agent package on targets if needed, then collects facts,
5
+ # Installs the `puppet-agent` package on targets if needed, then collects facts,
6
6
  # including any custom facts found in Bolt's modulepath. The package is
7
7
  # installed using either the configured plugin or the `task` plugin with the
8
8
  # `puppet_agent::install` task.
9
9
  #
10
- # Agent installation will be skipped if the target includes the 'puppet-agent' feature, either as a
10
+ # Agent installation will be skipped if the target includes the `puppet-agent` feature, either as a
11
11
  # property of its transport (PCP) or by explicitly setting it as a feature in Bolt's inventory.
12
12
  #
13
- # **NOTE:** Not available in apply block
13
+ # > **Note:** Not available in apply block
14
14
  Puppet::Functions.create_function(:apply_prep) do
15
15
  # @param targets A pattern or array of patterns identifying a set of targets.
16
16
  # @example Prepare targets by name.
@@ -83,15 +83,13 @@ Puppet::Functions.create_function(:apply_prep) do
83
83
  pool = Concurrent::ThreadPoolExecutor.new
84
84
 
85
85
  hooks = need_install_targets.map do |t|
86
- begin
87
- opts = t.plugin_hooks&.fetch('puppet_library').dup
88
- plugin_name = opts.delete('plugin')
89
- hook = inventory.plugins.get_hook(plugin_name, :puppet_library)
90
- { 'target' => t,
91
- 'hook_proc' => hook.call(opts, t, self) }
92
- rescue StandardError => e
93
- Bolt::Result.from_exception(t, e)
94
- end
86
+ opts = t.plugin_hooks&.fetch('puppet_library').dup
87
+ plugin_name = opts.delete('plugin')
88
+ hook = inventory.plugins.get_hook(plugin_name, :puppet_library)
89
+ { 'target' => t,
90
+ 'hook_proc' => hook.call(opts, t, self) }
91
+ rescue StandardError => e
92
+ Bolt::Result.from_exception(t, e)
95
93
  end
96
94
 
97
95
  hook_errors, ok_hooks = hooks.partition { |h| h.is_a?(Bolt::Result) }
@@ -4,7 +4,7 @@
4
4
  # output of the block if no errors are raised. Accepts an optional list of
5
5
  # error kinds to catch.
6
6
  #
7
- # **NOTE:** Not available in apply block
7
+ # > **Note:** Not available in apply block
8
8
  Puppet::Functions.create_function(:catch_errors) do
9
9
  # @param error_types An array of error types to catch
10
10
  # @param block The block of steps to catch errors on
@@ -2,12 +2,12 @@
2
2
 
3
3
  require 'bolt/error'
4
4
 
5
- # Raises a Bolt::PlanFailure exception to signal to callers that the plan failed.
5
+ # Raises a `Bolt::PlanFailure` exception to signal to callers that the plan failed.
6
6
  #
7
7
  # Plan authors should call this function when their plan is not successful. The
8
- # error may then be caught by another plans run_plan function or in bolt itself
8
+ # error may then be caught by another plans `run_plan` function or in Bolt itself
9
9
  #
10
- # **NOTE:** Not available in apply block
10
+ # > **Note:** Not available in apply block
11
11
  Puppet::Functions.create_function(:fail_plan) do
12
12
  # Fail a plan, generating an exception from the parameters.
13
13
  # @param msg An error message.
@@ -6,20 +6,21 @@ require 'bolt/task'
6
6
  # The results are returned as a list of hashes representing each resource.
7
7
  #
8
8
  # Requires the Puppet Agent be installed on the target, which can be accomplished with apply_prep
9
- # or by directly running the puppet_agent::install task. In order to be able to reference types without
10
- # string quoting (for example `get_resources($target, Package)` instead of `get_resources($target, 'Package')`)
9
+ # or by directly running the `puppet_agent::install` task. In order to be able to reference types without
10
+ # string quoting (for example `get_resources($target, Package)` instead of `get_resources($target, 'Package')`),
11
11
  # run the command `bolt puppetfile generate-types` to generate type references in `$Boldir/.resource_types`.
12
12
  #
13
- #
14
- # **NOTE:** Not available in apply block
13
+ # > **Note:** Not available in apply block
15
14
  Puppet::Functions.create_function(:get_resources) do
16
15
  # @param targets A pattern or array of patterns identifying a set of targets.
17
16
  # @param resources A resource type or instance, or an array of such.
17
+ # @return A result set with a list of hashes representing each resource.
18
18
  # @example Collect resource states for packages and a file
19
19
  # get_resources('target1,target2', [Package, File[/etc/puppetlabs]])
20
20
  dispatch :get_resources do
21
21
  param 'Boltlib::TargetSpec', :targets
22
22
  param 'Variant[String, Type[Resource], Array[Variant[String, Type[Resource]]]]', :resources
23
+ return_type 'ResultSet'
23
24
  end
24
25
 
25
26
  def script_compiler
@@ -4,9 +4,7 @@ require 'bolt/error'
4
4
 
5
5
  # Get a single target from inventory if it exists, otherwise create a new Target.
6
6
  #
7
- # **NOTE:** Calling `get_target('all')` returns an empty array.
8
- # **NOTE:** Only compatible with inventory v2
9
- # **NOTE:** Not available in apply block when `future` is true
7
+ # > **Note:** Calling `get_target('all')` returns an empty array.
10
8
  Puppet::Functions.create_function(:get_target) do
11
9
  # @param name A Target name.
12
10
  # @return A single target, either new or from inventory.
@@ -3,9 +3,8 @@
3
3
  require 'bolt/error'
4
4
 
5
5
  # Parses common ways of referring to targets and returns an array of Targets.
6
- # `get_targets('all')` returns an empty array.
7
6
  #
8
- # **NOTE:** Not available in apply block when `future` is true
7
+ # > **Note:** Not available in apply block
9
8
  Puppet::Functions.create_function(:get_targets) do
10
9
  # @param names A pattern or array of patterns identifying a set of targets.
11
10
  # @return A list of unique Targets resolved from any target URIs and groups.
@@ -4,8 +4,8 @@ require 'bolt/error'
4
4
 
5
5
  # Collects facts based on a list of certnames.
6
6
  #
7
- # * If a node is not found in PuppetDB, it's included in the returned hash with empty facts hash.
8
- # * Otherwise the node is included in the hash with a value that is a hash of it's facts.
7
+ # If a node is not found in PuppetDB, it's included in the returned hash with an empty facts hash.
8
+ # Otherwise, the node is included in the hash with a value that is a hash of its facts.
9
9
  Puppet::Functions.create_function(:puppetdb_fact) do
10
10
  # @param certnames Array of certnames.
11
11
  # @return A hash of certname to facts hash for each matched Target.
@@ -5,9 +5,9 @@ require 'bolt/error'
5
5
  # Removes a target from the specified inventory group.
6
6
  #
7
7
  # The target is removed from all child groups and all parent groups where the target has
8
- # not been explicitly defined. A target cannot be removed from the 'all' group.
8
+ # not been explicitly defined. A target cannot be removed from the `all` group.
9
9
  #
10
- # **NOTE:** Not available in apply block
10
+ # > **Note:** Not available in apply block
11
11
  Puppet::Functions.create_function(:remove_from_group) do
12
12
  # @param target A pattern identifying a single target.
13
13
  # @param group The name of the group to remove the target from.
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'bolt/error'
4
4
 
5
- # Evaulates all _plugin references in a hash and returns the resolved reference data.
5
+ # Evaluates all `_plugin` references in a hash and returns the resolved reference data.
6
6
  Puppet::Functions.create_function(:resolve_references) do
7
7
  # Resolve references.
8
8
  # @param references A hash of reference data to resolve.
@@ -5,12 +5,14 @@ require 'bolt/error'
5
5
  # Runs a command on the given set of targets and returns the result from each command execution.
6
6
  # This function does nothing if the list of targets is empty.
7
7
  #
8
- # **NOTE:** Not available in apply block
8
+ # > **Note:** Not available in apply block
9
9
  Puppet::Functions.create_function(:run_command) do
10
10
  # Run a command.
11
11
  # @param command A command to run on target.
12
12
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
13
- # @param options Additional options: '_catch_errors', '_run_as'.
13
+ # @param options A hash of additional options.
14
+ # @option options [Boolean] _catch_errors Whether to catch raised errors.
15
+ # @option options [String] _run_as User to run as using privilege escalation.
14
16
  # @return A list of results, one entry per target.
15
17
  # @example Run a command on targets
16
18
  # run_command('hostname', $targets, '_catch_errors' => true)
@@ -25,7 +27,9 @@ Puppet::Functions.create_function(:run_command) do
25
27
  # @param command A command to run on target.
26
28
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
27
29
  # @param description A description to be output when calling this function.
28
- # @param options Additional options: '_catch_errors', '_run_as'.
30
+ # @param options A hash of additional options.
31
+ # @option options [Boolean] _catch_errors Whether to catch raised errors.
32
+ # @option options [String] _run_as User to run as using privilege escalation.
29
33
  # @return A list of results, one entry per target.
30
34
  # @example Run a command on targets
31
35
  # run_command('hostname', $targets, 'Get hostname')
@@ -4,11 +4,13 @@ require 'bolt/error'
4
4
 
5
5
  # Runs the `plan` referenced by its name. A plan is autoloaded from `$MODULEROOT/plans`.
6
6
  #
7
- # **NOTE:** Not available in apply block
7
+ # > **Note:** Not available in apply block
8
8
  Puppet::Functions.create_function(:run_plan, Puppet::Functions::InternalFunction) do
9
9
  # Run a plan
10
10
  # @param plan_name The plan to run.
11
- # @param args Arguments to the plan. Can also include additional options: '_catch_errors', '_run_as'.
11
+ # @param args A hash of arguments to the plan. Can also include additional options.
12
+ # @option args [Boolean] _catch_errors Whether to catch raised errors.
13
+ # @option args [String] _run_as User to run as using privilege escalation.
12
14
  # @return [PlanResult] The result of running the plan. Undef if plan does not explicitly return results.
13
15
  # @example Run a plan
14
16
  # run_plan('canary', 'command' => 'false', 'targets' => $targets, '_catch_errors' => true)
@@ -19,19 +21,16 @@ Puppet::Functions.create_function(:run_plan, Puppet::Functions::InternalFunction
19
21
  return_type 'Boltlib::PlanResult'
20
22
  end
21
23
 
22
- # Run a plan, specifying $nodes or $targets as a positional argument.
24
+ # Run a plan, specifying `$nodes` or `$targets` as a positional argument.
23
25
  #
24
- # When running a plan with a $nodes parameter, the second positional argument will always specify
25
- # the $nodes parameter. When running a plan with a $targets parameter and no $nodes parameter, the
26
- # second positional argument specifies the $targets parameter.
27
- #
28
- # Deprecation Warning: Starting with Bolt 2.0, a plan with both a $nodes and $targets parameter
29
- # cannot specify either parameter using the second positional argument and will result in the plan
30
- # failing to run.
26
+ # > **Note:** When running a plan with both a `$nodes` and `$targets` parameter, and using the second
27
+ # positional argument, the plan will fail.
31
28
  #
32
29
  # @param plan_name The plan to run.
33
- # @param args Arguments to the plan. Can also include additional options: '_catch_errors', '_run_as'.
34
30
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
31
+ # @param args A hash of arguments to the plan. Can also include additional options.
32
+ # @option args [Boolean] _catch_errors Whether to catch raised errors.
33
+ # @option args [String] _run_as User to run as using privilege escalation.
35
34
  # @return [PlanResult] The result of running the plan. Undef if plan does not explicitly return results.
36
35
  # @example Run a plan
37
36
  # run_plan('canary', $targets, 'command' => 'false')
@@ -98,7 +97,7 @@ Puppet::Functions.create_function(:run_plan, Puppet::Functions::InternalFunction
98
97
  param_acc[param.name] = extract_parameter_types(param.type_expr)&.flatten
99
98
  end
100
99
 
101
- targets_to_param(targets, params, param_types, executor) if targets
100
+ targets_to_param(targets, params, param_types) if targets
102
101
 
103
102
  if inventory.version > 1
104
103
  params.each do |param, value|
@@ -170,30 +169,15 @@ Puppet::Functions.create_function(:run_plan, Puppet::Functions::InternalFunction
170
169
  end
171
170
  end
172
171
 
173
- def targets_to_param(targets, params, param_types, executor)
172
+ def targets_to_param(targets, params, param_types)
174
173
  nodes_param = param_types.include?('nodes')
175
174
  targets_param = param_types['targets']&.any? { |p| p.match?(/TargetSpec/) }
176
175
 
177
176
  # Both a 'TargetSpec $nodes' and 'TargetSpec $targets' parameter are present in the plan
178
- # 1.x behavior: Populate $nodes and warn user that this will error in 2.x
179
- # 2.x behavior: Error
180
177
  if nodes_param && targets_param
181
- # rubocop:disable Style/GlobalVars
182
- if $future
183
- raise ArgumentError,
184
- "A plan with both a $nodes and $targets parameter cannot have either parameter specified " \
185
- "as the second positional argument to run_plan()."
186
- else
187
- msg = <<~WARNING
188
- Deprecation Warning: A plan with both a $nodes and $targets parameter can only specify
189
- the $nodes parameter as the second positional argument to run_plan(). Starting in
190
- Bolt 2.0, a plan with both a $nodes and $targets parameter will not be able to specify
191
- either parameter as the second positional argument to run_plan() and will result in the
192
- plan failing.
193
- WARNING
194
- executor.deprecation(msg)
195
- end
196
- # rubocop:enable Style/GlobalVars
178
+ raise ArgumentError,
179
+ "A plan with both a $nodes and $targets parameter cannot have either parameter specified " \
180
+ "as the second positional argument to run_plan()."
197
181
  end
198
182
 
199
183
  # Always populate a $nodes parameter over $targets
@@ -3,14 +3,16 @@
3
3
  # Uploads the given script to the given set of targets and returns the result of having each target execute the script.
4
4
  # This function does nothing if the list of targets is empty.
5
5
  #
6
- # **NOTE:** Not available in apply block
6
+ # > **Note:** Not available in apply block
7
7
  Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFunction) do
8
8
  # Run a script.
9
9
  # @param script Path to a script to run on target. May be an absolute path or a modulename/filename selector for a
10
10
  # file in $MODULEROOT/files.
11
11
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
12
- # @param options Specify an array of arguments to the 'arguments' key to be passed to the script.
13
- # Additional options: '_catch_errors', '_run_as'.
12
+ # @param options A hash of additional options.
13
+ # @option options [Array[String]] arguments An array of arguments to be passed to the script.
14
+ # @option args [Boolean] _catch_errors Whether to catch raised errors.
15
+ # @option args [String] _run_as User to run as using privilege escalation.
14
16
  # @return A list of results, one entry per target.
15
17
  # @example Run a local script on Linux targets as 'root'
16
18
  # run_script('/var/tmp/myscript', $targets, '_run_as' => 'root')
@@ -29,8 +31,10 @@ Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFuncti
29
31
  # file in $MODULEROOT/files.
30
32
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
31
33
  # @param description A description to be output when calling this function.
32
- # @param options Specify an array of arguments to the 'arguments' key to be passed to the script.
33
- # Additional options: '_catch_errors', '_run_as'.
34
+ # @param options A hash of additional options.
35
+ # @option options [Array[String]] arguments An array of arguments to be passed to the script.
36
+ # @option args [Boolean] _catch_errors Whether to catch raised errors.
37
+ # @option args [String] _run_as User to run as using privilege escalation.
34
38
  # @return A list of results, one entry per target.
35
39
  # @example Run a script
36
40
  # run_script('/var/tmp/myscript', $targets, 'Downloading my application')