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
@@ -2,11 +2,14 @@
2
2
 
3
3
  require 'bolt/error'
4
4
  require 'bolt/util'
5
+ require 'bolt/config/transport/options'
5
6
 
6
7
  module Bolt
7
8
  class Config
8
9
  module Transport
9
10
  class Base
11
+ include Bolt::Config::Transport::Options
12
+
10
13
  attr_reader :input
11
14
 
12
15
  def initialize(data = {}, project = nil)
@@ -96,7 +99,7 @@ module Bolt
96
99
  end
97
100
 
98
101
  private def filter(unfiltered)
99
- unfiltered.slice(*self.class.options.keys)
102
+ unfiltered.slice(*self.class.options)
100
103
  end
101
104
 
102
105
  private def assert_hash_or_config(data)
@@ -116,24 +119,21 @@ module Bolt
116
119
  assert_type
117
120
  end
118
121
 
119
- # Validates that each option is the correct type. Types are loaded from the OPTIONS hash.
122
+ # Validates that each option is the correct type. Types are loaded from the TRANSPORT_OPTIONS hash.
120
123
  private def assert_type
121
124
  @config.each_pair do |opt, val|
122
- next unless (type = self.class.options.dig(opt, :type))
123
-
124
- # Options that accept a Boolean value are indicated by the type TrueClass, so we
125
- # need some special handling here to check if the value is either true or false.
126
- if type == TrueClass
127
- unless [true, false].include?(val)
128
- raise Bolt::ValidationError,
129
- "#{opt} must be a Boolean true or false, received #{val.class} #{val.inspect}"
130
- end
131
- else
132
- unless val.nil? || val.is_a?(type)
133
- raise Bolt::ValidationError,
134
- "#{opt} must be a #{type}, received #{val.class} #{val.inspect}"
135
- end
125
+ types = Array(TRANSPORT_OPTIONS.dig(opt, :type)).compact
126
+
127
+ next if val.nil? || types.empty? || types.include?(val.class)
128
+
129
+ # Ruby doesn't have a Boolean class, so add it to the types list if TrueClass or FalseClass
130
+ # are present.
131
+ if types.include?(TrueClass) || types.include?(FalseClass)
132
+ types = types - [TrueClass, FalseClass] + ['Boolean']
136
133
  end
134
+
135
+ raise Bolt::ValidationError,
136
+ "#{opt} must be of type #{types.join(', ')}; received #{val.class} #{val.inspect} "
137
137
  end
138
138
  end
139
139
  end
@@ -7,29 +7,15 @@ module Bolt
7
7
  class Config
8
8
  module Transport
9
9
  class Docker < Base
10
- # NOTE: All transport configuration options should have a corresponding schema definition
11
- # in schemas/bolt-transport-definitions.json
12
- OPTIONS = {
13
- "cleanup" => { type: TrueClass,
14
- desc: "Whether to clean up temporary files created on targets." },
15
- "host" => { type: String,
16
- desc: "Host name." },
17
- "interpreters" => { type: Hash,
18
- desc: "A map of an extension name to the absolute path of an executable, "\
19
- "enabling you to override the shebang defined in a task executable. The "\
20
- "extension can optionally be specified with the `.` character (`.py` and "\
21
- "`py` both map to a task executable `task.py`) and the extension is case "\
22
- "sensitive. When a target's name is `localhost`, Ruby tasks run with the "\
23
- "Bolt Ruby interpreter by default." },
24
- "service-url" => { type: String,
25
- desc: "URL of the Docker host used for API requests." },
26
- "shell-command" => { type: String,
27
- desc: "A shell command to wrap any Docker exec commands in, such as `bash -lc`." },
28
- "tmpdir" => { type: String,
29
- desc: "The directory to upload and execute temporary files on the target." },
30
- "tty" => { type: TrueClass,
31
- desc: "Whether to enable tty on exec commands." }
32
- }.freeze
10
+ OPTIONS = %w[
11
+ cleanup
12
+ host
13
+ interpreters
14
+ service-url
15
+ shell-command
16
+ tmpdir
17
+ tty
18
+ ].freeze
33
19
 
34
20
  DEFAULTS = {
35
21
  'cleanup' => true
@@ -7,51 +7,13 @@ module Bolt
7
7
  class Config
8
8
  module Transport
9
9
  class Local < Base
10
- # NOTE: All transport configuration options should have a corresponding schema definition
11
- # in schemas/bolt-transport-definitions.json
12
- OPTIONS = {
13
- "cleanup" => { type: TrueClass,
14
- desc: "Whether to clean up temporary files created on targets." },
15
- "interpreters" => { type: Hash,
16
- desc: "A map of an extension name to the absolute path of an executable, "\
17
- "enabling you to override the shebang defined in a task executable. The "\
18
- "extension can optionally be specified with the `.` character (`.py` and "\
19
- "`py` both map to a task executable `task.py`) and the extension is case "\
20
- "sensitive. When a target's name is `localhost`, Ruby tasks run with the "\
21
- "Bolt Ruby interpreter by default." },
22
- "run-as" => { type: String,
23
- desc: "A different user to run commands as after login." },
24
- "run-as-command" => { type: Array,
25
- desc: "The command to elevate permissions. Bolt appends the user and command "\
26
- "strings to the configured `run-as-command` before running it on the target. "\
27
- "This command must not require an interactive password prompt, and the "\
28
- "`sudo-password` option is ignored when `run-as-command` is specified. The "\
29
- "`run-as-command` must be specified as an array." },
30
- "sudo-executable" => { type: String,
31
- desc: "The executable to use when escalating to the configured `run-as` user. This "\
32
- "is useful when you want to escalate using the configured `sudo-password`, "\
33
- "since `run-as-command` does not use `sudo-password` or support prompting. "\
34
- "The command executed on the target is `<sudo-executable> -S -u <user> -p "\
35
- "custom_bolt_prompt <command>`. **This option is experimental.**" },
36
- "sudo-password" => { type: String,
37
- desc: "Password to use when changing users via `run-as`." },
38
- "tmpdir" => { type: String,
39
- desc: "The directory to copy and execute temporary files." }
40
- }.freeze
10
+ WINDOWS_OPTIONS = %w[
11
+ cleanup
12
+ interpreters
13
+ tmpdir
14
+ ].freeze
41
15
 
42
- WINDOWS_OPTIONS = {
43
- "cleanup" => { type: TrueClass,
44
- desc: "Whether to clean up temporary files created on targets." },
45
- "interpreters" => { type: Hash,
46
- desc: "A map of an extension name to the absolute path of an executable, "\
47
- "enabling you to override the shebang defined in a task executable. The "\
48
- "extension can optionally be specified with the `.` character (`.py` and "\
49
- "`py` both map to a task executable `task.py`) and the extension is case "\
50
- "sensitive. When a target's name is `localhost`, Ruby tasks run with the "\
51
- "Bolt Ruby interpreter by default." },
52
- "tmpdir" => { type: String,
53
- desc: "The directory to copy and execute temporary files." }
54
- }.freeze
16
+ OPTIONS = WINDOWS_OPTIONS.dup.concat(RUN_AS_OPTIONS).sort.freeze
55
17
 
56
18
  DEFAULTS = {
57
19
  'cleanup' => true
@@ -0,0 +1,460 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bolt
4
+ class Config
5
+ module Transport
6
+ module Options
7
+ LOGIN_SHELLS = %w[sh bash zsh dash ksh powershell].freeze
8
+
9
+ # The following constants define the various configuration options available to Bolt's
10
+ # transports. Each constant is a hash where keys are the configuration option and values
11
+ # are the option's definition. These options are used in multiple locations:
12
+ #
13
+ # - Automatic type validation when loading and setting configuration
14
+ # - Generating reference documentation for configuration files
15
+ # - Generating JSON schemas for configuration files
16
+ #
17
+ # Data includes keys defined by JSON Schema Draft 07 as well as some metadata used
18
+ # by Bolt to generate documentation. The following keys are used:
19
+ #
20
+ # :description String A detailed description of the option and what it does. This
21
+ # field is used in both documentation and the JSON schemas,
22
+ # and should provide as much detail as possible, including
23
+ # links to relevant documentation.
24
+ #
25
+ # :type Class The expected type of a value. These should be Ruby classes,
26
+ # as this field is used to perform automatic type validation.
27
+ # If an option can accept more than one type, this should be
28
+ # an array of types. Boolean values should set :type to
29
+ # [TrueClass, FalseClass], as Ruby does not have a single
30
+ # Boolean class.
31
+ #
32
+ # :items Hash A definition hash for items in an array. Similar to values
33
+ # for top-level options, items can have a :description, :type,
34
+ # or any other key in this list.
35
+ #
36
+ # :uniqueItems Boolean Whether or not an array should contain only unique items.
37
+ #
38
+ # :properties Hash A hash where keys are sub-options and values are definitions
39
+ # for the sub-option. Similar to values for top-level options,
40
+ # properties can have a :description, :type, or any other key
41
+ # in this list.
42
+ #
43
+ # :additionalProperties A variation of the :properties key, where the hash is a
44
+ # Hash definition for any properties not specified in :properties.
45
+ # This can be used to permit arbitrary sub-options, such as
46
+ # logs for the 'log' option.
47
+ #
48
+ # :propertyNames Hash A hash that defines the properties that an option's property
49
+ # names must adhere to.
50
+ #
51
+ # :required Array An array of properties that are required for options that
52
+ # accept Hash values.
53
+ #
54
+ # :minimum Integer The minimum integer value for an option.
55
+ #
56
+ # :enum Array An array of values that the option recognizes.
57
+ #
58
+ # :pattern String A JSON regex pattern that the option's vaue should match.
59
+ #
60
+ # :format String Requires that a string value matches a format defined by the
61
+ # JSON Schema draft.
62
+ #
63
+ # :_plugin Boolean Whether the option accepts a plugin reference. This is used
64
+ # when generating the JSON schemas to determine whether or not
65
+ # to include a reference to the _plugin definition. If :_plugin
66
+ # is set to true, the script that generates JSON schemas will
67
+ # automatically recurse through the :items and :properties keys
68
+ # and add plugin references if applicable.
69
+ #
70
+ # :_example Any An example value for the option. This is used to generate
71
+ # reference documentation for configuration files.
72
+ #
73
+ # :_default Any The documented default value for the option. This is only
74
+ # used to generate reference documentation for configuration
75
+ # files and is not used by Bolt to actually set default values.
76
+ TRANSPORT_OPTIONS = {
77
+ "basic-auth-only" => {
78
+ type: [TrueClass, FalseClass],
79
+ description: "Whether to force basic authentication. This option is only available when using SSL.",
80
+ _plugin: true,
81
+ _default: false,
82
+ _example: true
83
+ },
84
+ "cacert" => {
85
+ type: String,
86
+ description: "The path to the CA certificate.",
87
+ _plugin: true,
88
+ _example: "~/.puppetlabs/puppet/cert.pem"
89
+ },
90
+ "cleanup" => {
91
+ type: [TrueClass, FalseClass],
92
+ description: "Whether to clean up temporary files created on targets. When running commands on a target, "\
93
+ "Bolt may create temporary files. After completing the command, these files are "\
94
+ "automatically deleted. This value can be set to 'false' if you wish to leave these "\
95
+ "temporary files on the target.",
96
+ _plugin: true,
97
+ _default: true,
98
+ _example: false
99
+ },
100
+ "connect-timeout" => {
101
+ type: Integer,
102
+ description: "How long to wait in seconds when establishing connections. Set this value higher if you "\
103
+ "frequently encounter connection timeout errors when running Bolt.",
104
+ minimum: 1,
105
+ _plugin: true,
106
+ _default: 10,
107
+ _example: 15
108
+ },
109
+ "copy-command" => {
110
+ type: [Array, String],
111
+ description: "The command to use when copying files using native SSH. Bolt runs `<copy-command> <src> "\
112
+ "<dest>`. This option is used when you need support for features or algorithms that are not "\
113
+ "supported by the net-ssh Ruby library. **This option is experimental.** You can read more "\
114
+ "about this option in [Native SSH transport](experimental_features.md#native-ssh-transport).",
115
+ items: {
116
+ type: String
117
+ },
118
+ _plugin: true,
119
+ _default: %w[scp -r],
120
+ _example: %w[scp -r -F ~/ssh-config/myconf]
121
+ },
122
+ "disconnect-timeout" => {
123
+ type: Integer,
124
+ description: "How long to wait in seconds before force-closing a connection.",
125
+ minimum: 1,
126
+ _plugin: true,
127
+ _default: 5,
128
+ _example: 10
129
+ },
130
+ "encryption-algorithms" => {
131
+ type: Array,
132
+ description: "A list of encryption algorithms to use when establishing a connection "\
133
+ "to a target. Supported algorithms are defined by the Ruby net-ssh library and can be "\
134
+ "viewed [here](https://github.com/net-ssh/net-ssh#supported-algorithms). All supported, "\
135
+ "non-deprecated algorithms are available by default when this option is not used. To "\
136
+ "reference all default algorithms using this option, add 'defaults' to the list of "\
137
+ "supported algorithms.",
138
+ uniqueItems: true,
139
+ items: {
140
+ type: String
141
+ },
142
+ _plugin: true,
143
+ _example: %w[defaults idea-cbc]
144
+ },
145
+ "extensions" => {
146
+ type: Array,
147
+ description: "A list of file extensions that are accepted for scripts or tasks on "\
148
+ "Windows. Scripts with these file extensions rely on the target's file "\
149
+ "type association to run. For example, if Python is installed on the "\
150
+ "system, a `.py` script runs with `python.exe`. The extensions `.ps1`, "\
151
+ "`.rb`, and `.pp` are always allowed and run via hard-coded "\
152
+ "executables.",
153
+ uniqueItems: true,
154
+ items: {
155
+ type: String
156
+ },
157
+ _plugin: true,
158
+ _example: [".sh"]
159
+ },
160
+ "file-protocol" => {
161
+ type: String,
162
+ description: "Which file transfer protocol to use. Either `winrm` or `smb`. Using `smb` is "\
163
+ "recommended for large file transfers.",
164
+ enum: %w[smb winrm],
165
+ _plugin: true,
166
+ _default: "winrm",
167
+ _example: "smb"
168
+ },
169
+ "host" => {
170
+ type: String,
171
+ description: "The target's hostname.",
172
+ _plugin: true,
173
+ _example: "docker_host_production"
174
+ },
175
+ "host-key-algorithms" => {
176
+ type: Array,
177
+ description: "A list of host key algorithms to use when establishing a connection "\
178
+ "to a target. Supported algorithms are defined by the Ruby net-ssh library and can be "\
179
+ "viewed [here](https://github.com/net-ssh/net-ssh#supported-algorithms). All supported, "\
180
+ "non-deprecated algorithms are available by default when this option is not used. To "\
181
+ "reference all default algorithms using this option, add 'defaults' to the list of "\
182
+ "supported algorithms.",
183
+ uniqueItems: true,
184
+ items: {
185
+ type: String
186
+ },
187
+ _plugin: true,
188
+ _example: %w[defaults ssh-dss]
189
+ },
190
+ "host-key-check" => {
191
+ type: [TrueClass, FalseClass],
192
+ description: "Whether to perform host key validation when connecting.",
193
+ _plugin: true,
194
+ _example: false
195
+ },
196
+ "interpreters" => {
197
+ type: Hash,
198
+ description: "A map of an extension name to the absolute path of an executable, enabling you to "\
199
+ "override the shebang defined in a task executable. The extension can optionally be "\
200
+ "specified with the `.` character (`.py` and `py` both map to a task executable "\
201
+ "`task.py`) and the extension is case sensitive. When a target's name is `localhost`, "\
202
+ "Ruby tasks run with the Bolt Ruby interpreter by default.",
203
+ additionalProperties: {
204
+ type: String
205
+ },
206
+ propertyNames: {
207
+ pattern: "^.?[a-zA-Z0-9]+$"
208
+ },
209
+ _plugin: true,
210
+ _example: { "rb" => "/usr/bin/ruby" }
211
+ },
212
+ "job-poll-interval" => {
213
+ type: Integer,
214
+ description: "The interval, in seconds, to poll orchestrator for job status.",
215
+ minimum: 1,
216
+ _plugin: true,
217
+ _example: 2
218
+ },
219
+ "job-poll-timeout" => {
220
+ type: Integer,
221
+ description: "The time, in seconds, to wait for orchestrator job status.",
222
+ minimum: 1,
223
+ _plugin: true,
224
+ _example: 2000
225
+ },
226
+ "kex-algorithms" => {
227
+ type: Array,
228
+ description: "A list of key exchange algorithms to use when establishing a connection "\
229
+ "to a target. Supported algorithms are defined by the Ruby net-ssh library and can be "\
230
+ "viewed [here](https://github.com/net-ssh/net-ssh#supported-algorithms). All supported, "\
231
+ "non-deprecated algorithms are available by default when this option is not used. To "\
232
+ "reference all default algorithms using this option, add 'defaults' to the list of "\
233
+ "supported algorithms.",
234
+ uniqueItems: true,
235
+ items: {
236
+ type: String
237
+ },
238
+ _plugin: true,
239
+ _example: %w[defaults diffie-hellman-group1-sha1]
240
+ },
241
+ "load-config" => {
242
+ type: [TrueClass, FalseClass],
243
+ description: "Whether to load system SSH configuration from '~/.ssh/config' and '/etc/ssh_config'.",
244
+ _plugin: true,
245
+ _default: true,
246
+ _example: false
247
+ },
248
+ "login-shell" => {
249
+ type: String,
250
+ description: "Which login shell Bolt should expect on the target. Supported shells are " \
251
+ "#{LOGIN_SHELLS.join(', ')}. **This option is experimental.**",
252
+ enum: LOGIN_SHELLS,
253
+ _plugin: true,
254
+ _default: "bash",
255
+ _example: "powershell"
256
+ },
257
+ "mac-algorithms" => {
258
+ type: Array,
259
+ description: "List of message authentication code algorithms to use when establishing a connection "\
260
+ "to a target. Supported algorithms are defined by the Ruby net-ssh library and can be "\
261
+ "viewed [here](https://github.com/net-ssh/net-ssh#supported-algorithms). All supported, "\
262
+ "non-deprecated algorithms are available by default when this option is not used. To "\
263
+ "reference all default algorithms using this option, add 'defaults' to the list of "\
264
+ "supported algorithms.",
265
+ uniqueItems: true,
266
+ items: {
267
+ type: String
268
+ },
269
+ _plugin: true,
270
+ _example: %w[defaults hmac-md5]
271
+ },
272
+ "native-ssh" => {
273
+ type: [TrueClass, FalseClass],
274
+ description: "This enables the native SSH transport, which shells out to SSH instead of using the "\
275
+ "net-ssh Ruby library",
276
+ _default: false,
277
+ _example: true
278
+ },
279
+ "password" => {
280
+ type: String,
281
+ description: "The password to use to login.",
282
+ _plugin: true,
283
+ _example: "hunter2!"
284
+ },
285
+ "port" => {
286
+ type: Integer,
287
+ description: "The port to use when connecting to the target.",
288
+ minimum: 0,
289
+ _plugin: true,
290
+ _example: 22
291
+ },
292
+ "private-key" => {
293
+ type: [Hash, String],
294
+ description: "Either the path to the private key file to use for authentication, or "\
295
+ "a hash with the key `key-data` and the contents of the private key.",
296
+ required: ["key-data"],
297
+ properties: {
298
+ "key-data" => {
299
+ description: "The contents of the private key.",
300
+ type: String
301
+ }
302
+ },
303
+ _plugin: true,
304
+ _example: "~/.ssh/id_rsa"
305
+ },
306
+ "proxyjump" => {
307
+ type: String,
308
+ description: "A jump host to proxy connections through, and an optional user to connect with.",
309
+ format: "uri",
310
+ _plugin: true,
311
+ _example: "jump.example.com"
312
+ },
313
+ "realm" => {
314
+ type: String,
315
+ description: "The Kerberos realm (Active Directory domain) to authenticate against.",
316
+ _plugin: true,
317
+ _example: "BOLT.PRODUCTION"
318
+ },
319
+ "run-as" => {
320
+ type: String,
321
+ description: "The user to run commands as after login. The run-as user must be different than the "\
322
+ "login user.",
323
+ _plugin: true,
324
+ _example: "root"
325
+ },
326
+ "run-as-command" => {
327
+ type: Array,
328
+ description: "The command to elevate permissions. Bolt appends the user and command strings to the "\
329
+ "configured `run-as-command` before running it on the target. This command must not require "\
330
+ " aninteractive password prompt, and the `sudo-password` option is ignored when "\
331
+ "`run-as-command` is specified. The `run-as-command` must be specified as an array.",
332
+ items: {
333
+ type: String
334
+ },
335
+ _plugin: true,
336
+ _example: ["sudo", "-nkSEu"]
337
+ },
338
+ "run-on" => {
339
+ type: String,
340
+ description: "The proxy target that the task executes on.",
341
+ format: "uri",
342
+ _plugin: true,
343
+ _default: "localhost",
344
+ _example: "proxy_target"
345
+ },
346
+ "script-dir" => {
347
+ type: String,
348
+ description: "The subdirectory of the tmpdir to use in place of a randomized "\
349
+ "subdirectory for uploading and executing temporary files on the "\
350
+ "target. It's expected that this directory already exists as a subdir "\
351
+ "of tmpdir, which is either configured or defaults to `/tmp`.",
352
+ _plugin: true,
353
+ _example: "bolt_scripts"
354
+ },
355
+ "service-url" => {
356
+ type: String,
357
+ description: "The URL of the host used for API requests.",
358
+ format: "uri",
359
+ _plugin: true,
360
+ _example: "https://api.example.com"
361
+ },
362
+ "shell-command" => {
363
+ type: String,
364
+ description: "A shell command to wrap any Docker exec commands in, such as `bash -lc`.",
365
+ _plugin: true,
366
+ _example: "bash -lc"
367
+ },
368
+ "smb-port" => {
369
+ type: Integer,
370
+ description: "The port to use when connecting to the target when file-protocol is set to 'smb'.",
371
+ minimum: 0,
372
+ _plugin: true,
373
+ _example: 445
374
+ },
375
+ "ssh-command" => {
376
+ type: [Array, String],
377
+ description: "The command and flags to use when SSHing. This option is used when you need support for "\
378
+ "features or algorithms that are not supported by the net-ssh Ruby library. **This option "\
379
+ "is experimental.** You can read more about this option in [Native SSH "\
380
+ "transport](experimental_features.md#native-ssh-transport).",
381
+ items: {
382
+ type: String
383
+ },
384
+ _plugin: true,
385
+ _default: 'ssh',
386
+ _example: %w[ssh -o Ciphers=chacha20-poly1305@openssh.com]
387
+ },
388
+ "ssl" => {
389
+ type: [TrueClass, FalseClass],
390
+ description: "Whether to use secure https connections for WinRM.",
391
+ _plugin: true,
392
+ _default: true,
393
+ _example: false
394
+ },
395
+ "ssl-verify" => {
396
+ type: [TrueClass, FalseClass],
397
+ description: "Whether to verify that the target's certificate matches the cacert.",
398
+ _plugin: true,
399
+ _default: true,
400
+ _example: false
401
+ },
402
+ "sudo-executable" => {
403
+ type: String,
404
+ description: "The executable to use when escalating to the configured `run-as` user. This is useful "\
405
+ "when you want to escalate using the configured `sudo-password`, since `run-as-command` "\
406
+ "does not use `sudo-password` or support prompting. The command executed on the target "\
407
+ "is `<sudo-executable> -S -u <user> -p custom_bolt_prompt <command>`. **This option is "\
408
+ "experimental.**",
409
+ _plugin: true,
410
+ _example: "dzdo"
411
+ },
412
+ "sudo-password" => {
413
+ type: String,
414
+ description: "The password to use when changing users via `run-as`.",
415
+ _plugin: true,
416
+ _example: "p@$$w0rd!"
417
+ },
418
+ "task-environment" => {
419
+ type: String,
420
+ description: "The environment the orchestrator loads task code from.",
421
+ _plugin: true,
422
+ _default: "production",
423
+ _example: "development"
424
+ },
425
+ "tmpdir" => {
426
+ type: String,
427
+ description: "The directory to upload and execute temporary files on the target.",
428
+ _plugin: true,
429
+ _example: "/tmp/bolt"
430
+ },
431
+ "token-file" => {
432
+ type: String,
433
+ description: "The path to the token file.",
434
+ _plugin: true,
435
+ _example: "~/.puppetlabs/puppet/token.pem"
436
+ },
437
+ "tty" => {
438
+ type: [TrueClass, FalseClass],
439
+ description: "Whether to enable tty on exec commands.",
440
+ _plugin: true,
441
+ _example: true
442
+ },
443
+ "user" => {
444
+ type: String,
445
+ description: "The user name to login as.",
446
+ _plugin: true,
447
+ _example: "bolt"
448
+ }
449
+ }.freeze
450
+
451
+ RUN_AS_OPTIONS = %w[
452
+ run-as
453
+ run-as-command
454
+ sudo-executable
455
+ sudo-password
456
+ ].freeze
457
+ end
458
+ end
459
+ end
460
+ end