bolt 3.11.0 → 3.15.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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +2 -2
  3. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +137 -104
  4. data/bolt-modules/boltlib/lib/puppet/functions/background.rb +2 -1
  5. data/bolt-modules/boltlib/lib/puppet/functions/parallelize.rb +5 -1
  6. data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +13 -0
  7. data/bolt-modules/boltlib/lib/puppet/functions/wait.rb +47 -7
  8. data/bolt-modules/log/lib/puppet/functions/log/debug.rb +39 -0
  9. data/bolt-modules/log/lib/puppet/functions/log/error.rb +40 -0
  10. data/bolt-modules/log/lib/puppet/functions/log/fatal.rb +40 -0
  11. data/bolt-modules/log/lib/puppet/functions/log/info.rb +39 -0
  12. data/bolt-modules/log/lib/puppet/functions/log/trace.rb +39 -0
  13. data/bolt-modules/log/lib/puppet/functions/log/warn.rb +41 -0
  14. data/bolt-modules/out/lib/puppet/functions/out/message.rb +9 -49
  15. data/bolt-modules/out/lib/puppet/functions/out/verbose.rb +35 -0
  16. data/guides/{debugging.txt → debugging.yaml} +5 -6
  17. data/guides/{inventory.txt → inventory.yaml} +6 -7
  18. data/guides/{links.txt → links.yaml} +3 -4
  19. data/guides/{logging.txt → logging.yaml} +5 -6
  20. data/guides/{module.txt → module.yaml} +5 -6
  21. data/guides/{modulepath.txt → modulepath.yaml} +5 -6
  22. data/guides/{project.txt → project.yaml} +6 -7
  23. data/guides/{targets.txt → targets.yaml} +5 -6
  24. data/guides/{transports.txt → transports.yaml} +6 -7
  25. data/lib/bolt/analytics.rb +1 -1
  26. data/lib/bolt/applicator.rb +23 -1
  27. data/lib/bolt/bolt_option_parser.rb +6 -3
  28. data/lib/bolt/cli.rb +34 -14
  29. data/lib/bolt/config/options.rb +2 -2
  30. data/lib/bolt/config/transport/options.rb +12 -0
  31. data/lib/bolt/config/transport/ssh.rb +7 -0
  32. data/lib/bolt/error.rb +3 -3
  33. data/lib/bolt/executor.rb +12 -4
  34. data/lib/bolt/fiber_executor.rb +57 -12
  35. data/lib/bolt/outputter/human.rb +124 -15
  36. data/lib/bolt/outputter/json.rb +5 -5
  37. data/lib/bolt/outputter/logger.rb +6 -0
  38. data/lib/bolt/pal.rb +81 -21
  39. data/lib/bolt/pal/yaml_plan/step.rb +2 -0
  40. data/lib/bolt/pal/yaml_plan/step/message.rb +0 -8
  41. data/lib/bolt/pal/yaml_plan/step/verbose.rb +31 -0
  42. data/lib/bolt/pal/yaml_plan/transpiler.rb +1 -1
  43. data/lib/bolt/plan_future.rb +21 -6
  44. data/lib/bolt/plugin/task.rb +1 -1
  45. data/lib/bolt/transport/ssh/exec_connection.rb +3 -1
  46. data/lib/bolt/util/format.rb +68 -0
  47. data/lib/bolt/version.rb +1 -1
  48. data/lib/bolt_server/schemas/connect-data.json +4 -1
  49. data/lib/bolt_server/schemas/partials/target-ssh.json +4 -0
  50. data/lib/bolt_server/schemas/partials/target-winrm.json +4 -0
  51. data/lib/bolt_server/transport_app.rb +93 -52
  52. data/lib/bolt_spec/bolt_context.rb +9 -0
  53. data/lib/bolt_spec/plans.rb +1 -1
  54. data/lib/bolt_spec/plans/mock_executor.rb +31 -7
  55. data/lib/bolt_spec/plans/publish_stub.rb +4 -4
  56. data/modules/canary/plans/init.pp +1 -1
  57. data/resources/bolt_bash_completion.sh +1 -1
  58. metadata +28 -14
  59. data/guides/guide.txt +0 -17
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bolt/util/format'
4
+
5
+ # Log a debugging message.
6
+ #
7
+ # Messages logged at this level typically include detailed information about
8
+ # what a plan is doing. For example, you might log a message at the `debug`
9
+ # level that shows what value is returned from a function invocation.
10
+ #
11
+ # See [Logs](logs.md) for more information about Bolt's log levels.
12
+ #
13
+ # > **Note:** Not available in apply block
14
+ Puppet::Functions.create_function(:'log::debug') do
15
+ # Log a debugging message.
16
+ # @param message The message to log.
17
+ # @example Log a debugging message
18
+ # log::debug("Function frogsay returned: ${result}")
19
+ dispatch :log_debug do
20
+ param 'Any', :message
21
+ return_type 'Undef'
22
+ end
23
+
24
+ def log_debug(message)
25
+ unless Puppet[:tasks]
26
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
27
+ Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
28
+ action: 'log::debug'
29
+ )
30
+ end
31
+
32
+ Puppet.lookup(:bolt_executor).tap do |executor|
33
+ executor.report_function_call(self.class.name)
34
+ executor.publish_event(type: :log, level: :debug, message: Bolt::Util::Format.stringify(message))
35
+ end
36
+
37
+ nil
38
+ end
39
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bolt/util/format'
4
+
5
+ # Log an error message.
6
+ #
7
+ # Messages logged at this level typically indicate that the plan encountered an
8
+ # error that can be recovered from. For example, you might log a message at the
9
+ # `error` level if you want to inform the user an action running on a target
10
+ # failed but that the plan will continue running.
11
+ #
12
+ # See [Logs](logs.md) for more information about Bolt's log levels.
13
+ #
14
+ # > **Note:** Not available in apply block
15
+ Puppet::Functions.create_function(:'log::error') do
16
+ # Log an error message.
17
+ # @param message The message to log.
18
+ # @example Log an error message
19
+ # log::error("The HTTP request returned an error, continuing the plan: ${result}")
20
+ dispatch :log_error do
21
+ param 'Any', :message
22
+ return_type 'Undef'
23
+ end
24
+
25
+ def log_error(message)
26
+ unless Puppet[:tasks]
27
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
28
+ Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
29
+ action: 'log::error'
30
+ )
31
+ end
32
+
33
+ Puppet.lookup(:bolt_executor).tap do |executor|
34
+ executor.report_function_call(self.class.name)
35
+ executor.publish_event(type: :log, level: :error, message: Bolt::Util::Format.stringify(message))
36
+ end
37
+
38
+ nil
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bolt/util/format'
4
+
5
+ # Log a fatal message.
6
+ #
7
+ # Messages logged at this level indicate that the plan encountered an error that
8
+ # could not be recovered from. For example, you might log a message at the
9
+ # `fatal` level if a service is unavailable and the plan cannot continue running
10
+ # without it.
11
+ #
12
+ # See [Logs](logs.md) for more information about Bolt's log levels.
13
+ #
14
+ # > **Note:** Not available in apply block
15
+ Puppet::Functions.create_function(:'log::fatal') do
16
+ # Log a fatal message.
17
+ # @param message The message to log.
18
+ # @example Log a fatal message
19
+ # log::fatal("The service is unavailable, unable to continue running: ${result}")
20
+ dispatch :log_fatal do
21
+ param 'Any', :message
22
+ return_type 'Undef'
23
+ end
24
+
25
+ def log_fatal(message)
26
+ unless Puppet[:tasks]
27
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
28
+ Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
29
+ action: 'log::fatal'
30
+ )
31
+ end
32
+
33
+ Puppet.lookup(:bolt_executor).tap do |executor|
34
+ executor.report_function_call(self.class.name)
35
+ executor.publish_event(type: :log, level: :fatal, message: Bolt::Util::Format.stringify(message))
36
+ end
37
+
38
+ nil
39
+ end
40
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bolt/util/format'
4
+
5
+ # Log an info message.
6
+ #
7
+ # Messages logged at this level typically include high-level information about
8
+ # what a plan is doing. For example, you might log a message at the `info` level
9
+ # that informs users that the plan is reading a file on disk.
10
+ #
11
+ # See [Logs](logs.md) for more information about Bolt's log levels.
12
+ #
13
+ # > **Note:** Not available in apply block
14
+ Puppet::Functions.create_function(:'log::info') do
15
+ # Log an info message.
16
+ # @param message The message to log.
17
+ # @example Log an info message
18
+ # log::info("Reading network device command file ${file}.")
19
+ dispatch :log_info do
20
+ param 'Any', :message
21
+ return_type 'Undef'
22
+ end
23
+
24
+ def log_info(message)
25
+ unless Puppet[:tasks]
26
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
27
+ Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
28
+ action: 'log::info'
29
+ )
30
+ end
31
+
32
+ Puppet.lookup(:bolt_executor).tap do |executor|
33
+ executor.report_function_call(self.class.name)
34
+ executor.publish_event(type: :log, level: :info, message: Bolt::Util::Format.stringify(message))
35
+ end
36
+
37
+ nil
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bolt/util/format'
4
+
5
+ # Log a trace message.
6
+ #
7
+ # Messages logged at this level typically include the most detailed information
8
+ # about what a plan is doing. For example, you might log a message at the `trace`
9
+ # level that describes how a plan is manipulating data.
10
+ #
11
+ # See [Logs](logs.md) for more information about Bolt's log levels.
12
+ #
13
+ # > **Note:** Not available in apply block
14
+ Puppet::Functions.create_function(:'log::trace') do
15
+ # Log a trace message.
16
+ # @param message The message to log.
17
+ # @example Log a trace message
18
+ # log::trace("Creating Target object with data ${data} from file ${file}")
19
+ dispatch :log_trace do
20
+ param 'Any', :message
21
+ return_type 'Undef'
22
+ end
23
+
24
+ def log_trace(message)
25
+ unless Puppet[:tasks]
26
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
27
+ Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
28
+ action: 'log::trace'
29
+ )
30
+ end
31
+
32
+ Puppet.lookup(:bolt_executor).tap do |executor|
33
+ executor.report_function_call(self.class.name)
34
+ executor.publish_event(type: :log, level: :trace, message: Bolt::Util::Format.stringify(message))
35
+ end
36
+
37
+ nil
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bolt/util/format'
4
+
5
+ # Log a warning message.
6
+ #
7
+ # Messages logged at this level typically include messages about deprecated
8
+ # behavior or potentially harmful situations that might affect the plan run.
9
+ # For example, you might log a message at the `warn` level if you are
10
+ # planning to make a breaking change to your plan in a future release and
11
+ # want to notify users.
12
+ #
13
+ # See [Logs](logs.md) for more information about Bolt's log levels.
14
+ #
15
+ # > **Note:** Not available in apply block
16
+ Puppet::Functions.create_function(:'log::warn') do
17
+ # Log a warning message.
18
+ # @param message The message to log.
19
+ # @example Log a warning message
20
+ # log::warn('This plan will no longer install the package in a future release.')
21
+ dispatch :log_warn do
22
+ param 'Any', :message
23
+ return_type 'Undef'
24
+ end
25
+
26
+ def log_warn(message)
27
+ unless Puppet[:tasks]
28
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
29
+ Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
30
+ action: 'log::warn'
31
+ )
32
+ end
33
+
34
+ Puppet.lookup(:bolt_executor).tap do |executor|
35
+ executor.report_function_call(self.class.name)
36
+ executor.publish_event(type: :log, level: :warn, message: Bolt::Util::Format.stringify(message))
37
+ end
38
+
39
+ nil
40
+ end
41
+ end
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'bolt/util/format'
4
+
3
5
  # Output a message for the user.
4
6
  #
5
7
  # This will print a message to stdout when using the human output format,
6
- # and print to stderr when using the json output format
8
+ # and print to stderr when using the json output format. Messages are
9
+ # also logged at the `info` level. For more information about logs, see
10
+ # [Logs](logs.md).
7
11
  #
8
12
  # > **Note:** Not available in apply block
9
13
  Puppet::Functions.create_function(:'out::message') do
@@ -22,55 +26,11 @@ Puppet::Functions.create_function(:'out::message') do
22
26
  .from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, action: 'out::message')
23
27
  end
24
28
 
25
- executor = Puppet.lookup(:bolt_executor)
26
- # Send Analytics Report
27
- executor.report_function_call(self.class.name)
28
-
29
- executor.publish_event(type: :message, message: stringify(message))
30
-
31
- nil
32
- end
33
-
34
- def stringify(message)
35
- formatted = format_message(message)
36
- if formatted.is_a?(Hash) || formatted.is_a?(Array)
37
- ::JSON.pretty_generate(formatted)
38
- else
39
- formatted
40
- end
41
- end
42
-
43
- def format_message(message)
44
- case message
45
- when Array
46
- message.map { |item| format_message(item) }
47
- when Bolt::ApplyResult
48
- format_apply_result(message)
49
- when Bolt::Result, Bolt::ResultSet
50
- # This is equivalent to to_s, but formattable
51
- message.to_data
52
- when Bolt::RunFailure
53
- formatted_resultset = message.result_set.to_data
54
- message.to_h.merge('result_set' => formatted_resultset)
55
- when Hash
56
- message.each_with_object({}) do |(k, v), h|
57
- h[format_message(k)] = format_message(v)
58
- end
59
- when Integer, Float, NilClass
60
- message
61
- else
62
- message.to_s
29
+ Puppet.lookup(:bolt_executor).tap do |executor|
30
+ executor.report_function_call(self.class.name)
31
+ executor.publish_event(type: :message, message: Bolt::Util::Format.stringify(message), level: :info)
63
32
  end
64
- end
65
33
 
66
- def format_apply_result(result)
67
- logs = result.resource_logs&.map do |log|
68
- # Omit low-level info/debug messages
69
- next if %w[info debug].include?(log['level'])
70
- indent(2, format_log(log))
71
- end
72
- hash = result.to_data
73
- hash['logs'] = logs unless logs.empty?
74
- hash
34
+ nil
75
35
  end
76
36
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bolt/util/format'
4
+
5
+ # Output a message for the user when running in verbose mode.
6
+ #
7
+ # This will print a message to stdout when using the human output format,
8
+ # and print to stderr when using the json output format. Messages are
9
+ # also logged at the `debug` level. For more information about logs, see
10
+ # [Logs](logs.md).
11
+ #
12
+ # > **Note:** Not available in apply block
13
+ Puppet::Functions.create_function(:'out::verbose') do
14
+ # @param message The message to output.
15
+ # @example Print a message
16
+ # out::verbose('Something went wrong')
17
+ dispatch :output_verbose do
18
+ param 'Any', :message
19
+ return_type 'Undef'
20
+ end
21
+
22
+ def output_verbose(message)
23
+ unless Puppet[:tasks]
24
+ raise Puppet::ParseErrorWithIssue
25
+ .from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, action: 'out::verbose')
26
+ end
27
+
28
+ Puppet.lookup(:bolt_executor).tap do |executor|
29
+ executor.report_function_call(self.class.name)
30
+ executor.publish_event(type: :verbose, message: Bolt::Util::Format.stringify(message), level: :debug)
31
+ end
32
+
33
+ nil
34
+ end
35
+ end
@@ -1,7 +1,6 @@
1
- TOPIC
2
- debugging
3
-
4
- DESCRIPTION
1
+ ---
2
+ topic: debugging
3
+ guide: |
5
4
  When Bolt isn't behaving as expected, there are a few helpful commands and
6
5
  logs that can help identify common issues. The first place to look is in
7
6
  `<PROJECT>/bolt-debug.log`, which contains debug-level logs from the last Bolt
@@ -24,5 +23,5 @@ DESCRIPTION
24
23
  Visit the linked documentation for more in-depth troubleshooting help for
25
24
  specific issues.
26
25
 
27
- DOCUMENTATION
28
- https://pup.pt/bolt-troubleshooting
26
+ documentation:
27
+ - https://pup.pt/bolt-troubleshooting
@@ -1,7 +1,6 @@
1
- TOPIC
2
- inventory
3
-
4
- DESCRIPTION
1
+ ---
2
+ topic: inventory
3
+ guide: |
5
4
  The inventory describes the targets that you run Bolt commands on, along
6
5
  with any data and configuration for the targets. Targets in an inventory can
7
6
  belong to one or more groups, allowing you to share data and configuration
@@ -19,6 +18,6 @@ DESCRIPTION
19
18
  target in multiple groups, this might result in target configuration that
20
19
  is different than expected.
21
20
 
22
- DOCUMENTATION
23
- https://pup.pt/bolt-inventory
24
- https://pup.pt/bolt-inventory-reference
21
+ documentation:
22
+ - https://pup.pt/bolt-inventory
23
+ - https://pup.pt/bolt-inventory-reference
@@ -1,7 +1,6 @@
1
- TOPIC
2
- links
3
-
4
- DESCRIPTION
1
+ ---
2
+ topic: links
3
+ guide: |
5
4
  Bolt documentation https://bolt.guide
6
5
  Ask a question in #bolt https://slack.puppet.com/
7
6
  Contribute at https://github.com/puppetlabs/bolt/
@@ -1,7 +1,6 @@
1
- TOPIC
2
- logging
3
-
4
- DESCRIPTION
1
+ ---
2
+ topic: logging
3
+ guide: |
5
4
  Bolt prints messages both to the console and to log files. Messages can
6
5
  either come from Bolt's 'outputter', which logs user-facing messages like
7
6
  progress and results, or from the 'logger', which logs warnings, errors, and
@@ -14,5 +13,5 @@ DESCRIPTION
14
13
 
15
14
  To learn more about projects, see the 'project' guide.
16
15
 
17
- DOCUMENTATION
18
- https://pup.pt/bolt-logging
16
+ documentation:
17
+ - https://pup.pt/bolt-logging
@@ -1,7 +1,6 @@
1
- TOPIC
2
- module
3
-
4
- DESCRIPTION
1
+ ---
2
+ topic: module
3
+ guide: |
5
4
  Modules are shareable, reusable packages of Puppet content. They can include
6
5
  tasks, plans, functions, and other types of content that you can use in your
7
6
  project. You can download and install modules to your project from the
@@ -15,5 +14,5 @@ DESCRIPTION
15
14
  To learn more about managing modules in a project, see the documentation.
16
15
  To learn how modules are loaded by Bolt, see the 'modulepath' guide.
17
16
 
18
- DOCUMENTATION
19
- https://pup.pt/bolt-modules
17
+ documentation:
18
+ - https://pup.pt/bolt-modules