bolt 2.28.0 → 2.33.1

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +15 -14
  3. data/bolt-modules/boltlib/lib/puppet/functions/download_file.rb +1 -1
  4. data/bolt-modules/boltlib/lib/puppet/functions/facts.rb +6 -0
  5. data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb +2 -2
  6. data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +1 -1
  7. data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +1 -1
  8. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +1 -1
  9. data/bolt-modules/boltlib/lib/puppet/functions/run_task_with.rb +1 -1
  10. data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -1
  11. data/bolt-modules/boltlib/lib/puppet/functions/write_file.rb +2 -2
  12. data/bolt-modules/out/lib/puppet/functions/out/message.rb +44 -1
  13. data/bolt-modules/prompt/lib/puppet/functions/prompt.rb +3 -0
  14. data/guides/logging.txt +18 -0
  15. data/guides/module.txt +19 -0
  16. data/guides/modulepath.txt +25 -0
  17. data/lib/bolt/bolt_option_parser.rb +50 -28
  18. data/lib/bolt/catalog.rb +1 -1
  19. data/lib/bolt/cli.rb +159 -112
  20. data/lib/bolt/config.rb +13 -1
  21. data/lib/bolt/config/modulepath.rb +30 -0
  22. data/lib/bolt/config/options.rb +38 -9
  23. data/lib/bolt/config/transport/options.rb +2 -2
  24. data/lib/bolt/error.rb +4 -0
  25. data/lib/bolt/executor.rb +13 -13
  26. data/lib/bolt/inventory.rb +10 -9
  27. data/lib/bolt/logger.rb +26 -19
  28. data/lib/bolt/module_installer.rb +198 -0
  29. data/lib/bolt/{puppetfile → module_installer}/installer.rb +3 -2
  30. data/lib/bolt/module_installer/puppetfile.rb +117 -0
  31. data/lib/bolt/module_installer/puppetfile/forge_module.rb +54 -0
  32. data/lib/bolt/module_installer/puppetfile/git_module.rb +37 -0
  33. data/lib/bolt/module_installer/puppetfile/module.rb +26 -0
  34. data/lib/bolt/module_installer/resolver.rb +76 -0
  35. data/lib/bolt/module_installer/specs.rb +93 -0
  36. data/lib/bolt/module_installer/specs/forge_spec.rb +84 -0
  37. data/lib/bolt/module_installer/specs/git_spec.rb +178 -0
  38. data/lib/bolt/outputter.rb +2 -45
  39. data/lib/bolt/outputter/human.rb +78 -18
  40. data/lib/bolt/outputter/json.rb +22 -7
  41. data/lib/bolt/outputter/logger.rb +2 -2
  42. data/lib/bolt/pal.rb +55 -45
  43. data/lib/bolt/pal/yaml_plan.rb +4 -2
  44. data/lib/bolt/pal/yaml_plan/evaluator.rb +23 -1
  45. data/lib/bolt/pal/yaml_plan/loader.rb +14 -9
  46. data/lib/bolt/plugin.rb +1 -1
  47. data/lib/bolt/plugin/module.rb +1 -1
  48. data/lib/bolt/project.rb +32 -22
  49. data/lib/bolt/project_migrator.rb +80 -0
  50. data/lib/bolt/project_migrator/base.rb +39 -0
  51. data/lib/bolt/project_migrator/config.rb +67 -0
  52. data/lib/bolt/project_migrator/inventory.rb +67 -0
  53. data/lib/bolt/project_migrator/modules.rb +200 -0
  54. data/lib/bolt/result.rb +23 -11
  55. data/lib/bolt/shell/bash.rb +15 -9
  56. data/lib/bolt/shell/powershell.rb +11 -6
  57. data/lib/bolt/transport/base.rb +18 -18
  58. data/lib/bolt/transport/docker.rb +23 -6
  59. data/lib/bolt/transport/orch.rb +23 -14
  60. data/lib/bolt/transport/remote.rb +2 -2
  61. data/lib/bolt/transport/simple.rb +6 -6
  62. data/lib/bolt/transport/ssh/connection.rb +1 -1
  63. data/lib/bolt/util.rb +41 -0
  64. data/lib/bolt/version.rb +1 -1
  65. data/lib/bolt_server/acl.rb +2 -2
  66. data/lib/bolt_server/base_config.rb +3 -3
  67. data/lib/bolt_server/schemas/partials/task.json +17 -2
  68. data/lib/bolt_server/transport_app.rb +93 -13
  69. data/lib/bolt_spec/bolt_context.rb +4 -2
  70. data/lib/bolt_spec/plans.rb +1 -1
  71. data/lib/bolt_spec/plans/action_stubs/command_stub.rb +1 -1
  72. data/lib/bolt_spec/plans/action_stubs/script_stub.rb +1 -1
  73. data/lib/bolt_spec/plans/mock_executor.rb +6 -6
  74. data/lib/bolt_spec/run.rb +1 -1
  75. metadata +31 -12
  76. data/lib/bolt/project_migrate.rb +0 -138
  77. data/lib/bolt/puppetfile.rb +0 -160
  78. data/lib/bolt/puppetfile/module.rb +0 -66
  79. data/lib/bolt_server/pe/pal.rb +0 -67
  80. data/modules/secure_env_vars/plans/init.pp +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03de2a7e4d6fa0b9d4120fff783ccb009665077c7b00e910f5e2de14c03a1767
4
- data.tar.gz: 511e18c31228338f47519ee02a7b248f4d264b93516a58aa1b063a41bb835e80
3
+ metadata.gz: cf27b6c8b1a7e3cfb2eb61617bd7ab4927161c577df4915d959182fd8bce7eaf
4
+ data.tar.gz: '05578a39ce18d1d63bf9455c8890e1e328bdcb3f52dacc3d6d5047251bca833e'
5
5
  SHA512:
6
- metadata.gz: 1956edc3051eae34d25957c7827ce1e1f12bfc7e322d9305a79d9a2cb32cf144309413626cfb9db6667193a8853810dabf8d6004924ad3899633a220f34cecb7
7
- data.tar.gz: af2e40875cb54c1e2b4153605ffc6abb6b11a65e2f0abcc30f7eb87701cb3c5c023905dc1709ff0bf7261e856ceaae29fad9df13e4b9b51b9f74a4ef65fb0b74
6
+ metadata.gz: 11b3fad81f576fa435b570b15ee7cbab14b7c099b4b179770eb20dbc7f2a2db9b2d2de6c4a52eb09021a9794d13c4da704eb3a2ed362cfd50ab1946e7ef5998d
7
+ data.tar.gz: 300b9fa2214a66d239218b7a8c12518a97c2cf2fafd401c860a3ff9cdd439355608b30d72d5a82f157eea842a25a7c5bc9d484dd9f616837ebfe4beff26c0795
data/Puppetfile CHANGED
@@ -6,35 +6,37 @@ moduledir File.join(File.dirname(__FILE__), 'modules')
6
6
 
7
7
  # Core modules used by 'apply'
8
8
  mod 'puppetlabs-service', '1.3.0'
9
- mod 'puppetlabs-puppet_agent', '4.1.1'
10
- mod 'puppetlabs-facts', '1.0.0'
9
+ mod 'puppetlabs-puppet_agent', '4.2.0'
10
+ mod 'puppetlabs-facts', '1.1.0'
11
11
 
12
12
  # Core types and providers for Puppet 6
13
- mod 'puppetlabs-augeas_core', '1.0.5'
13
+ mod 'puppetlabs-augeas_core', '1.1.1'
14
14
  mod 'puppetlabs-host_core', '1.0.3'
15
- mod 'puppetlabs-scheduled_task', '2.0.1'
16
- mod 'puppetlabs-sshkeys_core', '1.0.3'
17
- mod 'puppetlabs-zfs_core', '1.0.4'
18
- mod 'puppetlabs-cron_core', '1.0.3'
15
+ mod 'puppetlabs-scheduled_task', '2.2.1'
16
+ mod 'puppetlabs-sshkeys_core', '2.2.0'
17
+ mod 'puppetlabs-zfs_core', '1.2.0'
18
+ mod 'puppetlabs-cron_core', '1.0.5'
19
19
  mod 'puppetlabs-mount_core', '1.0.4'
20
20
  mod 'puppetlabs-selinux_core', '1.0.4'
21
- mod 'puppetlabs-yumrepo_core', '1.0.6'
21
+ mod 'puppetlabs-yumrepo_core', '1.0.7'
22
22
  mod 'puppetlabs-zone_core', '1.0.3'
23
23
 
24
24
  # Useful additional modules
25
- mod 'puppetlabs-package', '1.1.0'
25
+ mod 'puppetlabs-package', '1.3.0'
26
26
  mod 'puppetlabs-puppet_conf', '0.6.0'
27
27
  mod 'puppetlabs-python_task_helper', '0.4.3'
28
28
  mod 'puppetlabs-reboot', '3.0.0'
29
29
  mod 'puppetlabs-ruby_task_helper', '0.5.1'
30
30
  mod 'puppetlabs-ruby_plugin_helper', '0.1.0'
31
- mod 'puppetlabs-stdlib', '6.3.0'
31
+ mod 'puppetlabs-stdlib', '6.5.0'
32
32
 
33
33
  # Plugin modules
34
- mod 'puppetlabs-aws_inventory', '0.5.0'
35
- mod 'puppetlabs-azure_inventory', '0.3.0'
36
- mod 'puppetlabs-gcloud_inventory', '0.1.1'
34
+ mod 'puppetlabs-aws_inventory', '0.5.2'
35
+ mod 'puppetlabs-azure_inventory', '0.4.1'
36
+ mod 'puppetlabs-gcloud_inventory', '0.1.3'
37
+ mod 'puppetlabs-http_request', '0.2.0'
37
38
  mod 'puppetlabs-pkcs7', '0.1.1'
39
+ mod 'puppetlabs-secure_env_vars', '0.1.0'
38
40
  mod 'puppetlabs-terraform', '0.5.0'
39
41
  mod 'puppetlabs-vault', '0.3.0'
40
42
  mod 'puppetlabs-yaml', '0.2.0'
@@ -43,4 +45,3 @@ mod 'puppetlabs-yaml', '0.2.0'
43
45
  mod 'canary', local: true
44
46
  mod 'aggregate', local: true
45
47
  mod 'puppetdb_fact', local: true
46
- mod 'secure_env_vars', local: true
@@ -112,7 +112,7 @@ Puppet::Functions.create_function(:download_file, Puppet::Functions::InternalFun
112
112
  call_function('debug', "Simulating file download of '#{source}' - no targets given - no action taken")
113
113
  r = Bolt::ResultSet.new([])
114
114
  else
115
- r = executor.download_file(targets, source, destination, options)
115
+ r = executor.download_file(targets, source, destination, options, Puppet::Pops::PuppetStack.top_of_stack)
116
116
  end
117
117
 
118
118
  if !r.ok && !options[:catch_errors]
@@ -3,6 +3,12 @@
3
3
  require 'bolt/error'
4
4
 
5
5
  # Returns the facts hash for a target.
6
+ #
7
+ # Using the `facts` function does not automatically collect facts for a target,
8
+ # and will only return facts that are currently set in the inventory. To collect
9
+ # facts from a target and set them in the inventory, run the
10
+ # [facts](writing_plans.md#collect-facts-from-targets) plan or
11
+ # [puppetdb_fact](writing_plans.md#collect-facts-from-puppetdb) plan.
6
12
  Puppet::Functions.create_function(:facts) do
7
13
  # @param target A target.
8
14
  # @return The target's facts.
@@ -2,12 +2,12 @@
2
2
 
3
3
  require 'bolt/error'
4
4
 
5
- # Makes a query to {https://puppet.com/docs/puppetdb/latest/index.html puppetdb}
5
+ # Makes a query to [puppetdb](https://puppet.com/docs/puppetdb/latest/index.html)
6
6
  # using Bolt's PuppetDB client.
7
7
  Puppet::Functions.create_function(:puppetdb_query) do
8
8
  # rubocop:disable Layout/LineLength
9
9
  # @param query A PQL query.
10
- # {https://puppet.com/docs/puppetdb/latest/api/query/tutorial-pql.html Learn more about Puppet's query language, PQL}
10
+ # Learn more about [Puppet's query language](https://puppet.com/docs/puppetdb/latest/api/query/tutorial-pql.html), PQL.
11
11
  # @return Results of the PuppetDB query.
12
12
  # @example Request certnames for all nodes
13
13
  # puppetdb_query('nodes[certname] {}')
@@ -69,7 +69,7 @@ Puppet::Functions.create_function(:run_command) do
69
69
  call_function('debug', "Simulating run_command('#{command}') - no targets given - no action taken")
70
70
  r = Bolt::ResultSet.new([])
71
71
  else
72
- r = executor.run_command(targets, command, options)
72
+ r = executor.run_command(targets, command, options, Puppet::Pops::PuppetStack.top_of_stack)
73
73
  end
74
74
 
75
75
  if !r.ok && !options[:catch_errors]
@@ -87,7 +87,7 @@ Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFuncti
87
87
  r = if targets.empty?
88
88
  Bolt::ResultSet.new([])
89
89
  else
90
- executor.run_script(targets, found, arguments, options)
90
+ executor.run_script(targets, found, arguments, options, Puppet::Pops::PuppetStack.top_of_stack)
91
91
  end
92
92
 
93
93
  if !r.ok && !options[:catch_errors]
@@ -133,7 +133,7 @@ Puppet::Functions.create_function(:run_task) do
133
133
  if targets.empty?
134
134
  Bolt::ResultSet.new([])
135
135
  else
136
- result = executor.run_task(targets, task, params, options)
136
+ result = executor.run_task(targets, task, params, options, Puppet::Pops::PuppetStack.top_of_stack)
137
137
  if !result.ok && !options[:catch_errors]
138
138
  raise Bolt::RunFailure.new(result, 'run_task', task_name)
139
139
  end
@@ -180,7 +180,7 @@ Puppet::Functions.create_function(:run_task_with) do
180
180
  else
181
181
  # Combine the results from the task run with any failing results that were
182
182
  # generated earlier when creating the target mapping
183
- task_result = executor.run_task_with(target_mapping, task, options)
183
+ task_result = executor.run_task_with(target_mapping, task, options, Puppet::Pops::PuppetStack.top_of_stack)
184
184
  result = Bolt::ResultSet.new(task_result.results + error_set)
185
185
 
186
186
  if !result.ok && !options[:catch_errors]
@@ -83,7 +83,7 @@ Puppet::Functions.create_function(:upload_file, Puppet::Functions::InternalFunct
83
83
  call_function('debug', "Simulating file upload of '#{found}' - no targets given - no action taken")
84
84
  r = Bolt::ResultSet.new([])
85
85
  else
86
- r = executor.upload_file(targets, found, destination, options)
86
+ r = executor.upload_file(targets, found, destination, options, Puppet::Pops::PuppetStack.top_of_stack)
87
87
  end
88
88
 
89
89
  if !r.ok && !options[:catch_errors]
@@ -6,15 +6,15 @@ require 'tempfile'
6
6
  #
7
7
  # > **Note:** Not available in apply block
8
8
  Puppet::Functions.create_function(:write_file) do
9
- # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
10
9
  # @param content File content to write.
11
10
  # @param destination An absolute path on the target(s).
11
+ # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
12
12
  # @option options [Boolean] _catch_errors Whether to catch raised errors.
13
13
  # @option options [String] _run_as User to run as using privilege escalation.
14
14
  # @return A list of results, one entry per target.
15
15
  # @example Write a file to a target
16
16
  # $content = 'Hello, world!'
17
- # write_file($targets, $content, '/Users/me/hello.txt')
17
+ # write_file($content, '/Users/me/hello.txt', $targets)
18
18
  dispatch :write_file do
19
19
  required_param 'String', :content
20
20
  required_param 'String[1]', :destination
@@ -26,8 +26,51 @@ Puppet::Functions.create_function(:'out::message') do
26
26
  # Send Analytics Report
27
27
  executor.report_function_call(self.class.name)
28
28
 
29
- executor.publish_event(type: :message, message: message)
29
+ executor.publish_event(type: :message, message: stringify(message))
30
30
 
31
31
  nil
32
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
63
+ end
64
+ end
65
+
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
75
+ end
33
76
  end
@@ -9,11 +9,14 @@ Puppet::Functions.create_function(:prompt) do
9
9
  # @param prompt The prompt to display.
10
10
  # @param options A hash of additional options.
11
11
  # @option options [Boolean] sensitive Disable echo back and mark the response as sensitive.
12
+ # The returned value will be wrapped by the `Sensitive` data type. To access the raw
13
+ # value, use the `unwrap` function (i.e. `$sensitive_value.unwrap`).
12
14
  # @return The response to the prompt.
13
15
  # @example Prompt the user if plan execution should continue
14
16
  # $response = prompt('Continue executing plan? [Y\N]')
15
17
  # @example Prompt the user for sensitive information
16
18
  # $password = prompt('Enter your password', 'sensitive' => true)
19
+ # out::message("Password is: ${password.unwrap}")
17
20
  dispatch :prompt do
18
21
  param 'String', :prompt
19
22
  optional_param 'Hash[String[1], Any]', :options
@@ -0,0 +1,18 @@
1
+ TOPIC
2
+ logging
3
+
4
+ DESCRIPTION
5
+ Bolt prints messages both to the console and to log files. Messages can
6
+ either come from Bolt's 'outputter', which logs user-facing messages like
7
+ progress and results, or from the 'logger', which logs warnings, errors, and
8
+ log-structured output to log files. Both of these message streams are
9
+ configurable.
10
+
11
+ By default, Bolt logs to the console at 'warn' level and writes a log file to
12
+ '<project>/bolt-debug.log' at 'debug' level. Unless you are running a plan,
13
+ Bolt runs in verbose mode by default.
14
+
15
+ To learn more about projects, see the 'project' guide.
16
+
17
+ DOCUMENTATION
18
+ https://pup.pt/bolt-logging
@@ -0,0 +1,19 @@
1
+ TOPIC
2
+ module
3
+
4
+ DESCRIPTION
5
+ Modules are shareable, reusable packages of Puppet content. They can include
6
+ tasks, plans, functions, and other types of content that you can use in your
7
+ project. You can download and install modules to your project from the
8
+ Puppet Forge or write your own modules. Bolt also ships with several helpful
9
+ modules pre-installed that are available to all of your projects.
10
+
11
+ Bolt makes it easy to manage the modules that your project depends on. You
12
+ can use Bolt commands to install a project's modules, add new modules to a
13
+ project, and view the modules that are available to the project.
14
+
15
+ To learn more about managing modules in a project, see the documentation.
16
+ To learn how modules are loaded by Bolt, see the 'modulepath' guide.
17
+
18
+ DOCUMENTATION
19
+ https://pup.pt/bolt-modules
@@ -0,0 +1,25 @@
1
+ TOPIC
2
+ modulepath
3
+
4
+ DESCRIPTION
5
+ The modulepath is an ordered list of directories that Bolt loads modules
6
+ from. When Bolt runs a command, it automatically loads modules from the
7
+ modulepath.
8
+
9
+ While Bolt has a default modulepath, you can also configure your own
10
+ modulepath, which can include directories within the project or directories
11
+ elsewhere on your system. Regardless of whether your project uses a default
12
+ or configured modulepath, Bolt automatically adds directories to the
13
+ modulepath. This includes modules containing core Bolt content, which is
14
+ added to the beginning of the modulepath, and bundled content, which is
15
+ added to the end of the modulepath.
16
+
17
+ Modules loaded from a directory listed earlier in the modulepath take
18
+ precedence over modules with the same name loaded from a directory later in
19
+ the modulepath. Bolt will not warn or error when two modules share a name
20
+ and instead will ignore modules with a lower precedence.
21
+
22
+ To learn more about modules, see the 'module' guide.
23
+
24
+ DOCUMENTATION
25
+ https://pup.pt/bolt-project-reference#modulepath
@@ -66,15 +66,18 @@ module Bolt
66
66
  banner: GUIDE_HELP }
67
67
  when 'module'
68
68
  case action
69
+ when 'add'
70
+ { flags: OPTIONS[:global] + %w[configfile project],
71
+ banner: MODULE_ADD_HELP }
72
+ when 'generate-types'
73
+ { flags: OPTIONS[:global] + OPTIONS[:global_config_setters],
74
+ banner: MODULE_GENERATETYPES_HELP }
69
75
  when 'install'
70
- { flags: OPTIONS[:global] + %w[configfile force project],
76
+ { flags: OPTIONS[:global] + %w[configfile force project resolve],
71
77
  banner: MODULE_INSTALL_HELP }
72
78
  when 'show'
73
79
  { flags: OPTIONS[:global] + OPTIONS[:global_config_setters],
74
80
  banner: MODULE_SHOW_HELP }
75
- when 'generate-types'
76
- { flags: OPTIONS[:global] + OPTIONS[:global_config_setters],
77
- banner: MODULE_GENERATETYPES_HELP }
78
81
  else
79
82
  { flags: OPTIONS[:global],
80
83
  banner: MODULE_HELP }
@@ -184,6 +187,7 @@ module Bolt
184
187
  group Show the list of groups in the inventory
185
188
  guide View guides for Bolt concepts and features
186
189
  inventory Show the list of targets an action would run on
190
+ module Manage Bolt project modules
187
191
  plan Convert, create, show, and run Bolt plans
188
192
  project Create and migrate Bolt projects
189
193
  puppetfile Install and list modules and generate type references
@@ -364,27 +368,34 @@ module Bolt
364
368
  bolt module <action> [options]
365
369
 
366
370
  DESCRIPTION
367
- Install and list modules and generate type references
371
+ Manage Bolt project modules
372
+
373
+ The module command is only supported when a project is configured
374
+ with the 'modules' key.
368
375
 
369
376
  ACTIONS
377
+ add Add a module to the project
370
378
  generate-types Generate type references to register in plans
371
379
  install Install the project's modules
372
380
  show List modules available to the Bolt project
373
381
  HELP
374
382
 
375
- MODULE_INSTALL_HELP = <<~HELP
383
+ MODULE_ADD_HELP = <<~HELP
376
384
  NAME
377
- install
385
+ add
378
386
 
379
387
  USAGE
380
- bolt module install [options]
388
+ bolt module add <module> [options]
381
389
 
382
390
  DESCRIPTION
383
- Install the project's modules.
391
+ Add a module to the project.
384
392
 
385
393
  Module declarations are loaded from the project's configuration
386
394
  file. Bolt will automatically resolve all module dependencies,
387
395
  generate a Puppetfile, and install the modules.
396
+
397
+ The module command is only supported when a project is configured
398
+ with the 'modules' key.
388
399
  HELP
389
400
 
390
401
  MODULE_GENERATETYPES_HELP = <<~HELP
@@ -396,6 +407,24 @@ module Bolt
396
407
 
397
408
  DESCRIPTION
398
409
  Generate type references to register in plans.
410
+
411
+ The module command is only supported when a project is configured
412
+ with the 'modules' key.
413
+ HELP
414
+
415
+ MODULE_INSTALL_HELP = <<~HELP
416
+ NAME
417
+ install
418
+
419
+ USAGE
420
+ bolt module install [options]
421
+
422
+ DESCRIPTION
423
+ Install the project's modules.
424
+
425
+ Module declarations are loaded from the project's configuration
426
+ file. Bolt will automatically resolve all module dependencies,
427
+ generate a Puppetfile, and install the modules.
399
428
  HELP
400
429
 
401
430
  MODULE_SHOW_HELP = <<~HELP
@@ -407,6 +436,9 @@ module Bolt
407
436
 
408
437
  DESCRIPTION
409
438
  List modules available to the Bolt project.
439
+
440
+ The module command is only supported when a project is configured
441
+ with the 'modules' key.
410
442
  HELP
411
443
 
412
444
  PLAN_HELP = <<~HELP
@@ -746,7 +778,7 @@ module Bolt
746
778
  'For SSH, port defaults to `22`',
747
779
  'For WinRM, port defaults to `5985` or `5986` based on the --[no-]ssl setting') do |targets|
748
780
  @options[:targets] ||= []
749
- @options[:targets] << get_arg_input(targets)
781
+ @options[:targets] << Bolt::Util.get_arg_input(targets)
750
782
  end
751
783
  define('-q', '--query QUERY', 'Query PuppetDB to determine the targets') do |query|
752
784
  @options[:query] = query
@@ -906,6 +938,13 @@ module Bolt
906
938
  @options[:tmpdir] = tmpdir
907
939
  end
908
940
 
941
+ separator "\nMODULE OPTIONS"
942
+ define('--[no-]resolve',
943
+ 'Use --no-resolve to install modules listed in the Puppetfile without resolving modules configured',
944
+ 'in Bolt project configuration') do |resolve|
945
+ @options[:resolve] = resolve
946
+ end
947
+
909
948
  separator "\nDISPLAY OPTIONS"
910
949
  define('--filter FILTER', 'Filter tasks and plans by a matching substring') do |filter|
911
950
  unless /^[a-z0-9_:]+$/.match(filter)
@@ -985,27 +1024,10 @@ module Bolt
985
1024
  end
986
1025
 
987
1026
  def parse_params(params)
988
- json = get_arg_input(params)
1027
+ json = Bolt::Util.get_arg_input(params)
989
1028
  JSON.parse(json)
990
1029
  rescue JSON::ParserError => e
991
1030
  raise Bolt::CLIError, "Unable to parse --params value as JSON: #{e}"
992
1031
  end
993
-
994
- def get_arg_input(value)
995
- if value.start_with?('@')
996
- file = value.sub(/^@/, '')
997
- read_arg_file(file)
998
- elsif value == '-'
999
- $stdin.read
1000
- else
1001
- value
1002
- end
1003
- end
1004
-
1005
- def read_arg_file(file)
1006
- File.read(File.expand_path(file))
1007
- rescue StandardError => e
1008
- raise Bolt::FileError.new("Error attempting to read #{file}: #{e}", file)
1009
- end
1010
1032
  end
1011
1033
  end