bolt 2.36.0 → 2.42.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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +8 -8
  3. data/lib/bolt/bolt_option_parser.rb +7 -3
  4. data/lib/bolt/cli.rb +67 -23
  5. data/lib/bolt/config.rb +70 -45
  6. data/lib/bolt/config/options.rb +104 -79
  7. data/lib/bolt/config/transport/base.rb +2 -2
  8. data/lib/bolt/config/transport/local.rb +1 -0
  9. data/lib/bolt/config/transport/options.rb +11 -68
  10. data/lib/bolt/config/transport/ssh.rb +0 -5
  11. data/lib/bolt/inventory.rb +26 -0
  12. data/lib/bolt/inventory/group.rb +29 -9
  13. data/lib/bolt/inventory/inventory.rb +1 -1
  14. data/lib/bolt/inventory/options.rb +130 -0
  15. data/lib/bolt/inventory/target.rb +10 -11
  16. data/lib/bolt/module.rb +10 -2
  17. data/lib/bolt/module_installer.rb +21 -13
  18. data/lib/bolt/module_installer/resolver.rb +13 -5
  19. data/lib/bolt/outputter.rb +19 -5
  20. data/lib/bolt/outputter/human.rb +20 -1
  21. data/lib/bolt/outputter/json.rb +1 -1
  22. data/lib/bolt/outputter/logger.rb +1 -1
  23. data/lib/bolt/outputter/rainbow.rb +12 -1
  24. data/lib/bolt/pal/yaml_plan/transpiler.rb +5 -1
  25. data/lib/bolt/plugin.rb +42 -6
  26. data/lib/bolt/plugin/cache.rb +76 -0
  27. data/lib/bolt/plugin/module.rb +4 -4
  28. data/lib/bolt/plugin/puppetdb.rb +1 -1
  29. data/lib/bolt/project.rb +38 -13
  30. data/lib/bolt/project_manager.rb +2 -0
  31. data/lib/bolt/project_manager/config_migrator.rb +9 -1
  32. data/lib/bolt/project_manager/module_migrator.rb +2 -0
  33. data/lib/bolt/puppetdb/client.rb +8 -0
  34. data/lib/bolt/rerun.rb +1 -5
  35. data/lib/bolt/shell/bash.rb +7 -1
  36. data/lib/bolt/shell/powershell.rb +21 -3
  37. data/lib/bolt/target.rb +4 -0
  38. data/lib/bolt/transport/local.rb +13 -0
  39. data/lib/bolt/util.rb +22 -0
  40. data/lib/bolt/validator.rb +227 -0
  41. data/lib/bolt/version.rb +1 -1
  42. data/lib/bolt_server/plugin.rb +13 -0
  43. data/lib/bolt_server/plugin/puppet_connect_data.rb +37 -0
  44. data/lib/bolt_server/schemas/connect-data.json +22 -0
  45. data/lib/bolt_server/schemas/partials/task.json +1 -1
  46. data/lib/bolt_server/transport_app.rb +64 -36
  47. metadata +24 -5
  48. data/lib/bolt/config/validator.rb +0 -231
@@ -33,75 +33,25 @@ module Bolt
33
33
  "_plugin" => {
34
34
  description: "The name of the plugin.",
35
35
  type: "string"
36
+ },
37
+ "_cache" => {
38
+ description: "This feature is experimental. Enable plugin caching and set a time-to-live.",
39
+ type: "object",
40
+ required: ["ttl"],
41
+ properties: {
42
+ "ttl" => {
43
+ description: "Time in seconds to keep the plugin cache.",
44
+ type: "integer",
45
+ minimum: 0
46
+ }
47
+ }
36
48
  }
37
49
  }
38
50
  }
39
51
  }.freeze
40
52
 
41
- # The following constants define the various configuration options available to Bolt.
42
- # Each constant is a hash where keys are the configuration option and values are the
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.
53
+ # Definitions used to validate config options.
54
+ # https://github.com/puppetlabs/bolt/blob/main/schemas/README.md
105
55
  OPTIONS = {
106
56
  "apply_settings" => {
107
57
  description: "A map of Puppet settings to use when applying Puppet code using the `apply` "\
@@ -190,6 +140,20 @@ module Bolt
190
140
  _example: "~/.puppetlabs/bolt/inventory.yaml",
191
141
  _default: "project/inventory.yaml"
192
142
  },
143
+ "plugin-cache" => {
144
+ description: "This feature is experimental. Enable plugin caching and set the time-to-live.",
145
+ type: Hash,
146
+ required: ["ttl"],
147
+ properties: {
148
+ "ttl" => {
149
+ description: "Time in seconds to keep the plugin cache.",
150
+ type: Integer,
151
+ minimum: 0
152
+ }
153
+ },
154
+ _plugin: false,
155
+ _example: { "ttl" => 3600 }
156
+ },
193
157
  "log" => {
194
158
  description: "A map of configuration for the logfile output. Under `log`, you can configure log options "\
195
159
  "for `console` and add configuration for individual log files, such as "\
@@ -207,7 +171,7 @@ module Bolt
207
171
  "level" => {
208
172
  description: "The type of information to log.",
209
173
  type: String,
210
- enum: %w[trace debug error info warn fatal any],
174
+ enum: %w[trace debug error info notice warn fatal any],
211
175
  _default: "warn"
212
176
  }
213
177
  }
@@ -226,7 +190,7 @@ module Bolt
226
190
  "level" => {
227
191
  description: "The type of information to log.",
228
192
  type: String,
229
- enum: %w[trace debug error info warn fatal any],
193
+ enum: %w[trace debug error info notice warn fatal any],
230
194
  _default: "warn"
231
195
  }
232
196
  }
@@ -246,6 +210,41 @@ module Bolt
246
210
  _example: ["~/.puppetlabs/bolt/modules", "~/.puppetlabs/bolt/site-modules"],
247
211
  _default: ["project/modules", "project/site-modules", "project/site"]
248
212
  },
213
+ "module-install" => {
214
+ description: "Options that configure where Bolt downloads modules from. This option is only used when "\
215
+ "installing modules using the `bolt module add|install` commands and "\
216
+ "`Add|Install-BoltModule` cmdlets.",
217
+ type: Hash,
218
+ properties: {
219
+ "forge" => {
220
+ description: "A subsection that can have its own `proxy` setting to set an HTTP proxy for Forge "\
221
+ "operations only, and a `baseurl` setting to specify a different Forge host.",
222
+ type: Hash,
223
+ properties: {
224
+ "baseurl" => {
225
+ description: "The URL to the Forge host.",
226
+ type: String,
227
+ format: "uri",
228
+ _example: "https://forge.example.com"
229
+ },
230
+ "proxy" => {
231
+ description: "The HTTP proxy to use for Forge operations.",
232
+ type: String,
233
+ format: "uri",
234
+ _example: "https://my-forge-proxy.com:8080"
235
+ }
236
+ },
237
+ _example: { "baseurl" => "https://forge.example.com", "proxy" => "https://my-forge-proxy.com:8080" }
238
+ },
239
+ "proxy" => {
240
+ description: "The HTTP proxy to use for Git and Forge operations.",
241
+ type: String,
242
+ format: "uri",
243
+ _example: "https://my-proxy.com:8080"
244
+ }
245
+ },
246
+ _plugin: false
247
+ },
249
248
  "modules" => {
250
249
  description: "A list of module dependencies for the project. Each dependency is a map of data specifying "\
251
250
  "the module to install. To install the project's module dependencies, run the `bolt module "\
@@ -351,49 +350,57 @@ module Bolt
351
350
  "cacert" => {
352
351
  description: "The path to the ca certificate for PuppetDB.",
353
352
  type: String,
354
- _example: "/etc/puppetlabs/puppet/ssl/certs/ca.pem"
353
+ _example: "/etc/puppetlabs/puppet/ssl/certs/ca.pem",
354
+ _plugin: true
355
355
  },
356
356
  "cert" => {
357
357
  description: "The path to the client certificate file to use for authentication.",
358
358
  type: String,
359
- _example: "/etc/puppetlabs/puppet/ssl/certs/my-host.example.com.pem"
359
+ _example: "/etc/puppetlabs/puppet/ssl/certs/my-host.example.com.pem",
360
+ _plugin: true
360
361
  },
361
362
  "connect_timeout" => {
362
363
  description: "How long to wait in seconds when establishing connections with PuppetDB.",
363
364
  type: Integer,
364
365
  minimum: 1,
365
366
  _default: 60,
366
- _example: 120
367
+ _example: 120,
368
+ _plugin: true
367
369
  },
368
370
  "key" => {
369
371
  description: "The private key for the certificate.",
370
372
  type: String,
371
- _example: "/etc/puppetlabs/puppet/ssl/private_keys/my-host.example.com.pem"
373
+ _example: "/etc/puppetlabs/puppet/ssl/private_keys/my-host.example.com.pem",
374
+ _plugin: true
372
375
  },
373
376
  "read_timeout" => {
374
377
  description: "How long to wait in seconds for a response from PuppetDB.",
375
378
  type: Integer,
376
379
  minimum: 1,
377
380
  _default: 60,
378
- _example: 120
381
+ _example: 120,
382
+ _plugin: true
379
383
  },
380
384
  "server_urls" => {
381
385
  description: "An array containing the PuppetDB host to connect to. Include the protocol `https` "\
382
386
  "and the port, which is usually `8081`. For example, "\
383
387
  "`https://my-puppetdb-server.com:8081`.",
384
388
  type: Array,
385
- _example: ["https://puppet.example.com:8081"]
389
+ _example: ["https://puppet.example.com:8081"],
390
+ _plugin: true
386
391
  },
387
392
  "token" => {
388
393
  description: "The path to the PE RBAC Token.",
389
394
  type: String,
390
- _example: "~/.puppetlabs/token"
395
+ _example: "~/.puppetlabs/token",
396
+ _plugin: true
391
397
  }
392
398
  },
393
399
  _plugin: true
394
400
  },
395
401
  "puppetfile" => {
396
- description: "A map containing options for the `bolt puppetfile install` command.",
402
+ description: "A map containing options for the `bolt puppetfile install` command and "\
403
+ "`Install-BoltPuppetfile` cmdlet.",
397
404
  type: Hash,
398
405
  properties: {
399
406
  "forge" => {
@@ -408,21 +415,23 @@ module Bolt
408
415
  _example: "https://forge.example.com"
409
416
  },
410
417
  "proxy" => {
411
- description: "The HTTP proxy to use for Git and Forge operations.",
418
+ description: "The HTTP proxy to use for Forge operations.",
412
419
  type: String,
413
420
  format: "uri",
414
- _example: "https://forgeapi.example.com"
421
+ _example: "https://my-forge-proxy.com:8080"
415
422
  }
416
423
  },
417
- _example: { "baseurl" => "https://forge.example.com", "proxy" => "https://forgeapi.example.com" }
424
+ _example: { "baseurl" => "https://forge.example.com", "proxy" => "https://my-forge-proxy.com:8080" }
418
425
  },
419
426
  "proxy" => {
420
427
  description: "The HTTP proxy to use for Git and Forge operations.",
421
428
  type: String,
422
429
  format: "uri",
423
- _example: "https://forgeapi.example.com"
430
+ _example: "https://my-proxy.com:8080"
424
431
  }
425
432
  },
433
+ _deprecation: "This option will be removed in Bolt 3.0. Update your project to use the module "\
434
+ "management feature. For more information, see https://pup.pt/bolt-module-migrate.",
426
435
  _plugin: false
427
436
  },
428
437
  "save-rerun" => {
@@ -434,6 +443,14 @@ module Bolt
434
443
  _example: false,
435
444
  _default: true
436
445
  },
446
+ "spinner" => {
447
+ description: "Whether to print a spinner to the console for long-running Bolt operations.",
448
+ type: [TrueClass, FalseClass],
449
+ _plugin: false,
450
+ _example: false,
451
+ _default: true
452
+ },
453
+
437
454
  "tasks" => {
438
455
  description: "A list of task names and glob patterns to filter the project's tasks by. This option is used "\
439
456
  "to limit the visibility of tasks for users of the project. For example, project authors "\
@@ -468,7 +485,7 @@ module Bolt
468
485
  "specified in the URI.",
469
486
  type: String,
470
487
  enum: TRANSPORT_CONFIG.keys,
471
- _plugin: false,
488
+ _plugin: true,
472
489
  _example: "winrm",
473
490
  _default: "ssh"
474
491
  },
@@ -494,6 +511,7 @@ module Bolt
494
511
  "remote" => {
495
512
  description: "A map of configuration options for the remote transport.",
496
513
  type: Hash,
514
+ additionalProperties: true,
497
515
  _plugin: true,
498
516
  _example: { "run-on" => "proxy_target" }
499
517
  },
@@ -529,6 +547,7 @@ module Bolt
529
547
  puppetdb
530
548
  puppetfile
531
549
  save-rerun
550
+ spinner
532
551
  trusted-external-command
533
552
  ].freeze
534
553
 
@@ -540,12 +559,15 @@ module Bolt
540
559
  format
541
560
  inventory-config
542
561
  log
562
+ module-install
563
+ plugin-cache
543
564
  plugin-hooks
544
565
  plugin_hooks
545
566
  plugins
546
567
  puppetdb
547
568
  puppetfile
548
569
  save-rerun
570
+ spinner
549
571
  ].freeze
550
572
 
551
573
  # Options that are available in a bolt-project.yaml file
@@ -560,15 +582,18 @@ module Bolt
560
582
  inventoryfile
561
583
  log
562
584
  modulepath
585
+ module-install
563
586
  modules
564
587
  name
565
588
  plans
589
+ plugin-cache
566
590
  plugin-hooks
567
591
  plugin_hooks
568
592
  plugins
569
593
  puppetdb
570
594
  puppetfile
571
595
  save-rerun
596
+ spinner
572
597
  tasks
573
598
  trusted-external-command
574
599
  ].freeze
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'bolt/error'
4
4
  require 'bolt/util'
5
- require 'bolt/config/validator'
5
+ require 'bolt/validator'
6
6
  require 'bolt/config/transport/options'
7
7
 
8
8
  module Bolt
@@ -125,7 +125,7 @@ module Bolt
125
125
 
126
126
  # Validation defaults to just asserting the option types
127
127
  private def validate
128
- Bolt::Config::Validator.new.validate(@config.compact, self.class.schema.fetch(:properties))
128
+ Bolt::Validator.new.validate(@config.compact, self.class.schema)
129
129
  end
130
130
  end
131
131
  end
@@ -8,6 +8,7 @@ module Bolt
8
8
  module Transport
9
9
  class Local < Base
10
10
  WINDOWS_OPTIONS = %w[
11
+ bundled-ruby
11
12
  cleanup
12
13
  interpreters
13
14
  tmpdir
@@ -6,73 +6,8 @@ module Bolt
6
6
  module Options
7
7
  LOGIN_SHELLS = %w[sh bash zsh dash ksh powershell].freeze
8
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.
9
+ # Definitions used to validate config options.
10
+ # https://github.com/puppetlabs/bolt/blob/main/schemas/README.md
76
11
  TRANSPORT_OPTIONS = {
77
12
  "basic-auth-only" => {
78
13
  type: [TrueClass, FalseClass],
@@ -81,6 +16,13 @@ module Bolt
81
16
  _default: false,
82
17
  _example: true
83
18
  },
19
+ "bundled-ruby" => {
20
+ description: "Whether to use the Ruby bundled with Bolt packages for local targets.",
21
+ type: [TrueClass, FalseClass],
22
+ _plugin: false,
23
+ _example: true,
24
+ _default: false
25
+ },
84
26
  "cacert" => {
85
27
  type: String,
86
28
  description: "The path to the CA certificate.",
@@ -201,7 +143,8 @@ module Bolt
201
143
  "`task.py`) and the extension is case sensitive. When a target's name is `localhost`, "\
202
144
  "Ruby tasks run with the Bolt Ruby interpreter by default.",
203
145
  additionalProperties: {
204
- type: String
146
+ type: String,
147
+ _plugin: false
205
148
  },
206
149
  propertyNames: {
207
150
  pattern: "^.?[a-zA-Z0-9]+$"