bolt 2.15.0 → 2.20.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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +1 -0
  3. data/bolt-modules/boltlib/lib/puppet/functions/add_to_group.rb +1 -0
  4. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +20 -9
  5. data/bolt-modules/boltlib/lib/puppet/functions/catch_errors.rb +1 -0
  6. data/bolt-modules/boltlib/lib/puppet/functions/download_file.rb +123 -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 +1 -0
  33. data/bolt-modules/file/lib/puppet/functions/file/join.rb +2 -0
  34. data/bolt-modules/file/lib/puppet/functions/file/read.rb +2 -0
  35. data/bolt-modules/file/lib/puppet/functions/file/readable.rb +2 -0
  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 +21 -15
  41. data/lib/bolt/apply_result.rb +1 -1
  42. data/lib/bolt/bolt_option_parser.rb +55 -20
  43. data/lib/bolt/catalog.rb +3 -2
  44. data/lib/bolt/cli.rb +116 -47
  45. data/lib/bolt/config.rb +48 -148
  46. data/lib/bolt/config/options.rb +488 -0
  47. data/lib/bolt/config/transport/base.rb +16 -16
  48. data/lib/bolt/config/transport/docker.rb +9 -23
  49. data/lib/bolt/config/transport/local.rb +6 -44
  50. data/lib/bolt/config/transport/options.rb +460 -0
  51. data/lib/bolt/config/transport/orch.rb +9 -18
  52. data/lib/bolt/config/transport/remote.rb +3 -6
  53. data/lib/bolt/config/transport/ssh.rb +74 -154
  54. data/lib/bolt/config/transport/winrm.rb +18 -47
  55. data/lib/bolt/executor.rb +15 -0
  56. data/lib/bolt/inventory/group.rb +4 -3
  57. data/lib/bolt/inventory/inventory.rb +4 -17
  58. data/lib/bolt/inventory/target.rb +18 -5
  59. data/lib/bolt/logger.rb +24 -1
  60. data/lib/bolt/outputter.rb +1 -1
  61. data/lib/bolt/outputter/rainbow.rb +14 -3
  62. data/lib/bolt/pal.rb +31 -11
  63. data/lib/bolt/pal/yaml_plan/evaluator.rb +19 -2
  64. data/lib/bolt/pal/yaml_plan/step.rb +11 -2
  65. data/lib/bolt/pal/yaml_plan/step/download.rb +38 -0
  66. data/lib/bolt/pal/yaml_plan/step/upload.rb +3 -3
  67. data/lib/bolt/plugin/module.rb +2 -4
  68. data/lib/bolt/plugin/puppetdb.rb +3 -2
  69. data/lib/bolt/project.rb +41 -44
  70. data/lib/bolt/puppetdb/client.rb +2 -0
  71. data/lib/bolt/puppetdb/config.rb +16 -0
  72. data/lib/bolt/result.rb +7 -0
  73. data/lib/bolt/shell/bash.rb +53 -45
  74. data/lib/bolt/shell/powershell.rb +23 -12
  75. data/lib/bolt/shell/powershell/snippets.rb +15 -6
  76. data/lib/bolt/transport/base.rb +24 -0
  77. data/lib/bolt/transport/docker.rb +17 -5
  78. data/lib/bolt/transport/docker/connection.rb +20 -2
  79. data/lib/bolt/transport/local/connection.rb +14 -1
  80. data/lib/bolt/transport/orch.rb +20 -0
  81. data/lib/bolt/transport/simple.rb +6 -0
  82. data/lib/bolt/transport/ssh.rb +7 -1
  83. data/lib/bolt/transport/ssh/connection.rb +9 -1
  84. data/lib/bolt/transport/ssh/exec_connection.rb +23 -2
  85. data/lib/bolt/transport/winrm/connection.rb +109 -8
  86. data/lib/bolt/util.rb +26 -11
  87. data/lib/bolt/version.rb +1 -1
  88. data/lib/bolt_server/transport_app.rb +3 -2
  89. data/lib/bolt_spec/bolt_context.rb +7 -2
  90. data/lib/bolt_spec/plans.rb +15 -2
  91. data/lib/bolt_spec/plans/action_stubs.rb +2 -1
  92. data/lib/bolt_spec/plans/action_stubs/download_stub.rb +66 -0
  93. data/lib/bolt_spec/plans/mock_executor.rb +14 -1
  94. data/lib/bolt_spec/run.rb +22 -0
  95. data/libexec/bolt_catalog +3 -2
  96. metadata +20 -29
@@ -7,24 +7,15 @@ module Bolt
7
7
  class Config
8
8
  module Transport
9
9
  class Orch < Base
10
- # NOTE: All transport configuration options should have a corresponding schema definition
11
- # in schemas/bolt-transport-definitions.json
12
- OPTIONS = {
13
- "cacert" => { type: String,
14
- desc: "The path to the CA certificate." },
15
- "host" => { type: String,
16
- desc: "Host name." },
17
- "job-poll-interval" => { type: Integer,
18
- desc: "Set interval to poll orchestrator for job status." },
19
- "job-poll-timeout" => { type: Integer,
20
- desc: "Set time to wait for orchestrator job status." },
21
- "service-url" => { type: String,
22
- desc: "The URL of the orchestrator API." },
23
- "task-environment" => { type: String,
24
- desc: "The environment the orchestrator loads task code from." },
25
- "token-file" => { type: String,
26
- desc: "The path to the token file." }
27
- }.freeze
10
+ OPTIONS = %w[
11
+ cacert
12
+ host
13
+ job-poll-interval
14
+ job-poll-timeout
15
+ service-url
16
+ task-environment
17
+ token-file
18
+ ].freeze
28
19
 
29
20
  DEFAULTS = {
30
21
  "task-environment" => "production"
@@ -7,12 +7,9 @@ module Bolt
7
7
  class Config
8
8
  module Transport
9
9
  class Remote < Base
10
- # NOTE: All transport configuration options should have a corresponding schema definition
11
- # in schemas/bolt-transport-definitions.json
12
- OPTIONS = {
13
- "run-on" => { type: String,
14
- desc: "The proxy target that the task executes on." }
15
- }.freeze
10
+ OPTIONS = %w[
11
+ run-on
12
+ ].freeze
16
13
 
17
14
  DEFAULTS = {
18
15
  "run-on" => "localhost"
@@ -7,148 +7,82 @@ module Bolt
7
7
  class Config
8
8
  module Transport
9
9
  class SSH < Base
10
- LOGIN_SHELLS = %w[sh bash zsh dash ksh powershell].freeze
11
-
12
- # NOTE: All transport configuration options should have a corresponding schema definition
13
- # in schemas/bolt-transport-definitions.json
14
- OPTIONS = {
15
- "cleanup" => { type: TrueClass,
16
- external: true,
17
- desc: "Whether to clean up temporary files created on targets." },
18
- "connect-timeout" => { type: Integer,
19
- desc: "How long to wait when establishing connections." },
20
- "copy-command" => { external: true,
21
- desc: "Command to use when copying files using ssh-command. "\
22
- "Bolt runs `<copy-command> <src> <dest>`. **This option is "\
23
- "experimental.**" },
24
- "disconnect-timeout" => { type: Integer,
25
- desc: "How long to wait before force-closing a connection." },
26
- "encryption-algorithms" => { type: Array,
27
- desc: "List of encryption algorithms to use when establishing a "\
28
- "connection with a target. Supported algorithms are "\
29
- "defined by the Ruby net-ssh library and can be viewed "\
30
- "[here](https://github.com/net-ssh/net-ssh#supported-algorithms). "\
31
- "All supported, non-deprecated algorithms are available by default when "\
32
- "this option is not used. To reference all default algorithms "\
33
- "when using this option, add 'defaults' to the list of supported "\
34
- "algorithms." },
35
- "extensions" => { type: Array,
36
- desc: "List of file extensions that are accepted for scripts or tasks on "\
37
- "Windows. Scripts with these file extensions rely on the target's file "\
38
- "type association to run. For example, if Python is installed on the "\
39
- "system, a `.py` script runs with `python.exe`. The extensions `.ps1`, "\
40
- "`.rb`, and `.pp` are always allowed and run via hard-coded "\
41
- "executables." },
42
- "host" => { type: String,
43
- external: true,
44
- desc: "Host name." },
45
- "host-key-algorithms" => { type: Array,
46
- desc: "List of host key algorithms to use when establishing a connection "\
47
- "with a target. Supported algorithms are defined by the Ruby net-ssh "\
48
- "library "\
49
- "([docs](https://github.com/net-ssh/net-ssh#supported-algorithms)). "\
50
- "All supported, non-deprecated algorithms are available by default when "\
51
- "this option is not used. To reference all default algorithms "\
52
- "using this option, add 'defaults' to the list of supported "\
53
- "algorithms." },
54
- "host-key-check" => { type: TrueClass,
55
- external: true,
56
- desc: "Whether to perform host key validation when connecting." },
57
- "interpreters" => { type: Hash,
58
- external: true,
59
- desc: "A map of an extension name to the absolute path of an executable, "\
60
- "enabling you to override the shebang defined in a task executable. "\
61
- "The extension can optionally be specified with the `.` character "\
62
- "(`.py` and `py` both map to a task executable `task.py`) and the "\
63
- "extension is case sensitive. When a target's name is `localhost`, "\
64
- "Ruby tasks run with the Bolt Ruby interpreter by default." },
65
- "kex-algorithms" => { type: Array,
66
- desc: "List of key exchange algorithms to use when establishing a "\
67
- "connection to a target. Supported algorithms are defined by the "\
68
- "Ruby net-ssh library "\
69
- "([docs](https://github.com/net-ssh/net-ssh#supported-algorithms)). "\
70
- "All supported, non-deprecated algorithms are available by default when "\
71
- "this option is not used. To reference all default algorithms "\
72
- "using this option, add 'defaults' to the list of supported "\
73
- "algorithms." },
74
- "load-config" => { type: TrueClass,
75
- desc: "Whether to load system SSH configuration." },
76
- "login-shell" => { type: String,
77
- desc: "Which login shell Bolt should expect on the target. "\
78
- "Supported shells are #{LOGIN_SHELLS.join(', ')}. "\
79
- "**This option is experimental.**" },
80
- "mac-algorithms" => { type: Array,
81
- desc: "List of message authentication code algorithms to use when "\
82
- "establishing a connection to a target. Supported algorithms are "\
83
- "defined by the Ruby net-ssh library "\
84
- "([docs](https://github.com/net-ssh/net-ssh#supported-algorithms)). "\
85
- "All supported, non-deprecated algorithms are available by default when "\
86
- "this option is not used. To reference all default algorithms "\
87
- "using this option, add 'defaults' to the list of supported "\
88
- "algorithms." },
89
- "password" => { type: String,
90
- desc: "Login password." },
91
- "port" => { type: Integer,
92
- external: true,
93
- desc: "Connection port." },
94
- "private-key" => { external: true,
95
- desc: "Either the path to the private key file to use for authentication, or "\
96
- "a hash with the key `key-data` and the contents of the private key." },
97
- "proxyjump" => { type: String,
98
- desc: "A jump host to proxy connections through, and an optional user to "\
99
- "connect with." },
100
- "run-as" => { type: String,
101
- external: true,
102
- desc: "A different user to run commands as after login." },
103
- "run-as-command" => { type: Array,
104
- external: true,
105
- desc: "The command to elevate permissions. Bolt appends the user and command "\
106
- "strings to the configured `run-as-command` before running it on the "\
107
- "target. This command must not require an interactive password prompt, "\
108
- "and the `sudo-password` option is ignored when `run-as-command` is "\
109
- "specified. The `run-as-command` must be specified as an array." },
110
- "script-dir" => { type: String,
111
- external: true,
112
- desc: "The subdirectory of the tmpdir to use in place of a randomized "\
113
- "subdirectory for uploading and executing temporary files on the "\
114
- "target. It's expected that this directory already exists as a subdir "\
115
- "of tmpdir, which is either configured or defaults to `/tmp`." },
116
- "ssh-command" => { external: true,
117
- desc: "Command and flags to use when SSHing. This enables the external "\
118
- "SSH transport which shells out to the specified command. "\
119
- "**This option is experimental.**" },
120
- "sudo-executable" => { type: String,
121
- external: true,
122
- desc: "The executable to use when escalating to the configured `run-as` "\
123
- "user. This is useful when you want to escalate using the configured "\
124
- "`sudo-password`, since `run-as-command` does not use `sudo-password` "\
125
- "or support prompting. The command executed on the target is "\
126
- "`<sudo-executable> -S -u <user> -p custom_bolt_prompt <command>`. "\
127
- "**This option is experimental.**" },
128
- "sudo-password" => { type: String,
129
- external: true,
130
- desc: "Password to use when changing users via `run-as`." },
131
- "tmpdir" => { type: String,
132
- external: true,
133
- desc: "The directory to upload and execute temporary files on the target." },
134
- "tty" => { type: TrueClass,
135
- desc: "Request a pseudo tty for the session. This option is generally "\
136
- "only used in conjunction with the `run-as` option when the sudoers "\
137
- "policy requires a `tty`." },
138
- "user" => { type: String,
139
- external: true,
140
- desc: "Login user." }
141
- }.freeze
10
+ # Options available when using the net-ssh-based transport
11
+ OPTIONS = %w[
12
+ cleanup
13
+ connect-timeout
14
+ disconnect-timeout
15
+ encryption-algorithms
16
+ extensions
17
+ host
18
+ host-key-algorithms
19
+ host-key-check
20
+ interpreters
21
+ kex-algorithms
22
+ load-config
23
+ login-shell
24
+ mac-algorithms
25
+ password
26
+ port
27
+ private-key
28
+ proxyjump
29
+ script-dir
30
+ tmpdir
31
+ tty
32
+ user
33
+ ].concat(RUN_AS_OPTIONS).sort.freeze
34
+
35
+ # Options available when using the native ssh transport
36
+ NATIVE_OPTIONS = %w[
37
+ cleanup
38
+ copy-command
39
+ host
40
+ host-key-check
41
+ interpreters
42
+ native-ssh
43
+ port
44
+ private-key
45
+ script-dir
46
+ ssh-command
47
+ tmpdir
48
+ user
49
+ ].concat(RUN_AS_OPTIONS).sort.freeze
142
50
 
143
51
  DEFAULTS = {
144
52
  "cleanup" => true,
145
53
  "connect-timeout" => 10,
146
- "tty" => false,
147
- "load-config" => true,
148
54
  "disconnect-timeout" => 5,
149
- "login-shell" => 'bash'
55
+ "load-config" => true,
56
+ "login-shell" => 'bash',
57
+ "tty" => false
150
58
  }.freeze
151
59
 
60
+ # The set of options available for the ssh and native ssh transports overlap, so we
61
+ # need to check which transport is used before fully initializing, otherwise options
62
+ # may not be filtered correctly.
63
+ def initialize(data = {}, project = nil)
64
+ assert_hash_or_config(data)
65
+ @native = true if data['native-ssh']
66
+ super(data, project)
67
+ end
68
+
69
+ # This method is used to filter CLI options in the Config class. This
70
+ # should include `ssh-command` so that we can later warn if the option
71
+ # is present without `native-ssh`
72
+ def self.options
73
+ %w[ssh-command native-ssh].concat(OPTIONS)
74
+ end
75
+
76
+ private def filter(unfiltered)
77
+ # Because we filter before merging config together it's impossible to
78
+ # know whether both ssh-command *and* native-ssh will be specified
79
+ # unless they are both in the filter. However, we can't add
80
+ # ssh-command to OPTIONS since that's used for documenting available
81
+ # options. This makes it so that ssh-command is preserved so we can
82
+ # warn once all config is resolved if native-ssh isn't set.
83
+ @native ? unfiltered.slice(*NATIVE_OPTIONS) : unfiltered.slice(*self.class.options)
84
+ end
85
+
152
86
  private def validate
153
87
  super
154
88
 
@@ -163,11 +97,11 @@ module Bolt
163
97
  @config['private-key'] = File.expand_path(key_opt, @project)
164
98
 
165
99
  # We have an explicit test for this to only warn if using net-ssh transport
166
- Bolt::Util.validate_file('ssh key', @config['private-key']) if @config['ssh-command']
100
+ Bolt::Util.validate_file('ssh key', @config['private-key']) if @config['native-ssh']
167
101
  end
168
102
 
169
- if key_opt.instance_of?(Hash) && @config['ssh-command']
170
- raise Bolt::ValidationError, 'private-key must be a filepath when using ssh-command'
103
+ if key_opt.instance_of?(Hash) && @config['native-ssh']
104
+ raise Bolt::ValidationError, 'private-key must be a filepath when using native-ssh'
171
105
  end
172
106
  end
173
107
 
@@ -197,24 +131,10 @@ module Bolt
197
131
  end
198
132
  end
199
133
 
200
- if @config['ssh-command'] && !@config['load-config']
201
- msg = 'Cannot use external SSH transport with load-config set to false'
134
+ if @config['native-ssh'] && !@config['load-config']
135
+ msg = 'Cannot use native SSH transport with load-config set to false'
202
136
  raise Bolt::ValidationError, msg
203
137
  end
204
-
205
- if (ssh_cmd = @config['ssh-command'])
206
- unless ssh_cmd.is_a?(String) || ssh_cmd.is_a?(Array)
207
- raise Bolt::ValidationError,
208
- "ssh-command must be a String or Array, received #{ssh_cmd.class} #{ssh_cmd.inspect}"
209
- end
210
- end
211
-
212
- if (copy_cmd = @config['copy-command'])
213
- unless copy_cmd.is_a?(String) || copy_cmd.is_a?(Array)
214
- raise Bolt::ValidationError,
215
- "copy-command must be a String or Array, received #{copy_cmd.class} #{copy_cmd.inspect}"
216
- end
217
- end
218
138
  end
219
139
  end
220
140
  end
@@ -7,53 +7,24 @@ module Bolt
7
7
  class Config
8
8
  module Transport
9
9
  class WinRM < Base
10
- # NOTE: All transport configuration options should have a corresponding schema definition
11
- # in schemas/bolt-transport-definitions.json
12
- OPTIONS = {
13
- "basic-auth-only" => { type: TrueClass,
14
- desc: "Force basic authentication. This option is only available when using SSL." },
15
- "cacert" => { type: String,
16
- desc: "The path to the CA certificate." },
17
- "cleanup" => { type: TrueClass,
18
- desc: "Whether to clean up temporary files created on targets." },
19
- "connect-timeout" => { type: Integer,
20
- desc: "How long Bolt should wait when establishing connections." },
21
- "extensions" => { type: Array,
22
- desc: "List of file extensions that are accepted for scripts or tasks. "\
23
- "Scripts with these file extensions rely on the target's file type "\
24
- "association to run. For example, if Python is installed on the system, "\
25
- "a `.py` script runs with `python.exe`. The extensions `.ps1`, `.rb`, and "\
26
- "`.pp` are always allowed and run via hard-coded executables." },
27
- "file-protocol" => { type: String,
28
- desc: "Which file transfer protocol to use. Either `winrm` or `smb`. Using `smb` is "\
29
- "recommended for large file transfers." },
30
- "host" => { type: String,
31
- desc: "Host name." },
32
- "interpreters" => { type: Hash,
33
- desc: "A map of an extension name to the absolute path of an executable, "\
34
- "enabling you to override the shebang defined in a task executable. The "\
35
- "extension can optionally be specified with the `.` character (`.py` and "\
36
- "`py` both map to a task executable `task.py`) and the extension is case "\
37
- "sensitive. When a target's name is `localhost`, Ruby tasks run with the "\
38
- "Bolt Ruby interpreter by default." },
39
- "password" => { type: String,
40
- desc: "Login password. **Required unless using Kerberos.**" },
41
- "port" => { type: Integer,
42
- desc: "Connection port." },
43
- "realm" => { type: String,
44
- desc: "Kerberos realm (Active Directory domain) to authenticate against." },
45
- "smb-port" => { type: Integer,
46
- desc: "With file-protocol set to smb, this is the port to establish a "\
47
- "connection on." },
48
- "ssl" => { type: TrueClass,
49
- desc: "When true, Bolt uses secure https connections for WinRM." },
50
- "ssl-verify" => { type: TrueClass,
51
- desc: "When true, verifies the targets certificate matches the cacert." },
52
- "tmpdir" => { type: String,
53
- desc: "The directory to upload and execute temporary files on the target." },
54
- "user" => { type: String,
55
- desc: "Login user. **Required unless using Kerberos.**" }
56
- }.freeze
10
+ OPTIONS = %w[
11
+ basic-auth-only
12
+ cacert
13
+ cleanup
14
+ connect-timeout
15
+ extensions
16
+ file-protocol
17
+ host
18
+ interpreters
19
+ password
20
+ port
21
+ realm
22
+ smb-port
23
+ ssl
24
+ ssl-verify
25
+ tmpdir
26
+ user
27
+ ].freeze
57
28
 
58
29
  DEFAULTS = {
59
30
  "basic-auth-only" => false,
@@ -320,6 +320,21 @@ module Bolt
320
320
  end
321
321
  end
322
322
 
323
+ def download_file(targets, source, destination, options = {})
324
+ description = options.fetch(:description, "file download from #{source} to #{destination}")
325
+ FileUtils.mkdir_p(destination)
326
+
327
+ log_action(description, targets) do
328
+ options[:run_as] = run_as if run_as && !options.key?(:run_as)
329
+
330
+ batch_execute(targets) do |transport, batch|
331
+ with_node_logging("Downloading file #{source} to #{destination}", batch) do
332
+ transport.batch_download(batch, source, destination, options, &method(:publish_event))
333
+ end
334
+ end
335
+ end
336
+ end
337
+
323
338
  def run_plan(scope, plan, params)
324
339
  plan.call_by_name_with_scope(scope, params, true)
325
340
  end
@@ -16,7 +16,7 @@ module Bolt
16
16
  DATA_KEYS = %w[config facts vars features plugin_hooks].freeze
17
17
  TARGET_KEYS = DATA_KEYS + %w[name alias uri]
18
18
  GROUP_KEYS = DATA_KEYS + %w[name groups targets]
19
- CONFIG_KEYS = Bolt::Config::INVENTORY_CONFIG.keys
19
+ CONFIG_KEYS = Bolt::Config::INVENTORY_OPTIONS.keys
20
20
 
21
21
  def initialize(input, plugins)
22
22
  @logger = Logging.logger[self]
@@ -50,10 +50,11 @@ module Bolt
50
50
  # or it could be a name/alias of a target defined in another group.
51
51
  # We can't tell the difference until all groups have been resolved,
52
52
  # so we store the string on its own here and process it later.
53
- if target.is_a?(String)
53
+ case target
54
+ when String
54
55
  @string_targets << target
55
56
  # Handle plugins at this level so that lookups cannot trigger recursive lookups
56
- elsif target.is_a?(Hash)
57
+ when Hash
57
58
  add_target_definition(target)
58
59
  else
59
60
  raise ValidationError.new("Target entry must be a String or Hash, not #{target.class}", @name)
@@ -78,20 +78,6 @@ module Bolt
78
78
  target_array.first
79
79
  end
80
80
 
81
- def self.localhost_defaults(data)
82
- defaults = {
83
- 'config' => {
84
- 'transport' => 'local',
85
- 'local' => { 'interpreters' => { '.rb' => RbConfig.ruby } }
86
- },
87
- 'features' => ['puppet-agent']
88
- }
89
- data = Bolt::Util.deep_merge(defaults, data)
90
- # If features is an empty array deep_merge won't add the puppet-agent
91
- data['features'] += ['puppet-agent'] if data['features'].empty?
92
- data
93
- end
94
-
95
81
  #### PRIVATE ####
96
82
  def group_data_for(target_name)
97
83
  @groups.group_collect(target_name)
@@ -123,11 +109,12 @@ module Bolt
123
109
  private :resolve_name
124
110
 
125
111
  def expand_targets(targets)
126
- if targets.is_a? Bolt::Target
112
+ case targets
113
+ when Bolt::Target
127
114
  targets
128
- elsif targets.is_a? Array
115
+ when Array
129
116
  targets.map { |tish| expand_targets(tish) }
130
- elsif targets.is_a? String
117
+ when String
131
118
  # Expand a comma-separated list
132
119
  targets.split(/[[:space:],]+/).reject(&:empty?).map do |name|
133
120
  ts = resolve_name(name)