bolt 2.42.0 → 3.3.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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +21 -19
  3. data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +1 -1
  4. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +25 -0
  5. data/bolt-modules/boltlib/lib/puppet/functions/parallelize.rb +6 -8
  6. data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +2 -2
  7. data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +27 -5
  8. data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -1
  9. data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +7 -3
  10. data/bolt-modules/file/lib/puppet/functions/file/read.rb +3 -2
  11. data/lib/bolt/analytics.rb +3 -2
  12. data/lib/bolt/applicator.rb +11 -1
  13. data/lib/bolt/apply_result.rb +1 -1
  14. data/lib/bolt/bolt_option_parser.rb +9 -116
  15. data/lib/bolt/catalog.rb +10 -29
  16. data/lib/bolt/cli.rb +90 -154
  17. data/lib/bolt/config.rb +66 -239
  18. data/lib/bolt/config/options.rb +79 -102
  19. data/lib/bolt/config/transport/local.rb +1 -0
  20. data/lib/bolt/config/transport/lxd.rb +21 -0
  21. data/lib/bolt/config/transport/options.rb +9 -2
  22. data/lib/bolt/config/transport/orch.rb +1 -0
  23. data/lib/bolt/executor.rb +23 -6
  24. data/lib/bolt/inventory.rb +1 -1
  25. data/lib/bolt/inventory/group.rb +7 -4
  26. data/lib/bolt/logger.rb +123 -11
  27. data/lib/bolt/module_installer.rb +6 -4
  28. data/lib/bolt/module_installer/puppetfile.rb +2 -2
  29. data/lib/bolt/module_installer/resolver.rb +59 -14
  30. data/lib/bolt/module_installer/specs/forge_spec.rb +10 -4
  31. data/lib/bolt/module_installer/specs/git_spec.rb +19 -4
  32. data/lib/bolt/outputter/human.rb +56 -17
  33. data/lib/bolt/outputter/json.rb +16 -16
  34. data/lib/bolt/outputter/rainbow.rb +3 -3
  35. data/lib/bolt/pal.rb +95 -15
  36. data/lib/bolt/pal/yaml_plan.rb +9 -4
  37. data/lib/bolt/pal/yaml_plan/evaluator.rb +5 -153
  38. data/lib/bolt/pal/yaml_plan/step.rb +91 -52
  39. data/lib/bolt/pal/yaml_plan/step/command.rb +16 -16
  40. data/lib/bolt/pal/yaml_plan/step/download.rb +15 -16
  41. data/lib/bolt/pal/yaml_plan/step/eval.rb +11 -11
  42. data/lib/bolt/pal/yaml_plan/step/message.rb +13 -4
  43. data/lib/bolt/pal/yaml_plan/step/plan.rb +19 -15
  44. data/lib/bolt/pal/yaml_plan/step/resources.rb +82 -21
  45. data/lib/bolt/pal/yaml_plan/step/script.rb +32 -17
  46. data/lib/bolt/pal/yaml_plan/step/task.rb +19 -16
  47. data/lib/bolt/pal/yaml_plan/step/upload.rb +16 -17
  48. data/lib/bolt/pal/yaml_plan/transpiler.rb +2 -1
  49. data/lib/bolt/plan_creator.rb +1 -1
  50. data/lib/bolt/plugin.rb +2 -2
  51. data/lib/bolt/plugin/cache.rb +7 -7
  52. data/lib/bolt/plugin/module.rb +0 -23
  53. data/lib/bolt/plugin/puppet_connect_data.rb +77 -0
  54. data/lib/bolt/plugin/puppetdb.rb +1 -1
  55. data/lib/bolt/project.rb +54 -81
  56. data/lib/bolt/project_manager.rb +5 -4
  57. data/lib/bolt/project_manager/module_migrator.rb +7 -6
  58. data/lib/bolt/rerun.rb +1 -1
  59. data/lib/bolt/result.rb +6 -1
  60. data/lib/bolt/shell.rb +16 -0
  61. data/lib/bolt/shell/bash.rb +57 -25
  62. data/lib/bolt/shell/bash/tmpdir.rb +6 -3
  63. data/lib/bolt/shell/powershell.rb +33 -10
  64. data/lib/bolt/shell/powershell/snippets.rb +37 -150
  65. data/lib/bolt/task.rb +2 -2
  66. data/lib/bolt/transport/base.rb +0 -9
  67. data/lib/bolt/transport/docker.rb +1 -125
  68. data/lib/bolt/transport/docker/connection.rb +86 -161
  69. data/lib/bolt/transport/local.rb +1 -9
  70. data/lib/bolt/transport/lxd.rb +26 -0
  71. data/lib/bolt/transport/lxd/connection.rb +99 -0
  72. data/lib/bolt/transport/orch/connection.rb +1 -1
  73. data/lib/bolt/transport/ssh.rb +1 -2
  74. data/lib/bolt/transport/ssh/connection.rb +2 -2
  75. data/lib/bolt/transport/winrm/connection.rb +1 -1
  76. data/lib/bolt/validator.rb +2 -2
  77. data/lib/bolt/version.rb +1 -1
  78. data/lib/bolt_server/config.rb +1 -1
  79. data/lib/bolt_server/transport_app.rb +61 -32
  80. data/lib/bolt_spec/bolt_context.rb +9 -4
  81. data/lib/bolt_spec/plans.rb +1 -109
  82. data/lib/bolt_spec/plans/action_stubs.rb +1 -1
  83. data/lib/bolt_spec/plans/mock_executor.rb +4 -0
  84. data/libexec/bolt_catalog +1 -1
  85. data/modules/aggregate/plans/count.pp +21 -0
  86. data/modules/aggregate/plans/targets.pp +21 -0
  87. data/modules/puppet_connect/plans/test_input_data.pp +67 -0
  88. data/modules/puppetdb_fact/plans/init.pp +10 -0
  89. metadata +13 -9
  90. data/modules/aggregate/plans/nodes.pp +0 -36
@@ -4,6 +4,7 @@ require 'bolt/config/transport/ssh'
4
4
  require 'bolt/config/transport/winrm'
5
5
  require 'bolt/config/transport/orch'
6
6
  require 'bolt/config/transport/local'
7
+ require 'bolt/config/transport/lxd'
7
8
  require 'bolt/config/transport/docker'
8
9
  require 'bolt/config/transport/remote'
9
10
 
@@ -17,6 +18,7 @@ module Bolt
17
18
  'winrm' => Bolt::Config::Transport::WinRM,
18
19
  'pcp' => Bolt::Config::Transport::Orch,
19
20
  'local' => Bolt::Config::Transport::Local,
21
+ 'lxd' => Bolt::Config::Transport::LXD,
20
22
  'docker' => Bolt::Config::Transport::Docker,
21
23
  'remote' => Bolt::Config::Transport::Remote
22
24
  }.freeze
@@ -53,31 +55,38 @@ module Bolt
53
55
  # Definitions used to validate config options.
54
56
  # https://github.com/puppetlabs/bolt/blob/main/schemas/README.md
55
57
  OPTIONS = {
56
- "apply_settings" => {
58
+ "apply-settings" => {
57
59
  description: "A map of Puppet settings to use when applying Puppet code using the `apply` "\
58
60
  "plan function or the `bolt apply` command.",
59
61
  type: Hash,
60
62
  properties: {
61
- "show_diff" => {
62
- description: "Whether to log and report a contextual diff.",
63
+ "evaltrace" => {
64
+ description: "Whether each resource should log when it is being evaluated. This allows "\
65
+ "you to interactively see exactly what is being done.",
63
66
  type: [TrueClass, FalseClass],
64
67
  _example: true,
65
68
  _default: false
66
- }
67
- },
68
- _plugin: false,
69
- _deprecation: "This option will be removed in Bolt 3.0. Use `apply-settings` instead."
70
- },
71
- "apply-settings" => {
72
- description: "A map of Puppet settings to use when applying Puppet code using the `apply` "\
73
- "plan function or the `bolt apply` command.",
74
- type: Hash,
75
- properties: {
69
+ },
70
+ "log_level" => {
71
+ description: "The log level for logs in apply reports from Puppet. These can be seen "\
72
+ "in ApplyResults.",
73
+ type: String,
74
+ enum: %w[debug info notice warning err alert emerg crit],
75
+ _example: "debug",
76
+ _default: "notice"
77
+ },
76
78
  "show_diff" => {
77
79
  description: "Whether to log and report a contextual diff.",
78
80
  type: [TrueClass, FalseClass],
79
81
  _example: true,
80
82
  _default: false
83
+ },
84
+ "trace" => {
85
+ description: "Whether to print stack traces on some errors. Will print internal Ruby "\
86
+ "stack trace interleaved with Puppet function frames.",
87
+ type: [TrueClass, FalseClass],
88
+ _example: true,
89
+ _default: false
81
90
  }
82
91
  },
83
92
  _plugin: false
@@ -105,6 +114,17 @@ module Bolt
105
114
  _example: 50,
106
115
  _default: "100 or 1/7 the ulimit, whichever is lower."
107
116
  },
117
+ "disable-warnings" => {
118
+ description: "An array of IDs of warnings to suppress. Warnings with a matching ID will not be logged "\
119
+ "by Bolt. If you are upgrading Bolt to a new major version, you should re-enable all warnings "\
120
+ "until you have finished upgrading.",
121
+ type: Array,
122
+ items: {
123
+ type: String
124
+ },
125
+ _plugin: false,
126
+ _example: ["powershell_2"]
127
+ },
108
128
  "format" => {
109
129
  description: "The format to use when printing results.",
110
130
  type: String,
@@ -128,18 +148,6 @@ module Bolt
128
148
  _plugin: false,
129
149
  _example: {}
130
150
  },
131
- "inventoryfile" => {
132
- description: "The path to a structured data inventory file used to refer to groups of targets on the "\
133
- "command line and from plans. Read more about using inventory files in [Inventory "\
134
- "files](inventory_file_v2.md).",
135
- type: String,
136
- _plugin: false,
137
- _deprecation: "This option will be removed in Bolt 3.0. Use the `--inventoryfile` command-line option "\
138
- "to use a non-default inventory file or move the file contents to `inventory.yaml` in the "\
139
- "project directory.",
140
- _example: "~/.puppetlabs/bolt/inventory.yaml",
141
- _default: "project/inventory.yaml"
142
- },
143
151
  "plugin-cache" => {
144
152
  description: "This feature is experimental. Enable plugin caching and set the time-to-live.",
145
153
  type: Hash,
@@ -171,7 +179,7 @@ module Bolt
171
179
  "level" => {
172
180
  description: "The type of information to log.",
173
181
  type: String,
174
- enum: %w[trace debug error info notice warn fatal any],
182
+ enum: %w[trace debug error info warn fatal any],
175
183
  _default: "warn"
176
184
  }
177
185
  }
@@ -190,7 +198,7 @@ module Bolt
190
198
  "level" => {
191
199
  description: "The type of information to log.",
192
200
  type: String,
193
- enum: %w[trace debug error info notice warn fatal any],
201
+ enum: %w[trace debug error info warn fatal any],
194
202
  _default: "warn"
195
203
  }
196
204
  }
@@ -208,7 +216,7 @@ module Bolt
208
216
  },
209
217
  _plugin: false,
210
218
  _example: ["~/.puppetlabs/bolt/modules", "~/.puppetlabs/bolt/site-modules"],
211
- _default: ["project/modules", "project/site-modules", "project/site"]
219
+ _default: ["project/modules"]
212
220
  },
213
221
  "module-install" => {
214
222
  description: "Options that configure where Bolt downloads modules from. This option is only used when "\
@@ -260,6 +268,10 @@ module Bolt
260
268
  description: "The name of the module.",
261
269
  type: String
262
270
  },
271
+ "resolve" => {
272
+ description: "Whether to resolve the module's dependencies when installing modules.",
273
+ type: [TrueClass, FalseClass]
274
+ },
263
275
  "version_requirement" => {
264
276
  description: "The version requirement for the module. Accepts a specific version (1.2.3), version "\
265
277
  "shorthand (1.2.x), or a version range (>= 1.2.0).",
@@ -274,15 +286,24 @@ module Bolt
274
286
  description: "The URL to the public git repository.",
275
287
  type: String
276
288
  },
289
+ "name" => {
290
+ description: "The name of the module. Required when `resolve` is `false`.",
291
+ type: String
292
+ },
277
293
  "ref" => {
278
294
  description: "The git reference to check out. Can be either a branch, tag, or commit SHA.",
279
295
  type: String
296
+ },
297
+ "resolve" => {
298
+ description: "Whether to resolve the module's dependencies when installing modules.",
299
+ type: [TrueClass, FalseClass]
280
300
  }
281
301
  }
282
302
  }
283
303
  ]
284
304
  },
285
305
  _plugin: false,
306
+ _default: [],
286
307
  _example: [
287
308
  "puppetlabs-facts",
288
309
  { "name" => "puppetlabs-mysql" },
@@ -311,16 +332,6 @@ module Bolt
311
332
  _plugin: false,
312
333
  _example: ["myproject", "myproject::foo", "myproject::bar", "myproject::deploy::*"]
313
334
  },
314
- "plugin_hooks" => {
315
- description: "A map of [plugin hooks](writing_plugins.md#hooks) and which plugins a hook should use. "\
316
- "The only configurable plugin hook is `puppet_library`, which can use two possible plugins: "\
317
- "[`puppet_agent`](https://github.com/puppetlabs/puppetlabs-puppet_agent#puppet_agentinstall) "\
318
- "and [`task`](using_plugins.md#task).",
319
- type: Hash,
320
- _plugin: true,
321
- _example: { "puppet_library" => { "plugin" => "puppet_agent", "version" => "6.15.0", "_run_as" => "root" } },
322
- _deprecation: "This option will be removed in Bolt 3.0. Use `plugin-hooks` instead."
323
- },
324
335
  "plugin-hooks" => {
325
336
  description: "A map of [plugin hooks](writing_plugins.md#hooks) and which plugins a hook should use. "\
326
337
  "The only configurable plugin hook is `puppet_library`, which can use two possible plugins: "\
@@ -398,42 +409,6 @@ module Bolt
398
409
  },
399
410
  _plugin: true
400
411
  },
401
- "puppetfile" => {
402
- description: "A map containing options for the `bolt puppetfile install` command and "\
403
- "`Install-BoltPuppetfile` cmdlet.",
404
- type: Hash,
405
- properties: {
406
- "forge" => {
407
- description: "A subsection that can have its own `proxy` setting to set an HTTP proxy for Forge "\
408
- "operations only, and a `baseurl` setting to specify a different Forge host.",
409
- type: Hash,
410
- properties: {
411
- "baseurl" => {
412
- description: "The URL to the Forge host.",
413
- type: String,
414
- format: "uri",
415
- _example: "https://forge.example.com"
416
- },
417
- "proxy" => {
418
- description: "The HTTP proxy to use for Forge operations.",
419
- type: String,
420
- format: "uri",
421
- _example: "https://my-forge-proxy.com:8080"
422
- }
423
- },
424
- _example: { "baseurl" => "https://forge.example.com", "proxy" => "https://my-forge-proxy.com:8080" }
425
- },
426
- "proxy" => {
427
- description: "The HTTP proxy to use for Git and Forge operations.",
428
- type: String,
429
- format: "uri",
430
- _example: "https://my-proxy.com:8080"
431
- }
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.",
435
- _plugin: false
436
- },
437
412
  "save-rerun" => {
438
413
  description: "Whether to update `.rerun.json` in the Bolt project directory. If "\
439
414
  "your target names include passwords, set this value to `false` to avoid "\
@@ -450,7 +425,14 @@ module Bolt
450
425
  _example: false,
451
426
  _default: true
452
427
  },
453
-
428
+ "stream" => {
429
+ description: "Whether to stream output from scripts and commands to the console. "\
430
+ "**This option is experimental**.",
431
+ type: [TrueClass, FalseClass],
432
+ _plugin: false,
433
+ _default: false,
434
+ _example: true
435
+ },
454
436
  "tasks" => {
455
437
  description: "A list of task names and glob patterns to filter the project's tasks by. This option is used "\
456
438
  "to limit the visibility of tasks for users of the project. For example, project authors "\
@@ -467,8 +449,8 @@ module Bolt
467
449
  },
468
450
  "trusted-external-command" => {
469
451
  description: "The path to an executable on the Bolt controller that can produce external trusted facts. "\
470
- "**External trusted facts are experimental in both Puppet and Bolt and this API may change or "\
471
- "be removed.**",
452
+ "**External trusted facts are experimental in both Puppet and Bolt and this API might "\
453
+ "change or be removed.**",
472
454
  type: String,
473
455
  _plugin: false,
474
456
  _example: "/etc/puppetlabs/facts/trusted_external.sh"
@@ -477,8 +459,8 @@ module Bolt
477
459
 
478
460
  # Options that configure the inventory, specifically the default transport
479
461
  # used by targets and the transports themselves. These options are used in
480
- # bolt.yaml, under a 'config' key in inventory.yaml, and under the
481
- # 'inventory-config' key in bolt-defaults.yaml.
462
+ # bolt-defaults.yaml under 'inventory-config' and in inventory.yaml under
463
+ # 'config'.
482
464
  INVENTORY_OPTIONS = {
483
465
  "transport" => {
484
466
  description: "The default transport to use when the transport for a target is not "\
@@ -502,6 +484,13 @@ module Bolt
502
484
  _plugin: true,
503
485
  _example: { "cleanup" => false, "tmpdir" => "/tmp/bolt" }
504
486
  },
487
+ "lxd" => {
488
+ description: "A map of configuration options for the LXD transport. The LXD transport is "\
489
+ "experimental and might include breaking changes between minor versions.",
490
+ type: Hash,
491
+ _plugin: true,
492
+ _example: { cleanup: false }
493
+ },
505
494
  "pcp" => {
506
495
  description: "A map of configuration options for the pcp transport.",
507
496
  type: Hash,
@@ -529,57 +518,46 @@ module Bolt
529
518
  }
530
519
  }.freeze
531
520
 
532
- # Options that are available in a bolt.yaml file
533
- BOLT_OPTIONS = %w[
534
- apply-settings
535
- apply_settings
536
- color
521
+ # Options that are available on the command line
522
+ # This only includes options where users can provide arbitrary
523
+ # values from the command-line, allowing the validator to check them
524
+ CLI_OPTIONS = %w[
537
525
  compile-concurrency
538
526
  concurrency
539
527
  format
540
- hiera-config
541
- inventoryfile
542
528
  log
543
529
  modulepath
544
- plugin-hooks
545
- plugin_hooks
546
- plugins
547
- puppetdb
548
- puppetfile
549
- save-rerun
550
- spinner
551
- trusted-external-command
530
+ transport
552
531
  ].freeze
553
532
 
554
533
  # Options that are available in a bolt-defaults.yaml file
555
- BOLT_DEFAULTS_OPTIONS = %w[
534
+ DEFAULTS_OPTIONS = %w[
556
535
  color
557
536
  compile-concurrency
558
537
  concurrency
538
+ disable-warnings
559
539
  format
560
540
  inventory-config
561
541
  log
562
542
  module-install
563
543
  plugin-cache
564
544
  plugin-hooks
565
- plugin_hooks
566
545
  plugins
567
546
  puppetdb
568
- puppetfile
569
547
  save-rerun
570
548
  spinner
549
+ stream
571
550
  ].freeze
572
551
 
573
552
  # Options that are available in a bolt-project.yaml file
574
- BOLT_PROJECT_OPTIONS = %w[
553
+ PROJECT_OPTIONS = %w[
575
554
  apply-settings
576
- apply_settings
577
555
  color
578
556
  compile-concurrency
579
557
  concurrency
558
+ disable-warnings
580
559
  format
581
560
  hiera-config
582
- inventoryfile
583
561
  log
584
562
  modulepath
585
563
  module-install
@@ -588,12 +566,11 @@ module Bolt
588
566
  plans
589
567
  plugin-cache
590
568
  plugin-hooks
591
- plugin_hooks
592
569
  plugins
593
570
  puppetdb
594
- puppetfile
595
571
  save-rerun
596
572
  spinner
573
+ stream
597
574
  tasks
598
575
  trusted-external-command
599
576
  ].freeze
@@ -17,6 +17,7 @@ module Bolt
17
17
  OPTIONS = WINDOWS_OPTIONS.dup.concat(RUN_AS_OPTIONS).sort.freeze
18
18
 
19
19
  DEFAULTS = {
20
+ 'bundled-ruby' => true,
20
21
  'cleanup' => true
21
22
  }.freeze
22
23
 
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bolt/error'
4
+ require 'bolt/config/transport/base'
5
+
6
+ module Bolt
7
+ class Config
8
+ module Transport
9
+ class LXD < Base
10
+ OPTIONS = %w[
11
+ cleanup
12
+ tmpdir
13
+ ].freeze
14
+
15
+ DEFAULTS = {
16
+ 'cleanup' => true
17
+ }.freeze
18
+ end
19
+ end
20
+ end
21
+ end
@@ -21,7 +21,7 @@ module Bolt
21
21
  type: [TrueClass, FalseClass],
22
22
  _plugin: false,
23
23
  _example: true,
24
- _default: false
24
+ _default: true
25
25
  },
26
26
  "cacert" => {
27
27
  type: String,
@@ -32,7 +32,7 @@ module Bolt
32
32
  "cleanup" => {
33
33
  type: [TrueClass, FalseClass],
34
34
  description: "Whether to clean up temporary files created on targets. When running commands on a target, "\
35
- "Bolt may create temporary files. After completing the command, these files are "\
35
+ "Bolt might create temporary files. After completing the command, these files are "\
36
36
  "automatically deleted. This value can be set to 'false' if you wish to leave these "\
37
37
  "temporary files on the target.",
38
38
  _plugin: true,
@@ -253,6 +253,13 @@ module Bolt
253
253
  _plugin: true,
254
254
  _example: "jump.example.com"
255
255
  },
256
+ "read-timeout" => {
257
+ type: Integer,
258
+ description: "How long to wait in seconds when making requests to the Orchestrator.",
259
+ minimum: 1,
260
+ _plugin: true,
261
+ _example: 15
262
+ },
256
263
  "realm" => {
257
264
  type: String,
258
265
  description: "The Kerberos realm (Active Directory domain) to authenticate against.",
@@ -12,6 +12,7 @@ module Bolt
12
12
  host
13
13
  job-poll-interval
14
14
  job-poll-timeout
15
+ read-timeout
15
16
  service-url
16
17
  task-environment
17
18
  token-file
data/lib/bolt/executor.rb CHANGED
@@ -4,6 +4,7 @@
4
4
  require 'English'
5
5
  require 'json'
6
6
  require 'logging'
7
+ require 'pathname'
7
8
  require 'set'
8
9
  require 'bolt/analytics'
9
10
  require 'bolt/result'
@@ -15,6 +16,7 @@ require 'bolt/transport/ssh'
15
16
  require 'bolt/transport/winrm'
16
17
  require 'bolt/transport/orch'
17
18
  require 'bolt/transport/local'
19
+ require 'bolt/transport/lxd'
18
20
  require 'bolt/transport/docker'
19
21
  require 'bolt/transport/remote'
20
22
  require 'bolt/yarn'
@@ -25,6 +27,7 @@ module Bolt
25
27
  winrm: Bolt::Transport::WinRM,
26
28
  pcp: Bolt::Transport::Orch,
27
29
  local: Bolt::Transport::Local,
30
+ lxd: Bolt::Transport::LXD,
28
31
  docker: Bolt::Transport::Docker,
29
32
  remote: Bolt::Transport::Remote
30
33
  }.freeze
@@ -39,7 +42,6 @@ module Bolt
39
42
  modified_concurrency = false)
40
43
  # lazy-load expensive gem code
41
44
  require 'concurrent'
42
-
43
45
  @analytics = analytics
44
46
  @logger = Bolt::Logger.logger(self)
45
47
 
@@ -100,6 +102,8 @@ module Bolt
100
102
  # that type of event, publish the event
101
103
  next unless types.nil? || types.include?(event[:type])
102
104
  @publisher.post(subscriber) do |sub|
105
+ # Wait for user to input to prompt before printing anything
106
+ sleep(0.1) while @prompting
103
107
  sub.handle_event(event)
104
108
  end
105
109
  end
@@ -119,11 +123,12 @@ module Bolt
119
123
  def queue_execute(targets)
120
124
  if @warn_concurrency && targets.length > @concurrency
121
125
  @warn_concurrency = false
122
- @logger.warn("The ulimit is low, which may cause file limit issues. Default concurrency has been set to "\
123
- "'#{@concurrency}' to mitigate those issues, which may cause Bolt to run slow. "\
124
- "Disable this warning by configuring ulimit using 'ulimit -n <limit>' in your shell "\
125
- "configuration, or by configuring Bolt's concurrency. "\
126
- "See https://puppet.com/docs/bolt/latest/bolt_known_issues.html for details.")
126
+ msg = "The ulimit is low, which might cause file limit issues. Default concurrency has been set to "\
127
+ "'#{@concurrency}' to mitigate those issues, which might cause Bolt to run slow. "\
128
+ "Disable this warning by configuring ulimit using 'ulimit -n <limit>' in your shell "\
129
+ "configuration, or by configuring Bolt's concurrency. "\
130
+ "See https://puppet.com/docs/bolt/latest/bolt_known_issues.html for details."
131
+ Bolt::Logger.warn("low_ulimit", msg)
127
132
  end
128
133
 
129
134
  targets.group_by(&:transport).flat_map do |protocol, protocol_targets|
@@ -228,6 +233,11 @@ module Bolt
228
233
  @analytics.report_bundled_content(mode, name)
229
234
  end
230
235
 
236
+ def report_file_source(plan_function, source)
237
+ label = Pathname.new(source).absolute? ? 'absolute' : 'module'
238
+ @analytics&.event('Plan', plan_function, label: label)
239
+ end
240
+
231
241
  def report_apply(statement_count, resource_counts)
232
242
  data = { statement_count: statement_count }
233
243
 
@@ -258,7 +268,9 @@ module Bolt
258
268
 
259
269
  def with_node_logging(description, batch, log_level = :info)
260
270
  @logger.send(log_level, "#{description} on #{batch.map(&:safe_name)}")
271
+ publish_event(type: :start_spin)
261
272
  result = yield
273
+ publish_event(type: :stop_spin)
262
274
  @logger.send(log_level, result.to_json)
263
275
  result
264
276
  end
@@ -410,6 +422,7 @@ module Bolt
410
422
  subscribe(self, [:node_result])
411
423
  results = Array.new(skein.length)
412
424
  @in_parallel = true
425
+ publish_event(type: :stop_spin)
413
426
 
414
427
  until skein.empty?
415
428
  @thread_completed = false
@@ -417,6 +430,7 @@ module Bolt
417
430
 
418
431
  skein.each do |yarn|
419
432
  if yarn.alive?
433
+ publish_event(type: :stop_spin)
420
434
  r = yarn.resume
421
435
  else
422
436
  results[yarn.index] = yarn.value
@@ -428,6 +442,7 @@ module Bolt
428
442
  sleep(0.1) until @thread_completed || skein.empty?
429
443
  end
430
444
 
445
+ publish_event(type: :stop_spin)
431
446
  @in_parallel = false
432
447
  unsubscribe(self, [:node_result])
433
448
  results
@@ -469,6 +484,7 @@ module Bolt
469
484
  end
470
485
 
471
486
  def prompt(prompt, options)
487
+ @prompting = true
472
488
  unless $stdin.tty?
473
489
  raise Bolt::Error.new('STDIN is not a tty, unable to prompt', 'bolt/no-tty-error')
474
490
  end
@@ -480,6 +496,7 @@ module Bolt
480
496
  else
481
497
  $stdin.gets.to_s.chomp
482
498
  end
499
+ @prompting = false
483
500
 
484
501
  $stderr.puts if options[:sensitive]
485
502