bolt 2.16.0 → 2.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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4472049678531606c70c32415b9fde26f897fae21ffdf4099b01fd301f1dff57
4
- data.tar.gz: 305f69f3690a8a6b5468a57f7a5af8142fa90bf24a72499dc9f06094e007c1b6
3
+ metadata.gz: 8d7b3fbf02e3b0162ead0c7ca8994eb6a96f5f8d49d9b27aa4620a54c111396d
4
+ data.tar.gz: 3ec22c605ca39808ffdc1f9589bdc05921889f4cdf7ef7079682614bd1298a81
5
5
  SHA512:
6
- metadata.gz: af09bca7283a90b7644926048e178778778df5f333998a43719b37353fc5d7fd396212d8a65fcc3644c203189ab7cef6e5799b360f83caff08b879d9aef70dfa
7
- data.tar.gz: 314cfdee1be67a5fa1fe67211081973c8f52999cd4915440c28ecd0a76d880b73051d67dcb73068b3155e731d668bc6e0060a47eb4fd0394f8b254e56a3668c7
6
+ metadata.gz: 71c5644b0b1bcaee1aaf5d74b6e1ae895e82ffa56dc52df9b4fc2995f1fb7541c9da8c3a0a4d31b63b72e04ab2245d4fd377f3bf7eaf18ea4de7f8c7c2f46c6b
7
+ data.tar.gz: 503755fc3f2196d53fc26d6bfbe662671689ed6208ccf9ab06a384eb254d878f2e00d62b182f3c2185d09fc558bed8a2dfa8d2b942024bd62977b0e50e8c0d33
@@ -13,6 +13,7 @@ Puppet::Functions.create_function(:run_command) do
13
13
  # @param options A hash of additional options.
14
14
  # @option options [Boolean] _catch_errors Whether to catch raised errors.
15
15
  # @option options [String] _run_as User to run as using privilege escalation.
16
+ # @option options [Hash] _env_vars Map of environment variables to set
16
17
  # @return A list of results, one entry per target.
17
18
  # @example Run a command on targets
18
19
  # run_command('hostname', $targets, '_catch_errors' => true)
@@ -30,6 +31,7 @@ Puppet::Functions.create_function(:run_command) do
30
31
  # @param options A hash of additional options.
31
32
  # @option options [Boolean] _catch_errors Whether to catch raised errors.
32
33
  # @option options [String] _run_as User to run as using privilege escalation.
34
+ # @option options [Hash] _env_vars Map of environment variables to set
33
35
  # @return A list of results, one entry per target.
34
36
  # @example Run a command on targets
35
37
  # run_command('hostname', $targets, 'Get hostname')
@@ -11,8 +11,9 @@ Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFuncti
11
11
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
12
12
  # @param options A hash of additional options.
13
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
+ # @option options [Boolean] _catch_errors Whether to catch raised errors.
15
+ # @option options [String] _run_as User to run as using privilege escalation.
16
+ # @option options [Hash] _env_vars Map of environment variables to set
16
17
  # @return A list of results, one entry per target.
17
18
  # @example Run a local script on Linux targets as 'root'
18
19
  # run_script('/var/tmp/myscript', $targets, '_run_as' => 'root')
@@ -33,8 +34,9 @@ Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFuncti
33
34
  # @param description A description to be output when calling this function.
34
35
  # @param options A hash of additional options.
35
36
  # @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.
37
+ # @option options [Boolean] _catch_errors Whether to catch raised errors.
38
+ # @option options [String] _run_as User to run as using privilege escalation.
39
+ # @option options [Hash] _env_vars Map of environment variables to set
38
40
  # @return A list of results, one entry per target.
39
41
  # @example Run a script
40
42
  # run_script('/var/tmp/myscript', $targets, 'Downloading my application')
@@ -13,7 +13,7 @@ module Bolt
13
13
  global_config_setters: %w[modulepath project configfile],
14
14
  transports: %w[transport connect-timeout tty ssh-command copy-command],
15
15
  display: %w[format color verbose trace],
16
- global: %w[help version debug] }.freeze
16
+ global: %w[help version debug log-level] }.freeze
17
17
 
18
18
  ACTION_OPTS = OPTIONS.values.flatten.freeze
19
19
 
@@ -709,27 +709,27 @@ module Bolt
709
709
  File.expand_path(moduledir)
710
710
  end
711
711
  end
712
- define('--project FILEPATH', '--boltdir FILEPATH',
712
+ define('--project PATH', '--boltdir PATH',
713
713
  'Specify what project to load config from (default: autodiscovered from current working dir)') do |path|
714
714
  @options[:boltdir] = path
715
715
  end
716
- define('--configfile FILEPATH',
716
+ define('--configfile PATH',
717
717
  'Specify where to load config from (default: ~/.puppetlabs/bolt/bolt.yaml).',
718
718
  'Directory containing bolt.yaml will be used as the project directory.') do |path|
719
719
  @options[:configfile] = path
720
720
  end
721
- define('--hiera-config FILEPATH',
721
+ define('--hiera-config PATH',
722
722
  'Specify where to load Hiera config from (default: ~/.puppetlabs/bolt/hiera.yaml)') do |path|
723
723
  @options[:'hiera-config'] = File.expand_path(path)
724
724
  end
725
- define('-i', '--inventoryfile FILEPATH',
725
+ define('-i', '--inventoryfile PATH',
726
726
  'Specify where to load inventory from (default: ~/.puppetlabs/bolt/inventory.yaml)') do |path|
727
727
  if ENV.include?(Bolt::Inventory::ENVIRONMENT_VAR)
728
728
  raise Bolt::CLIError, "Cannot pass inventory file when #{Bolt::Inventory::ENVIRONMENT_VAR} is set"
729
729
  end
730
730
  @options[:inventoryfile] = Pathname.new(File.expand_path(path))
731
731
  end
732
- define('--puppetfile FILEPATH',
732
+ define('--puppetfile PATH',
733
733
  'Specify a Puppetfile to use when installing modules. (default: ~/.puppetlabs/bolt/Puppetfile)',
734
734
  'Modules are installed in the current project.') do |path|
735
735
  @options[:puppetfile_path] = Pathname.new(File.expand_path(path))
@@ -803,8 +803,15 @@ module Bolt
803
803
  end
804
804
  define('--debug', 'Display debug logging') do |_|
805
805
  @options[:debug] = true
806
+ # We don't actually set '--log-level debug' here, but once the options are evaluated by
807
+ # the config class the end result is the same.
808
+ @warnings << { msg: "Command line option '--debug' is deprecated, set '--log-level debug' instead." }
809
+ end
810
+ define('--log-level LEVEL',
811
+ "Set the log level for the console. Available options are",
812
+ "debug, info, notice, warn, error, fatal, any.") do |level|
813
+ @options[:log] = { 'console' => { 'level' => level } }
806
814
  end
807
-
808
815
  define('--plugin PLUGIN', 'Select the plugin to use') do |plug|
809
816
  @options[:plugin] = plug
810
817
  end
@@ -115,7 +115,12 @@ module Bolt
115
115
  Bolt::Config.from_file(options[:configfile], options)
116
116
  else
117
117
  project = if options[:boltdir]
118
- Bolt::Project.create_project(options[:boltdir])
118
+ dir = Pathname.new(options[:boltdir])
119
+ if (dir + Bolt::Project::BOLTDIR_NAME).directory?
120
+ Bolt::Project.create_project(dir + Bolt::Project::BOLTDIR_NAME)
121
+ else
122
+ Bolt::Project.create_project(dir)
123
+ end
119
124
  else
120
125
  Bolt::Project.find_boltdir(Dir.pwd)
121
126
  end
@@ -245,6 +250,10 @@ module Bolt
245
250
  !options[:object]
246
251
  raise Bolt::CLIError, "Must specify a value to #{options[:action]}"
247
252
  end
253
+
254
+ if options.key?(:debug) && options.key?(:log)
255
+ raise Bolt::CLIError, "Only one of '--debug' or '--log-level' may be specified"
256
+ end
248
257
  end
249
258
 
250
259
  def handle_parser_errors
@@ -6,13 +6,6 @@ require 'pathname'
6
6
  require 'bolt/project'
7
7
  require 'bolt/logger'
8
8
  require 'bolt/util'
9
- # Transport config objects
10
- require 'bolt/config/transport/ssh'
11
- require 'bolt/config/transport/winrm'
12
- require 'bolt/config/transport/orch'
13
- require 'bolt/config/transport/local'
14
- require 'bolt/config/transport/docker'
15
- require 'bolt/config/transport/remote'
16
9
  require 'bolt/config/options'
17
10
 
18
11
  module Bolt
@@ -31,17 +24,6 @@ module Bolt
31
24
  BOLT_CONFIG_NAME = 'bolt.yaml'
32
25
  BOLT_DEFAULTS_NAME = 'bolt-defaults.yaml'
33
26
 
34
- # Transport config classes. Used to load default transport config which
35
- # gets passed along to the inventory.
36
- TRANSPORT_CONFIG = {
37
- 'ssh' => Bolt::Config::Transport::SSH,
38
- 'winrm' => Bolt::Config::Transport::WinRM,
39
- 'pcp' => Bolt::Config::Transport::Orch,
40
- 'local' => Bolt::Config::Transport::Local,
41
- 'docker' => Bolt::Config::Transport::Docker,
42
- 'remote' => Bolt::Config::Transport::Remote
43
- }.freeze
44
-
45
27
  # The default concurrency value that is used when the ulimit is not low (i.e. < 700)
46
28
  DEFAULT_DEFAULT_CONCURRENCY = 100
47
29
 
@@ -316,8 +298,8 @@ module Bolt
316
298
  end
317
299
 
318
300
  # Filter hashes to only include valid options
319
- @data['apply_settings'] = @data['apply_settings'].slice(*SUBOPTIONS['apply_settings'].keys)
320
- @data['puppetfile'] = @data['puppetfile'].slice(*SUBOPTIONS['puppetfile'].keys)
301
+ @data['apply_settings'] = @data['apply_settings'].slice(*OPTIONS['apply_settings'][:properties].keys)
302
+ @data['puppetfile'] = @data['puppetfile'].slice(*OPTIONS['puppetfile'][:properties].keys)
321
303
  end
322
304
 
323
305
  private def normalize_log(target)
@@ -331,7 +313,7 @@ module Bolt
331
313
  next unless val.is_a?(Hash)
332
314
 
333
315
  name = normalize_log(key)
334
- acc[name] = val.slice(*SUBOPTIONS['log'].keys)
316
+ acc[name] = val.slice('append', 'level')
335
317
  .transform_keys(&:to_sym)
336
318
 
337
319
  if (v = acc[name][:level])
@@ -1,148 +1,363 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'bolt/config/transport/ssh'
4
+ require 'bolt/config/transport/winrm'
5
+ require 'bolt/config/transport/orch'
6
+ require 'bolt/config/transport/local'
7
+ require 'bolt/config/transport/docker'
8
+ require 'bolt/config/transport/remote'
9
+
3
10
  module Bolt
4
11
  class Config
5
12
  module Options
13
+ # Transport config classes. Used to load default transport config which
14
+ # gets passed along to the inventory.
15
+ TRANSPORT_CONFIG = {
16
+ 'ssh' => Bolt::Config::Transport::SSH,
17
+ 'winrm' => Bolt::Config::Transport::WinRM,
18
+ 'pcp' => Bolt::Config::Transport::Orch,
19
+ 'local' => Bolt::Config::Transport::Local,
20
+ 'docker' => Bolt::Config::Transport::Docker,
21
+ 'remote' => Bolt::Config::Transport::Remote
22
+ }.freeze
23
+
24
+ # Plugin definition. This is used by the JSON schemas to indicate that an option
25
+ # accepts a plugin reference. Since this isn't used by Bolt to perform automatic
26
+ # type validation, the :type key is set to a JSON type instead of a Ruby type.
27
+ PLUGIN = {
28
+ "_plugin" => {
29
+ description: "A plugin reference.",
30
+ type: "object",
31
+ required: ["_plugin"],
32
+ properties: {
33
+ "_plugin" => {
34
+ description: "The name of the plugin.",
35
+ type: "string"
36
+ }
37
+ }
38
+ }
39
+ }.freeze
40
+
6
41
  # The following constants define the various configuration options available to Bolt.
7
42
  # Each constant is a hash where keys are the configuration option and values are the
8
- # data describing the option. Data includes the following keys:
9
- # :def The **documented** default value. This is the value that is displayed
10
- # in the reference docs and is not used by Bolt to actually set a default
11
- # value.
12
- # :desc The text description of the option that is displayed in documentation.
13
- # :exmp An example value for the option. This is used to generate an example
14
- # configuration file in the reference docs.
15
- # :type The option's expected type. If an option accepts multiple types, this is
16
- # an array of the accepted types. Any options that accept a Boolean value
17
- # should use the [TrueClass, FalseClass] type.
43
+ # option's definition. These options are used in multiple locations:
44
+ #
45
+ # - Automatic type validation when loading and setting configuration
46
+ # - Generating reference documentation for configuration files
47
+ # - Generating JSON schemas for configuration files
48
+ #
49
+ # Data includes keys defined by JSON Schema Draft 07 as well as some metadata used
50
+ # by Bolt to generate documentation. The following keys are used:
51
+ #
52
+ # :description String A detailed description of the option and what it does. This
53
+ # field is used in both documentation and the JSON schemas,
54
+ # and should provide as much detail as possible, including
55
+ # links to relevant documentation.
56
+ #
57
+ # :type Class The expected type of a value. These should be Ruby classes,
58
+ # as this field is used to perform automatic type validation.
59
+ # If an option can accept more than one type, this should be
60
+ # an array of types. Boolean values should set :type to
61
+ # [TrueClass, FalseClass], as Ruby does not have a single
62
+ # Boolean class.
63
+ #
64
+ # :items Hash A definition hash for items in an array. Similar to values
65
+ # for top-level options, items can have a :description, :type,
66
+ # or any other key in this list.
67
+ #
68
+ # :uniqueItems Boolean Whether or not an array should contain only unique items.
69
+ #
70
+ # :properties Hash A hash where keys are sub-options and values are definitions
71
+ # for the sub-option. Similar to values for top-level options,
72
+ # properties can have a :description, :type, or any other key
73
+ # in this list.
74
+ #
75
+ # :additionalProperties A variation of the :properties key, where the hash is a
76
+ # Hash definition for any properties not specified in :properties.
77
+ # This can be used to permit arbitrary sub-options, such as
78
+ # logs for the 'log' option.
79
+ #
80
+ # :required Array An array of properties that are required for options that
81
+ # accept Hash values.
82
+ #
83
+ # :minimum Integer The minimum integer value for an option.
84
+ #
85
+ # :enum Array An array of values that the option recognizes.
86
+ #
87
+ # :pattern String A JSON regex pattern that the option's vaue should match.
88
+ #
89
+ # :format String Requires that a string value matches a format defined by the
90
+ # JSON Schema draft.
91
+ #
92
+ # :_plugin Boolean Whether the option accepts a plugin reference. This is used
93
+ # when generating the JSON schemas to determine whether or not
94
+ # to include a reference to the _plugin definition. If :_plugin
95
+ # is set to true, the script that generates JSON schemas will
96
+ # automatically recurse through the :items and :properties keys
97
+ # and add plugin references if applicable.
98
+ #
99
+ # :_example Any An example value for the option. This is used to generate
100
+ # reference documentation for configuration files.
101
+ #
102
+ # :_default Any The documented default value for the option. This is only
103
+ # used to generate reference documentation for configuration
104
+ # files and is not used by Bolt to actually set default values.
18
105
  OPTIONS = {
19
106
  "apply_settings" => {
20
- desc: "A map of Puppet settings to use when applying Puppet code using the `apply` "\
21
- "plan function or the `bolt apply` command.",
22
- type: Hash
107
+ description: "A map of Puppet settings to use when applying Puppet code using the `apply` "\
108
+ "plan function or the `bolt apply` command.",
109
+ type: Hash,
110
+ properties: {
111
+ "show_diff" => {
112
+ description: "Whether to log and report a contextual diff.",
113
+ type: [TrueClass, FalseClass],
114
+ _example: true,
115
+ _default: false
116
+ }
117
+ },
118
+ _plugin: false
23
119
  },
24
120
  "color" => {
25
- desc: "Whether to use colored output when printing messages to the console.",
121
+ description: "Whether to use colored output when printing messages to the console.",
26
122
  type: [TrueClass, FalseClass],
27
- exmp: false,
28
- def: true
123
+ _plugin: false,
124
+ _example: false,
125
+ _default: true
29
126
  },
30
127
  "compile-concurrency" => {
31
- desc: "The maximum number of simultaneous manifest block compiles.",
128
+ description: "The maximum number of simultaneous manifest block compiles.",
32
129
  type: Integer,
33
- exmp: 4,
34
- def: "Number of cores."
130
+ minimum: 1,
131
+ _plugin: false,
132
+ _example: 5,
133
+ _default: "Number of cores."
35
134
  },
36
135
  "concurrency" => {
37
- desc: "The number of threads to use when executing on remote targets.",
136
+ description: "The number of threads to use when executing on remote targets.",
38
137
  type: Integer,
39
- exmp: 50,
40
- def: "100 or 1/7 the ulimit, whichever is lower."
138
+ minimum: 1,
139
+ _plugin: false,
140
+ _example: 50,
141
+ _default: "100 or 1/7 the ulimit, whichever is lower."
41
142
  },
42
143
  "format" => {
43
- desc: "The format to use when printing results. Options are `human`, `json`, and `rainbow`.",
144
+ description: "The format to use when printing results.",
44
145
  type: String,
45
- exmp: "json",
46
- def: "human"
146
+ enum: %w[human json rainbow],
147
+ _plugin: false,
148
+ _example: "json",
149
+ _default: "human"
47
150
  },
48
151
  "hiera-config" => {
49
- desc: "The path to your Hiera config.",
152
+ description: "The path to the Hiera configuration file.",
50
153
  type: String,
51
- def: "project/hiera.yaml",
52
- exmp: "~/.puppetlabs/bolt/hiera.yaml"
154
+ _plugin: false,
155
+ _example: "~/.puppetlabs/bolt/hiera.yaml",
156
+ _default: "project/hiera.yaml"
53
157
  },
54
158
  "inventory-config" => {
55
- desc: "A map of default configuration options for the inventory. This includes options "\
56
- "for setting the default transport to use when connecting to targets, as well as "\
57
- "options for configuring the default behavior of each transport.",
58
- type: Hash
159
+ description: "A map of default configuration options for the inventory. This includes options "\
160
+ "for setting the default transport to use when connecting to targets, as well as "\
161
+ "options for configuring the default behavior of each transport.",
162
+ type: Hash,
163
+ _plugin: false,
164
+ _example: {}
59
165
  },
60
166
  "inventoryfile" => {
61
- desc: "The path to a structured data inventory file used to refer to groups of targets on the command "\
62
- "line and from plans. Read more about using inventory files in [Inventory "\
63
- "files](inventory_file_v2.md).",
167
+ description: "The path to a structured data inventory file used to refer to groups of targets on the "\
168
+ "command line and from plans. Read more about using inventory files in [Inventory "\
169
+ "files](inventory_file_v2.md).",
64
170
  type: String,
65
- def: "project/inventory.yaml",
66
- exmp: "~/.puppetlabs/bolt/inventory.yaml"
171
+ _plugin: false,
172
+ _example: "~/.puppetlabs/bolt/inventory.yaml",
173
+ _default: "project/inventory.yaml"
67
174
  },
68
175
  "log" => {
69
- desc: "A map of configuration for the logfile output. Configuration can be set for "\
70
- "`console` and individual log files, such as `~/.puppetlabs/bolt/debug.log`. "\
71
- "Each key in the map is the logfile output to configure, with the corresponding "\
72
- "value configuring the logfile output.",
176
+ description: "A map of configuration for the logfile output. Under `log`, you can configure log options "\
177
+ "for `console` and add configuration for individual log files, such as "\
178
+ "~/.puppetlabs/bolt/debug.log`. Individual log files must be valid filepaths. If the log "\
179
+ "file does not exist, then Bolt will create it before logging information.",
73
180
  type: Hash,
74
- exmp: { "console" => { "level" => "info" },
75
- "~/logs/debug.log" => { "append" => false, "level" => "debug" } }
181
+ properties: {
182
+ "console" => {
183
+ description: "Configuration for logs output to the console.",
184
+ type: Hash,
185
+ properties: {
186
+ "level" => {
187
+ description: "The type of information to log.",
188
+ type: String,
189
+ enum: %w[debug error info notice warn fatal any],
190
+ _default: "warn for console, notice for file"
191
+ }
192
+ }
193
+ }
194
+ },
195
+ additionalProperties: {
196
+ description: "Configuration for the logfile output.",
197
+ type: Hash,
198
+ properties: {
199
+ "append" => {
200
+ description: "Whether to append output to an existing log file.",
201
+ type: [TrueClass, FalseClass],
202
+ _default: true
203
+ },
204
+ "level" => {
205
+ description: "The type of information to log.",
206
+ type: String,
207
+ enum: %w[debug error info notice warn fatal any],
208
+ _default: "warn for console, notice for file"
209
+ }
210
+ }
211
+ },
212
+ _plugin: false,
213
+ _example: { "console" => { "level" => "info" },
214
+ "~/logs/debug.log" => { "append" => false, "level" => "debug" } }
76
215
  },
77
216
  "modulepath" => {
78
- desc: "An array of directories that Bolt loads content such as plans and tasks from. Read more "\
79
- "about modules in [Module structure](module_structure.md).",
217
+ description: "An array of directories that Bolt loads content such as plans and tasks from. Read more "\
218
+ "about modules in [Module structure](module_structure.md).",
80
219
  type: [Array, String],
81
- def: ["project/modules", "project/site-modules", "project/site"],
82
- exmp: ["~/.puppetlabs/bolt/modules", "~/.puppetlabs/bolt/site-modules"]
220
+ items: {
221
+ type: String
222
+ },
223
+ _plugin: false,
224
+ _example: ["~/.puppetlabs/bolt/modules", "~/.puppetlabs/bolt/site-modules"],
225
+ _default: ["project/modules", "project/site-modules", "project/site"]
83
226
  },
84
227
  "name" => {
85
- desc: "The name of the Bolt project. When this option is configured, the project is considered a "\
86
- "[Bolt project](experimental_features.md#bolt-projects), allowing Bolt to load content from "\
87
- "the project directory as though it were a module.",
228
+ description: "The name of the Bolt project. When this option is configured, the project is considered a "\
229
+ "[Bolt project](experimental_features.md#bolt-projects), allowing Bolt to load content from "\
230
+ "the project directory as though it were a module.",
88
231
  type: String,
89
- exmp: "myproject"
232
+ _plugin: false,
233
+ _example: "myproject"
90
234
  },
91
235
  "plans" => {
92
- desc: "A list of plan names to show in `bolt plan show` output, if they exist. This option is used to "\
93
- "limit the visibility of plans for users of the project. For example, project authors might want to "\
94
- "limit the visibility of plans that are bundled with Bolt or plans that should only be run as "\
95
- "part of another plan. When this option is not configured, all plans are visible. This "\
96
- "option does not prevent users from running plans that are not part of this list.",
236
+ description: "A list of plan names to show in `bolt plan show` output, if they exist. This option is used "\
237
+ "to limit the visibility of plans for users of the project. For example, project authors "\
238
+ "might want to limit the visibility of plans that are bundled with Bolt or plans that should "\
239
+ "only be run as part of another plan. When this option is not configured, all plans are "\
240
+ "visible. This option does not prevent users from running plans that are not part of this "\
241
+ "list.",
97
242
  type: Array,
98
- exmp: ["myproject", "myproject::foo", "myproject::bar"]
243
+ _plugin: false,
244
+ _example: ["myproject", "myproject::foo", "myproject::bar"]
99
245
  },
100
246
  "plugin_hooks" => {
101
- desc: "A map of [plugin hooks](writing_plugins.md#hooks) and which plugins a hook should use. "\
102
- "The only configurable plugin hook is `puppet_library`, which can use two possible plugins: "\
103
- "[`puppet_agent`](https://github.com/puppetlabs/puppetlabs-puppet_agent#puppet_agentinstall) "\
104
- "and [`task`](using_plugins.md#task).",
247
+ description: "A map of [plugin hooks](writing_plugins.md#hooks) and which plugins a hook should use. "\
248
+ "The only configurable plugin hook is `puppet_library`, which can use two possible plugins: "\
249
+ "[`puppet_agent`](https://github.com/puppetlabs/puppetlabs-puppet_agent#puppet_agentinstall) "\
250
+ "and [`task`](using_plugins.md#task).",
105
251
  type: Hash,
106
- exmp: { "puppet_library" => { "plugin" => "puppet_agent", "version" => "6.15.0", "_run_as" => "root" } }
252
+ _plugin: true,
253
+ _example: { "puppet_library" => { "plugin" => "puppet_agent", "version" => "6.15.0", "_run_as" => "root" } }
107
254
  },
108
255
  "plugins" => {
109
- desc: "A map of plugins and their configuration data, where each key is the name of a plugin and its "\
110
- "value is a map of configuration data. Configurable options are specified by the plugin. Read "\
111
- "more about configuring plugins in [Using plugins](using_plugins.md#configuring-plugins).",
256
+ description: "A map of plugins and their configuration data, where each key is the name of a plugin and "\
257
+ "its value is a map of configuration data. Configurable options are specified by the plugin. "\
258
+ "Read more about configuring plugins in [Using plugins](using_plugins.md#configuring-plugins).",
112
259
  type: Hash,
113
- exmp: { "pkcs7" => { "keysize" => 1024 } }
260
+ _plugin: true,
261
+ _example: { "pkcs7" => { "keysize" => 1024 } }
114
262
  },
115
263
  "puppetdb" => {
116
- desc: "A map containing options for [configuring the Bolt PuppetDB client](bolt_connect_puppetdb.md).",
117
- type: Hash
264
+ description: "A map containing options for [configuring the Bolt PuppetDB "\
265
+ "client](bolt_connect_puppetdb.md).",
266
+ type: Hash,
267
+ properties: {
268
+ "cacert" => {
269
+ description: "The path to the ca certificate for PuppetDB.",
270
+ type: String,
271
+ _example: "/etc/puppetlabs/puppet/ssl/certs/ca.pem"
272
+ },
273
+ "cert" => {
274
+ description: "The path to the client certificate file to use for authentication.",
275
+ type: String,
276
+ _example: "/etc/puppetlabs/puppet/ssl/certs/my-host.example.com.pem"
277
+ },
278
+ "key" => {
279
+ description: "The private key for the certificate.",
280
+ type: String,
281
+ _example: "/etc/puppetlabs/puppet/ssl/private_keys/my-host.example.com.pem"
282
+ },
283
+ "server_urls" => {
284
+ description: "An array containing the PuppetDB host to connect to. Include the protocol `https` "\
285
+ "and the port, which is usually `8081`. For example, "\
286
+ "`https://my-master.example.com:8081`.",
287
+ type: Array,
288
+ _example: ["https://puppet.example.com:8081"]
289
+ },
290
+ "token" => {
291
+ description: "The path to the PE RBAC Token.",
292
+ type: String,
293
+ _example: "~/.puppetlabs/token"
294
+ }
295
+ },
296
+ _plugin: true
118
297
  },
119
298
  "puppetfile" => {
120
- desc: "A map containing options for the `bolt puppetfile install` command.",
121
- type: Hash
299
+ description: "A map containing options for the `bolt puppetfile install` command.",
300
+ type: Hash,
301
+ properties: {
302
+ "forge" => {
303
+ description: "A subsection that can have its own `proxy` setting to set an HTTP proxy for Forge "\
304
+ "operations only, and a `baseurl` setting to specify a different Forge host.",
305
+ type: Hash,
306
+ properties: {
307
+ "baseurl" => {
308
+ description: "The URL to the Forge host.",
309
+ type: String,
310
+ format: "uri",
311
+ _example: "https://forge.example.com"
312
+ },
313
+ "proxy" => {
314
+ description: "The HTTP proxy to use for Git and Forge operations.",
315
+ type: String,
316
+ format: "uri",
317
+ _example: "https://forgeapi.example.com"
318
+ }
319
+ },
320
+ _example: { "baseurl" => "https://forge.example.com", "proxy" => "https://forgeapi.example.com" }
321
+ },
322
+ "proxy" => {
323
+ description: "The HTTP proxy to use for Git and Forge operations.",
324
+ type: String,
325
+ format: "uri",
326
+ _example: "https://forgeapi.example.com"
327
+ }
328
+ },
329
+ _plugin: false
122
330
  },
123
331
  "save-rerun" => {
124
- desc: "Whether to update `.rerun.json` in the Bolt project directory. If "\
125
- "your target names include passwords, set this value to `false` to avoid "\
126
- "writing passwords to disk.",
332
+ description: "Whether to update `.rerun.json` in the Bolt project directory. If "\
333
+ "your target names include passwords, set this value to `false` to avoid "\
334
+ "writing passwords to disk.",
127
335
  type: [TrueClass, FalseClass],
128
- exmp: false,
129
- def: true
336
+ _plugin: false,
337
+ _example: false,
338
+ _default: true
130
339
  },
131
340
  "tasks" => {
132
- desc: "A list of task names to show in `bolt task show` output, if they exist. This option is used to "\
133
- "limit the visibility of tasks for users of the project. For example, project authors might want to "\
134
- "limit the visibility of tasks that are bundled with Bolt or plans that should only be run as "\
135
- "part of a larger workflow. When this option is not configured, all tasks are visible. This "\
136
- "option does not prevent users from running tasks that are not part of this list.",
341
+ description: "A list of task names to show in `bolt task show` output, if they exist. This option is used "\
342
+ "to limit the visibility of tasks for users of the project. For example, project authors "\
343
+ "might want to limit the visibility of tasks that are bundled with Bolt or plans that should "\
344
+ "only be run as part of a larger workflow. When this option is not configured, all tasks "\
345
+ "are visible. This option does not prevent users from running tasks that are not part of "\
346
+ "this list.",
137
347
  type: Array,
138
- exmp: ["myproject", "myproject::foo", "myproject::bar"]
348
+ items: {
349
+ type: String
350
+ },
351
+ _plugin: false,
352
+ _example: ["myproject", "myproject::foo", "myproject::bar"]
139
353
  },
140
354
  "trusted-external-command" => {
141
- desc: "The path to an executable on the Bolt controller that can produce external trusted facts. "\
142
- "**External trusted facts are experimental in both Puppet and Bolt and this API may change or "\
143
- "be removed.**",
355
+ description: "The path to an executable on the Bolt controller that can produce external trusted facts. "\
356
+ "**External trusted facts are experimental in both Puppet and Bolt and this API may change or "\
357
+ "be removed.**",
144
358
  type: String,
145
- exmp: "/etc/puppetlabs/facts/trusted_external.sh"
359
+ _plugin: false,
360
+ _example: "/etc/puppetlabs/facts/trusted_external.sh"
146
361
  }
147
362
  }.freeze
148
363
 
@@ -152,113 +367,50 @@ module Bolt
152
367
  # 'inventory-config' key in bolt-defaults.yaml.
153
368
  INVENTORY_OPTIONS = {
154
369
  "transport" => {
155
- desc: "The default transport to use when the transport for a target is not "\
156
- "specified in the URI.",
370
+ description: "The default transport to use when the transport for a target is not "\
371
+ "specified in the URI.",
157
372
  type: String,
158
- def: "ssh",
159
- exmp: "winrm"
373
+ enum: TRANSPORT_CONFIG.keys,
374
+ _plugin: false,
375
+ _example: "winrm",
376
+ _default: "ssh"
160
377
  },
161
378
  "docker" => {
162
- desc: "A map of configuration options for the docker transport.",
379
+ description: "A map of configuration options for the docker transport.",
163
380
  type: Hash,
164
- exmp: { "cleanup" => false, "service-url" => "https://docker.example.com" }
381
+ _plugin: true,
382
+ _example: { "cleanup" => false, "service-url" => "https://docker.example.com" }
165
383
  },
166
384
  "local" => {
167
- desc: "A map of configuration options for the local transport. The set of available options is "\
168
- "platform dependent.",
385
+ description: "A map of configuration options for the local transport. The set of available options is "\
386
+ "platform dependent.",
169
387
  type: Hash,
170
- exmp: { "cleanup" => false, "tmpdir" => "/tmp/bolt" }
388
+ _plugin: true,
389
+ _example: { "cleanup" => false, "tmpdir" => "/tmp/bolt" }
171
390
  },
172
391
  "pcp" => {
173
- desc: "A map of configuration options for the pcp transport.",
392
+ description: "A map of configuration options for the pcp transport.",
174
393
  type: Hash,
175
- exmp: { "job-poll-interval" => 15, "job-poll-timeout" => 30 }
394
+ _plugin: true,
395
+ _example: { "job-poll-interval" => 15, "job-poll-timeout" => 30 }
176
396
  },
177
397
  "remote" => {
178
- desc: "A map of configuration options for the remote transport.",
398
+ description: "A map of configuration options for the remote transport.",
179
399
  type: Hash,
180
- exmp: { "run-on" => "proxy_target" }
400
+ _plugin: true,
401
+ _example: { "run-on" => "proxy_target" }
181
402
  },
182
403
  "ssh" => {
183
- desc: "A map of configuration options for the ssh transport.",
404
+ description: "A map of configuration options for the ssh transport.",
184
405
  type: Hash,
185
- exmp: { "password" => "hunter2!", "user" => "bolt" }
406
+ _plugin: true,
407
+ _example: { "password" => "hunter2!", "user" => "bolt" }
186
408
  },
187
409
  "winrm" => {
188
- desc: "A map of configuration options for the winrm transport.",
410
+ description: "A map of configuration options for the winrm transport.",
189
411
  type: Hash,
190
- exmp: { "password" => "hunter2!", "user" => "bolt" }
191
- }
192
- }.freeze
193
-
194
- # Suboptions for options that accept hashes.
195
- SUBOPTIONS = {
196
- "apply_settings" => {
197
- "show_diff" => {
198
- desc: "Whether to log and report a contextual diff when files are being replaced. See "\
199
- "[Puppet documentation](https://puppet.com/docs/puppet/latest/configuration.html#showdiff) "\
200
- "for details.",
201
- type: [TrueClass, FalseClass],
202
- exmp: true,
203
- def: false
204
- }
205
- },
206
- "inventory-config" => INVENTORY_OPTIONS,
207
- "log" => {
208
- "append" => {
209
- desc: "Add output to an existing log file. Available only for logs output to a "\
210
- "filepath.",
211
- type: [TrueClass, FalseClass],
212
- def: true
213
- },
214
- "level" => {
215
- desc: "The type of information in the log. Either `debug`, `info`, `notice`, "\
216
- "`warn`, or `error`.",
217
- type: String,
218
- def: "`warn` for console, `notice` for file"
219
- }
220
- },
221
- "puppetdb" => {
222
- "cacert" => {
223
- desc: "The path to the ca certificate for PuppetDB.",
224
- type: String,
225
- exmp: "/etc/puppetlabs/puppet/ssl/certs/ca.pem"
226
- },
227
- "cert" => {
228
- desc: "The path to the client certificate file to use for authentication.",
229
- type: String,
230
- exmp: "/etc/puppetlabs/puppet/ssl/certs/my-host.example.com.pem"
231
- },
232
- "key" => {
233
- desc: "The private key for the certificate.",
234
- type: String,
235
- exmp: "/etc/puppetlabs/puppet/ssl/private_keys/my-host.example.com.pem"
236
- },
237
- "server_urls" => {
238
- desc: "An array containing the PuppetDB host to connect to. Include the protocol `https` "\
239
- "and the port, which is usually `8081`. For example, "\
240
- "`https://my-master.example.com:8081`.",
241
- type: Array,
242
- exmp: ["https://puppet.example.com:8081"]
243
- },
244
- "token" => {
245
- desc: "The path to the PE RBAC Token.",
246
- type: String,
247
- exmp: "~/.puppetlabs/token"
248
- }
249
- },
250
- "puppetfile" => {
251
- "forge" => {
252
- desc: "A subsection that can have its own `proxy` setting to set an HTTP proxy for Forge "\
253
- "operations only, and a `baseurl` setting to specify a different Forge host.",
254
- type: Hash,
255
- exmp: { "baseurl" => "https://forge.example.com", "proxy" => "https://forgeapi.example.com" }
256
- },
257
- "proxy" => {
258
- desc: "The HTTP proxy to use for Git and Forge operations.",
259
- type: String,
260
- exmp: "https://forgeapi.example.com"
261
- }
412
+ _plugin: true,
413
+ _example: { "password" => "hunter2!", "user" => "bolt" }
262
414
  }
263
415
  }.freeze
264
416