openbolt 5.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Puppetfile +52 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/applyresult.rb +60 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/containerresult.rb +51 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/future.rb +25 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/resourceinstance.rb +71 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/result.rb +55 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/resultset.rb +65 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/target.rb +93 -0
- data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +33 -0
- data/bolt-modules/boltlib/lib/puppet/functions/add_to_group.rb +38 -0
- data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +208 -0
- data/bolt-modules/boltlib/lib/puppet/functions/background.rb +62 -0
- data/bolt-modules/boltlib/lib/puppet/functions/catch_errors.rb +57 -0
- data/bolt-modules/boltlib/lib/puppet/functions/download_file.rb +130 -0
- data/bolt-modules/boltlib/lib/puppet/functions/facts.rb +31 -0
- data/bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb +52 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_resources.rb +87 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_target.rb +34 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_targets.rb +35 -0
- data/bolt-modules/boltlib/lib/puppet/functions/parallelize.rb +74 -0
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_command.rb +97 -0
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb +47 -0
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb +52 -0
- data/bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb +40 -0
- data/bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb +42 -0
- data/bolt-modules/boltlib/lib/puppet/functions/resource.rb +53 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +106 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_container.rb +162 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +291 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +145 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +164 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_task_with.rb +211 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_config.rb +48 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +43 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_resources.rb +145 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_var.rb +38 -0
- data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +101 -0
- data/bolt-modules/boltlib/lib/puppet/functions/vars.rb +29 -0
- data/bolt-modules/boltlib/lib/puppet/functions/wait.rb +131 -0
- data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +59 -0
- data/bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb +39 -0
- data/bolt-modules/boltlib/lib/puppet/functions/write_file.rb +50 -0
- data/bolt-modules/boltlib/types/planresult.pp +18 -0
- data/bolt-modules/boltlib/types/targetspec.pp +7 -0
- data/bolt-modules/ctrl/lib/puppet/functions/ctrl/do_until.rb +42 -0
- data/bolt-modules/ctrl/lib/puppet/functions/ctrl/sleep.rb +20 -0
- data/bolt-modules/dir/lib/puppet/functions/dir/children.rb +35 -0
- data/bolt-modules/file/lib/puppet/functions/file/delete.rb +21 -0
- data/bolt-modules/file/lib/puppet/functions/file/exists.rb +28 -0
- data/bolt-modules/file/lib/puppet/functions/file/join.rb +20 -0
- data/bolt-modules/file/lib/puppet/functions/file/read.rb +33 -0
- data/bolt-modules/file/lib/puppet/functions/file/readable.rb +28 -0
- data/bolt-modules/file/lib/puppet/functions/file/write.rb +24 -0
- data/bolt-modules/log/lib/puppet/functions/log/debug.rb +39 -0
- data/bolt-modules/log/lib/puppet/functions/log/error.rb +40 -0
- data/bolt-modules/log/lib/puppet/functions/log/fatal.rb +40 -0
- data/bolt-modules/log/lib/puppet/functions/log/info.rb +39 -0
- data/bolt-modules/log/lib/puppet/functions/log/trace.rb +39 -0
- data/bolt-modules/log/lib/puppet/functions/log/warn.rb +41 -0
- data/bolt-modules/out/lib/puppet/functions/out/message.rb +36 -0
- data/bolt-modules/out/lib/puppet/functions/out/verbose.rb +35 -0
- data/bolt-modules/prompt/lib/puppet/functions/prompt/menu.rb +103 -0
- data/bolt-modules/prompt/lib/puppet/functions/prompt.rb +65 -0
- data/bolt-modules/system/lib/puppet/functions/system/env.rb +20 -0
- data/exe/bolt +17 -0
- data/guides/debugging.yaml +27 -0
- data/guides/inventory.yaml +23 -0
- data/guides/links.yaml +12 -0
- data/guides/logging.yaml +17 -0
- data/guides/module.yaml +18 -0
- data/guides/modulepath.yaml +24 -0
- data/guides/project.yaml +21 -0
- data/guides/targets.yaml +28 -0
- data/guides/transports.yaml +22 -0
- data/lib/bolt/analytics.rb +233 -0
- data/lib/bolt/application.rb +806 -0
- data/lib/bolt/applicator.rb +368 -0
- data/lib/bolt/apply_inventory.rb +93 -0
- data/lib/bolt/apply_result.rb +154 -0
- data/lib/bolt/apply_target.rb +90 -0
- data/lib/bolt/bolt_option_parser.rb +1226 -0
- data/lib/bolt/catalog/logging.rb +15 -0
- data/lib/bolt/catalog.rb +144 -0
- data/lib/bolt/cli.rb +949 -0
- data/lib/bolt/config/modulepath.rb +30 -0
- data/lib/bolt/config/options.rb +673 -0
- data/lib/bolt/config/transport/base.rb +133 -0
- data/lib/bolt/config/transport/docker.rb +34 -0
- data/lib/bolt/config/transport/jail.rb +33 -0
- data/lib/bolt/config/transport/local.rb +39 -0
- data/lib/bolt/config/transport/lxd.rb +34 -0
- data/lib/bolt/config/transport/options.rb +431 -0
- data/lib/bolt/config/transport/orch.rb +41 -0
- data/lib/bolt/config/transport/podman.rb +33 -0
- data/lib/bolt/config/transport/remote.rb +24 -0
- data/lib/bolt/config/transport/ssh.rb +138 -0
- data/lib/bolt/config/transport/winrm.rb +63 -0
- data/lib/bolt/config.rb +515 -0
- data/lib/bolt/container_result.rb +105 -0
- data/lib/bolt/error.rb +194 -0
- data/lib/bolt/executor.rb +539 -0
- data/lib/bolt/fiber_executor.rb +190 -0
- data/lib/bolt/inventory/group.rb +446 -0
- data/lib/bolt/inventory/inventory.rb +391 -0
- data/lib/bolt/inventory/options.rb +139 -0
- data/lib/bolt/inventory/target.rb +293 -0
- data/lib/bolt/inventory.rb +120 -0
- data/lib/bolt/logger.rb +252 -0
- data/lib/bolt/module.rb +54 -0
- data/lib/bolt/module_installer/installer.rb +44 -0
- data/lib/bolt/module_installer/puppetfile/forge_module.rb +54 -0
- data/lib/bolt/module_installer/puppetfile/git_module.rb +37 -0
- data/lib/bolt/module_installer/puppetfile/module.rb +26 -0
- data/lib/bolt/module_installer/puppetfile.rb +131 -0
- data/lib/bolt/module_installer/resolver.rb +129 -0
- data/lib/bolt/module_installer/specs/forge_spec.rb +91 -0
- data/lib/bolt/module_installer/specs/git_spec.rb +150 -0
- data/lib/bolt/module_installer/specs/id/base.rb +116 -0
- data/lib/bolt/module_installer/specs/id/gitclone.rb +120 -0
- data/lib/bolt/module_installer/specs/id/github.rb +90 -0
- data/lib/bolt/module_installer/specs/id/gitlab.rb +92 -0
- data/lib/bolt/module_installer/specs.rb +95 -0
- data/lib/bolt/module_installer.rb +208 -0
- data/lib/bolt/node/errors.rb +55 -0
- data/lib/bolt/node/output.rb +29 -0
- data/lib/bolt/outputter/human.rb +958 -0
- data/lib/bolt/outputter/json.rb +205 -0
- data/lib/bolt/outputter/logger.rb +76 -0
- data/lib/bolt/outputter/rainbow.rb +118 -0
- data/lib/bolt/outputter.rb +57 -0
- data/lib/bolt/pal/issues.rb +19 -0
- data/lib/bolt/pal/logging.rb +17 -0
- data/lib/bolt/pal/yaml_plan/evaluator.rb +83 -0
- data/lib/bolt/pal/yaml_plan/loader.rb +94 -0
- data/lib/bolt/pal/yaml_plan/parameter.rb +63 -0
- data/lib/bolt/pal/yaml_plan/step/command.rb +45 -0
- data/lib/bolt/pal/yaml_plan/step/download.rb +37 -0
- data/lib/bolt/pal/yaml_plan/step/eval.rb +42 -0
- data/lib/bolt/pal/yaml_plan/step/message.rb +31 -0
- data/lib/bolt/pal/yaml_plan/step/plan.rb +42 -0
- data/lib/bolt/pal/yaml_plan/step/resources.rb +170 -0
- data/lib/bolt/pal/yaml_plan/step/script.rb +62 -0
- data/lib/bolt/pal/yaml_plan/step/task.rb +42 -0
- data/lib/bolt/pal/yaml_plan/step/upload.rb +37 -0
- data/lib/bolt/pal/yaml_plan/step/verbose.rb +31 -0
- data/lib/bolt/pal/yaml_plan/step.rb +223 -0
- data/lib/bolt/pal/yaml_plan/transpiler.rb +90 -0
- data/lib/bolt/pal/yaml_plan.rb +172 -0
- data/lib/bolt/pal.rb +847 -0
- data/lib/bolt/plan_creator.rb +219 -0
- data/lib/bolt/plan_future.rb +86 -0
- data/lib/bolt/plan_result.rb +44 -0
- data/lib/bolt/plugin/cache.rb +76 -0
- data/lib/bolt/plugin/env_var.rb +54 -0
- data/lib/bolt/plugin/module.rb +276 -0
- data/lib/bolt/plugin/prompt.rb +36 -0
- data/lib/bolt/plugin/puppet_connect_data.rb +84 -0
- data/lib/bolt/plugin/puppetdb.rb +124 -0
- data/lib/bolt/plugin/task.rb +72 -0
- data/lib/bolt/plugin.rb +380 -0
- data/lib/bolt/project.rb +219 -0
- data/lib/bolt/project_manager/config_migrator.rb +113 -0
- data/lib/bolt/project_manager/inventory_migrator.rb +67 -0
- data/lib/bolt/project_manager/migrator.rb +39 -0
- data/lib/bolt/project_manager/module_migrator.rb +203 -0
- data/lib/bolt/project_manager.rb +221 -0
- data/lib/bolt/puppetdb/client.rb +153 -0
- data/lib/bolt/puppetdb/config.rb +176 -0
- data/lib/bolt/puppetdb/instance.rb +146 -0
- data/lib/bolt/puppetdb.rb +15 -0
- data/lib/bolt/r10k_log_proxy.rb +30 -0
- data/lib/bolt/rerun.rb +55 -0
- data/lib/bolt/resource_instance.rb +133 -0
- data/lib/bolt/result.rb +247 -0
- data/lib/bolt/result_set.rb +128 -0
- data/lib/bolt/shell/bash/tmpdir.rb +62 -0
- data/lib/bolt/shell/bash.rb +516 -0
- data/lib/bolt/shell/powershell/snippets.rb +181 -0
- data/lib/bolt/shell/powershell.rb +365 -0
- data/lib/bolt/shell.rb +105 -0
- data/lib/bolt/target.rb +174 -0
- data/lib/bolt/task/puppet_server.rb +27 -0
- data/lib/bolt/task/run.rb +55 -0
- data/lib/bolt/task.rb +163 -0
- data/lib/bolt/transport/base.rb +252 -0
- data/lib/bolt/transport/docker/connection.rb +150 -0
- data/lib/bolt/transport/docker.rb +23 -0
- data/lib/bolt/transport/jail/connection.rb +81 -0
- data/lib/bolt/transport/jail.rb +21 -0
- data/lib/bolt/transport/local/connection.rb +106 -0
- data/lib/bolt/transport/local.rb +20 -0
- data/lib/bolt/transport/lxd/connection.rb +115 -0
- data/lib/bolt/transport/lxd.rb +26 -0
- data/lib/bolt/transport/orch/connection.rb +111 -0
- data/lib/bolt/transport/orch.rb +271 -0
- data/lib/bolt/transport/podman/connection.rb +102 -0
- data/lib/bolt/transport/podman.rb +19 -0
- data/lib/bolt/transport/remote.rb +41 -0
- data/lib/bolt/transport/simple.rb +54 -0
- data/lib/bolt/transport/ssh/connection.rb +321 -0
- data/lib/bolt/transport/ssh/exec_connection.rb +140 -0
- data/lib/bolt/transport/ssh.rb +48 -0
- data/lib/bolt/transport/winrm/connection.rb +378 -0
- data/lib/bolt/transport/winrm.rb +33 -0
- data/lib/bolt/util/format.rb +68 -0
- data/lib/bolt/util/puppet_log_level.rb +21 -0
- data/lib/bolt/util.rb +465 -0
- data/lib/bolt/validator.rb +227 -0
- data/lib/bolt/version.rb +5 -0
- data/lib/bolt.rb +8 -0
- data/lib/bolt_server/acl.rb +39 -0
- data/lib/bolt_server/base_config.rb +112 -0
- data/lib/bolt_server/config.rb +64 -0
- data/lib/bolt_server/file_cache.rb +200 -0
- data/lib/bolt_server/request_error.rb +11 -0
- data/lib/bolt_server/schemas/action-check_node_connections.json +14 -0
- data/lib/bolt_server/schemas/action-run_command.json +12 -0
- data/lib/bolt_server/schemas/action-run_script.json +47 -0
- data/lib/bolt_server/schemas/action-run_task.json +20 -0
- data/lib/bolt_server/schemas/action-upload_file.json +47 -0
- data/lib/bolt_server/schemas/partials/target-any.json +10 -0
- data/lib/bolt_server/schemas/partials/target-ssh.json +88 -0
- data/lib/bolt_server/schemas/partials/target-winrm.json +67 -0
- data/lib/bolt_server/schemas/partials/task.json +94 -0
- data/lib/bolt_server/schemas/transport-ssh.json +25 -0
- data/lib/bolt_server/schemas/transport-winrm.json +19 -0
- data/lib/bolt_server/transport_app.rb +554 -0
- data/lib/bolt_spec/bolt_context.rb +226 -0
- data/lib/bolt_spec/plans/action_stubs/command_stub.rb +51 -0
- data/lib/bolt_spec/plans/action_stubs/download_stub.rb +66 -0
- data/lib/bolt_spec/plans/action_stubs/plan_stub.rb +55 -0
- data/lib/bolt_spec/plans/action_stubs/script_stub.rb +59 -0
- data/lib/bolt_spec/plans/action_stubs/task_stub.rb +57 -0
- data/lib/bolt_spec/plans/action_stubs/upload_stub.rb +65 -0
- data/lib/bolt_spec/plans/action_stubs.rb +196 -0
- data/lib/bolt_spec/plans/mock_executor.rb +361 -0
- data/lib/bolt_spec/plans/publish_stub.rb +49 -0
- data/lib/bolt_spec/plans.rb +190 -0
- data/lib/bolt_spec/run.rb +246 -0
- data/lib/logging_extensions/logging.rb +13 -0
- data/libexec/apply_catalog.rb +130 -0
- data/libexec/bolt_catalog +68 -0
- data/libexec/custom_facts.rb +63 -0
- data/libexec/query_resources.rb +75 -0
- data/modules/aggregate/lib/puppet/functions/aggregate/count.rb +21 -0
- data/modules/aggregate/lib/puppet/functions/aggregate/nodes.rb +22 -0
- data/modules/aggregate/lib/puppet/functions/aggregate/targets.rb +21 -0
- data/modules/aggregate/plans/count.pp +56 -0
- data/modules/aggregate/plans/targets.pp +56 -0
- data/modules/canary/lib/puppet/functions/canary/merge.rb +13 -0
- data/modules/canary/lib/puppet/functions/canary/random_split.rb +22 -0
- data/modules/canary/lib/puppet/functions/canary/skip.rb +25 -0
- data/modules/canary/plans/init.pp +100 -0
- data/modules/puppet_connect/plans/test_input_data.pp +94 -0
- data/modules/puppetdb_fact/plans/init.pp +20 -0
- data/resources/bolt_bash_completion.sh +214 -0
- metadata +735 -0
@@ -0,0 +1,1226 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Note this file includes very few 'requires' because it expects to be used from the CLI.
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
module Bolt
|
8
|
+
class BoltOptionParser < OptionParser
|
9
|
+
PROJECT_PATHS = %w[project].freeze
|
10
|
+
OPTIONS = { inventory: %w[targets query rerun],
|
11
|
+
authentication: %w[user password password-prompt private-key host-key-check ssl ssl-verify],
|
12
|
+
escalation: %w[run-as sudo-password sudo-password-prompt sudo-executable],
|
13
|
+
run_context: %w[concurrency inventoryfile save-rerun cleanup puppetdb],
|
14
|
+
global_config_setters: PROJECT_PATHS + %w[modulepath],
|
15
|
+
transports: %w[transport connect-timeout tty native-ssh ssh-command copy-command],
|
16
|
+
display: %w[format color verbose trace stream],
|
17
|
+
global: %w[help version log-level clear-cache] }.freeze
|
18
|
+
|
19
|
+
ACTION_OPTS = OPTIONS.values.flatten.freeze
|
20
|
+
|
21
|
+
def get_help_text(subcommand, action = nil)
|
22
|
+
case subcommand
|
23
|
+
when 'apply'
|
24
|
+
{ flags: ACTION_OPTS + %w[noop execute compile-concurrency hiera-config],
|
25
|
+
banner: APPLY_HELP }
|
26
|
+
when 'command'
|
27
|
+
case action
|
28
|
+
when 'run'
|
29
|
+
{ flags: ACTION_OPTS + %w[env-var],
|
30
|
+
banner: COMMAND_RUN_HELP }
|
31
|
+
else
|
32
|
+
{ flags: OPTIONS[:global],
|
33
|
+
banner: COMMAND_HELP }
|
34
|
+
end
|
35
|
+
when 'file'
|
36
|
+
case action
|
37
|
+
when 'upload'
|
38
|
+
{ flags: ACTION_OPTS + %w[tmpdir],
|
39
|
+
banner: FILE_UPLOAD_HELP }
|
40
|
+
when 'download'
|
41
|
+
{ flags: ACTION_OPTS,
|
42
|
+
banner: FILE_DOWNLOAD_HELP }
|
43
|
+
else
|
44
|
+
{ flags: OPTIONS[:global],
|
45
|
+
banner: FILE_HELP }
|
46
|
+
end
|
47
|
+
when 'inventory'
|
48
|
+
case action
|
49
|
+
when 'show'
|
50
|
+
{ flags: OPTIONS[:inventory] + OPTIONS[:global] +
|
51
|
+
PROJECT_PATHS + %w[format inventoryfile detail],
|
52
|
+
banner: INVENTORY_SHOW_HELP }
|
53
|
+
else
|
54
|
+
{ flags: OPTIONS[:global],
|
55
|
+
banner: INVENTORY_HELP }
|
56
|
+
end
|
57
|
+
when 'group'
|
58
|
+
case action
|
59
|
+
when 'show'
|
60
|
+
{ flags: OPTIONS[:global] + PROJECT_PATHS + %w[format inventoryfile],
|
61
|
+
banner: GROUP_SHOW_HELP }
|
62
|
+
else
|
63
|
+
{ flags: OPTIONS[:global],
|
64
|
+
banner: GROUP_HELP }
|
65
|
+
end
|
66
|
+
when 'guide'
|
67
|
+
{ flags: OPTIONS[:global] + %w[format],
|
68
|
+
banner: GUIDE_HELP }
|
69
|
+
when 'lookup'
|
70
|
+
{ flags: ACTION_OPTS + %w[hiera-config plan-hierarchy],
|
71
|
+
banner: LOOKUP_HELP }
|
72
|
+
when 'module'
|
73
|
+
case action
|
74
|
+
when 'add'
|
75
|
+
{ flags: OPTIONS[:global] + PROJECT_PATHS,
|
76
|
+
banner: MODULE_ADD_HELP }
|
77
|
+
when 'generate-types'
|
78
|
+
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters],
|
79
|
+
banner: MODULE_GENERATETYPES_HELP }
|
80
|
+
when 'install'
|
81
|
+
{ flags: OPTIONS[:global] + PROJECT_PATHS + %w[force resolve],
|
82
|
+
banner: MODULE_INSTALL_HELP }
|
83
|
+
when 'show'
|
84
|
+
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters],
|
85
|
+
banner: MODULE_SHOW_HELP }
|
86
|
+
else
|
87
|
+
{ flags: OPTIONS[:global],
|
88
|
+
banner: MODULE_HELP }
|
89
|
+
end
|
90
|
+
when 'plan'
|
91
|
+
case action
|
92
|
+
when 'convert'
|
93
|
+
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters],
|
94
|
+
banner: PLAN_CONVERT_HELP }
|
95
|
+
when 'new'
|
96
|
+
{ flags: OPTIONS[:global] + PROJECT_PATHS + %w[pp],
|
97
|
+
banner: PLAN_NEW_HELP }
|
98
|
+
when 'run'
|
99
|
+
{ flags: ACTION_OPTS + %w[params compile-concurrency tmpdir hiera-config],
|
100
|
+
banner: PLAN_RUN_HELP }
|
101
|
+
when 'show'
|
102
|
+
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters] + %w[filter format],
|
103
|
+
banner: PLAN_SHOW_HELP }
|
104
|
+
else
|
105
|
+
{ flags: OPTIONS[:global],
|
106
|
+
banner: PLAN_HELP }
|
107
|
+
end
|
108
|
+
when 'plugin'
|
109
|
+
case action
|
110
|
+
when 'show'
|
111
|
+
{ flags: OPTIONS[:global] + %w[color format modulepath project],
|
112
|
+
banner: PLUGIN_SHOW_HELP }
|
113
|
+
else
|
114
|
+
{ flags: OPTIONS[:global],
|
115
|
+
banner: PLUGIN_HELP }
|
116
|
+
end
|
117
|
+
when 'policy'
|
118
|
+
case action
|
119
|
+
when 'apply'
|
120
|
+
{ flags: ACTION_OPTS + %w[compile-concurrency hiera-config noop],
|
121
|
+
banner: POLICY_APPLY_HELP }
|
122
|
+
when 'new'
|
123
|
+
{ flags: OPTIONS[:global] + PROJECT_PATHS,
|
124
|
+
banner: POLICY_NEW_HELP }
|
125
|
+
when 'show'
|
126
|
+
{ flags: OPTIONS[:global] + PROJECT_PATHS,
|
127
|
+
banner: POLICY_SHOW_HELP }
|
128
|
+
else
|
129
|
+
{ flags: OPTIONS[:global],
|
130
|
+
banner: POLICY_HELP }
|
131
|
+
end
|
132
|
+
when 'project'
|
133
|
+
case action
|
134
|
+
when 'init'
|
135
|
+
{ flags: OPTIONS[:global] + %w[modules],
|
136
|
+
banner: PROJECT_INIT_HELP }
|
137
|
+
when 'migrate'
|
138
|
+
{ flags: OPTIONS[:global] + PROJECT_PATHS + %w[inventoryfile],
|
139
|
+
banner: PROJECT_MIGRATE_HELP }
|
140
|
+
else
|
141
|
+
{ flags: OPTIONS[:global],
|
142
|
+
banner: PROJECT_HELP }
|
143
|
+
end
|
144
|
+
when 'script'
|
145
|
+
case action
|
146
|
+
when 'run'
|
147
|
+
{ flags: ACTION_OPTS + %w[tmpdir env-var],
|
148
|
+
banner: SCRIPT_RUN_HELP }
|
149
|
+
else
|
150
|
+
{ flags: OPTIONS[:global],
|
151
|
+
banner: SCRIPT_HELP }
|
152
|
+
end
|
153
|
+
when 'secret'
|
154
|
+
case action
|
155
|
+
when 'createkeys'
|
156
|
+
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters] + %w[plugin force],
|
157
|
+
banner: SECRET_CREATEKEYS_HELP }
|
158
|
+
when 'decrypt'
|
159
|
+
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters] + %w[plugin],
|
160
|
+
banner: SECRET_DECRYPT_HELP }
|
161
|
+
when 'encrypt'
|
162
|
+
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters] + %w[plugin],
|
163
|
+
banner: SECRET_ENCRYPT_HELP }
|
164
|
+
else
|
165
|
+
{ flags: OPTIONS[:global],
|
166
|
+
banner: SECRET_HELP }
|
167
|
+
end
|
168
|
+
when 'task'
|
169
|
+
case action
|
170
|
+
when 'run'
|
171
|
+
{ flags: ACTION_OPTS + %w[params tmpdir noop],
|
172
|
+
banner: TASK_RUN_HELP }
|
173
|
+
when 'show'
|
174
|
+
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters] + %w[filter format],
|
175
|
+
banner: TASK_SHOW_HELP }
|
176
|
+
else
|
177
|
+
{ flags: OPTIONS[:global],
|
178
|
+
banner: TASK_HELP }
|
179
|
+
end
|
180
|
+
else
|
181
|
+
{ flags: OPTIONS[:global],
|
182
|
+
banner: BANNER }
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
COLORS = {
|
187
|
+
cyan: "36"
|
188
|
+
}.freeze
|
189
|
+
|
190
|
+
def self.colorize(color, string)
|
191
|
+
if $stdout.isatty
|
192
|
+
"\033[#{COLORS[color]}m#{string}\033[0m"
|
193
|
+
else
|
194
|
+
string
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
BANNER = <<~HELP
|
199
|
+
#{colorize(:cyan, 'Name')}
|
200
|
+
bolt
|
201
|
+
|
202
|
+
#{colorize(:cyan, 'Usage')}
|
203
|
+
bolt <subcommand> [action] [options]
|
204
|
+
|
205
|
+
#{colorize(:cyan, 'Description')}
|
206
|
+
Bolt is an orchestration tool that automates the manual work it takes to
|
207
|
+
maintain your infrastructure.
|
208
|
+
|
209
|
+
#{colorize(:cyan, 'Subcommands')}
|
210
|
+
apply Apply Puppet manifest code
|
211
|
+
command Run a command remotely
|
212
|
+
file Copy files between the controller and targets
|
213
|
+
group Show the list of groups in the inventory
|
214
|
+
guide View guides for Bolt concepts and features
|
215
|
+
inventory Show the list of targets an action would run on
|
216
|
+
module Manage Bolt project modules
|
217
|
+
lookup Look up a value with Hiera
|
218
|
+
plan Convert, create, show, and run Bolt plans
|
219
|
+
plugin Show available plugins
|
220
|
+
policy Apply, create, and show policies
|
221
|
+
project Create and migrate Bolt projects
|
222
|
+
script Upload a local script and run it remotely
|
223
|
+
secret Create encryption keys and encrypt and decrypt values
|
224
|
+
task Show and run Bolt tasks
|
225
|
+
|
226
|
+
#{colorize(:cyan, 'Guides')}
|
227
|
+
For a list of guides on Bolt's concepts and features, run 'bolt guide'.
|
228
|
+
Find Bolt's documentation at https://bolt.guide.
|
229
|
+
HELP
|
230
|
+
|
231
|
+
APPLY_HELP = <<~HELP
|
232
|
+
#{colorize(:cyan, 'Name')}
|
233
|
+
apply
|
234
|
+
|
235
|
+
#{colorize(:cyan, 'Usage')}
|
236
|
+
bolt apply [manifest] {--targets TARGETS | --query QUERY | --rerun FILTER}
|
237
|
+
[options]
|
238
|
+
|
239
|
+
#{colorize(:cyan, 'Description')}
|
240
|
+
Apply Puppet manifest code on the specified targets.
|
241
|
+
|
242
|
+
#{colorize(:cyan, 'Documentation')}
|
243
|
+
For documentation see http://pup.pt/bolt-apply.
|
244
|
+
|
245
|
+
#{colorize(:cyan, 'Examples')}
|
246
|
+
bolt apply manifest.pp -t target
|
247
|
+
bolt apply -e "file { '/etc/puppetlabs': ensure => present }" -t target
|
248
|
+
HELP
|
249
|
+
|
250
|
+
COMMAND_HELP = <<~HELP
|
251
|
+
#{colorize(:cyan, 'Name')}
|
252
|
+
command
|
253
|
+
|
254
|
+
#{colorize(:cyan, 'Usage')}
|
255
|
+
bolt command <action> [options]
|
256
|
+
|
257
|
+
#{colorize(:cyan, 'Description')}
|
258
|
+
Run a command on the specified targets.
|
259
|
+
|
260
|
+
#{colorize(:cyan, 'Documentation')}
|
261
|
+
For documentation see http://pup.pt/bolt-commands.
|
262
|
+
|
263
|
+
#{colorize(:cyan, 'Actions')}
|
264
|
+
run Run a command on the specified targets.
|
265
|
+
HELP
|
266
|
+
|
267
|
+
COMMAND_RUN_HELP = <<~HELP
|
268
|
+
#{colorize(:cyan, 'Name')}
|
269
|
+
command run
|
270
|
+
|
271
|
+
#{colorize(:cyan, 'Usage')}
|
272
|
+
bolt command run <command> {--targets TARGETS | --query QUERY | --rerun FILTER}
|
273
|
+
[options]
|
274
|
+
|
275
|
+
#{colorize(:cyan, 'Description')}
|
276
|
+
Run a command on the specified targets.
|
277
|
+
|
278
|
+
#{colorize(:cyan, 'Documentation')}
|
279
|
+
For documentation see http://pup.pt/bolt-commands.
|
280
|
+
|
281
|
+
#{colorize(:cyan, 'Examples')}
|
282
|
+
bolt command run 'uptime' -t target1,target2
|
283
|
+
HELP
|
284
|
+
|
285
|
+
FILE_HELP = <<~HELP
|
286
|
+
#{colorize(:cyan, 'Name')}
|
287
|
+
file
|
288
|
+
|
289
|
+
#{colorize(:cyan, 'Usage')}
|
290
|
+
bolt file <action> [options]
|
291
|
+
|
292
|
+
#{colorize(:cyan, 'Description')}
|
293
|
+
Copy files and directories between the controller and targets.
|
294
|
+
|
295
|
+
#{colorize(:cyan, 'Documentation')}
|
296
|
+
For documentation see http://pup.pt/bolt-commands.
|
297
|
+
|
298
|
+
#{colorize(:cyan, 'Actions')}
|
299
|
+
download Download a file or directory to the controller
|
300
|
+
upload Upload a local file or directory from the controller
|
301
|
+
HELP
|
302
|
+
|
303
|
+
FILE_DOWNLOAD_HELP = <<~HELP
|
304
|
+
#{colorize(:cyan, 'Name')}
|
305
|
+
file download
|
306
|
+
|
307
|
+
#{colorize(:cyan, 'Usage')}
|
308
|
+
bolt file download <source> <destination> {--targets TARGETS | --query QUERY | --rerun FILTER}
|
309
|
+
[options]
|
310
|
+
|
311
|
+
#{colorize(:cyan, 'Description')}
|
312
|
+
Download a file or directory from one or more targets.
|
313
|
+
|
314
|
+
Downloaded files and directories are saved to the a subdirectory
|
315
|
+
matching the target's name under the destination directory. The
|
316
|
+
destination directory is expanded relative to the downloads
|
317
|
+
subdirectory of the project directory.
|
318
|
+
|
319
|
+
#{colorize(:cyan, 'Documentation')}
|
320
|
+
For documentation see http://pup.pt/bolt-commands.
|
321
|
+
|
322
|
+
#{colorize(:cyan, 'Examples')}
|
323
|
+
bolt file download /etc/ssh_config ssh_config -t all
|
324
|
+
HELP
|
325
|
+
|
326
|
+
FILE_UPLOAD_HELP = <<~HELP
|
327
|
+
#{colorize(:cyan, 'Name')}
|
328
|
+
file upload
|
329
|
+
|
330
|
+
#{colorize(:cyan, 'Usage')}
|
331
|
+
bolt file upload <source> <destination> {--targets TARGETS | --query QUERY | --rerun FILTER}
|
332
|
+
[options]
|
333
|
+
|
334
|
+
#{colorize(:cyan, 'Description')}
|
335
|
+
Upload a local file or directory.
|
336
|
+
|
337
|
+
#{colorize(:cyan, 'Documentation')}
|
338
|
+
For documentation see http://pup.pt/bolt-commands.
|
339
|
+
|
340
|
+
#{colorize(:cyan, 'Examples')}
|
341
|
+
bolt file upload /tmp/source /etc/profile.d/login.sh -t target1
|
342
|
+
HELP
|
343
|
+
|
344
|
+
GROUP_HELP = <<~HELP
|
345
|
+
#{colorize(:cyan, 'Name')}
|
346
|
+
group
|
347
|
+
|
348
|
+
#{colorize(:cyan, 'Usage')}
|
349
|
+
bolt group <action> [options]
|
350
|
+
|
351
|
+
#{colorize(:cyan, 'Description')}
|
352
|
+
Show the list of groups in the inventory.
|
353
|
+
|
354
|
+
#{colorize(:cyan, 'Documentation')}
|
355
|
+
To learn more about the inventory run 'bolt guide inventory'.
|
356
|
+
|
357
|
+
#{colorize(:cyan, 'Actions')}
|
358
|
+
show Show the list of groups in the inventory
|
359
|
+
HELP
|
360
|
+
|
361
|
+
GROUP_SHOW_HELP = <<~HELP
|
362
|
+
#{colorize(:cyan, 'Name')}
|
363
|
+
group show
|
364
|
+
|
365
|
+
#{colorize(:cyan, 'Usage')}
|
366
|
+
bolt group show [options]
|
367
|
+
|
368
|
+
#{colorize(:cyan, 'Description')}
|
369
|
+
Show the list of groups in the inventory.
|
370
|
+
|
371
|
+
#{colorize(:cyan, 'Documentation')}
|
372
|
+
To learn more about the inventory run 'bolt guide inventory'.
|
373
|
+
HELP
|
374
|
+
|
375
|
+
GUIDE_HELP = <<~HELP
|
376
|
+
#{colorize(:cyan, 'Name')}
|
377
|
+
guide
|
378
|
+
|
379
|
+
#{colorize(:cyan, 'Usage')}
|
380
|
+
bolt guide [topic] [options]
|
381
|
+
|
382
|
+
#{colorize(:cyan, 'Description')}
|
383
|
+
View guides for Bolt's concepts and features.
|
384
|
+
|
385
|
+
Omitting a topic will display a list of available guides,
|
386
|
+
while providing a topic will display the relevant guide.
|
387
|
+
|
388
|
+
#{colorize(:cyan, 'Examples')}
|
389
|
+
View a list of available guides
|
390
|
+
bolt guide
|
391
|
+
View the 'project' guide page
|
392
|
+
bolt guide project
|
393
|
+
HELP
|
394
|
+
|
395
|
+
INVENTORY_HELP = <<~HELP
|
396
|
+
#{colorize(:cyan, 'Name')}
|
397
|
+
inventory
|
398
|
+
|
399
|
+
#{colorize(:cyan, 'Usage')}
|
400
|
+
bolt inventory <action> [options]
|
401
|
+
|
402
|
+
#{colorize(:cyan, 'Description')}
|
403
|
+
Show the list of targets an action would run on.
|
404
|
+
|
405
|
+
#{colorize(:cyan, 'Documentation')}
|
406
|
+
To learn more about the inventory run 'bolt guide inventory'.
|
407
|
+
|
408
|
+
#{colorize(:cyan, 'Actions')}
|
409
|
+
show Show the list of targets an action would run on
|
410
|
+
HELP
|
411
|
+
|
412
|
+
INVENTORY_SHOW_HELP = <<~HELP
|
413
|
+
#{colorize(:cyan, 'Name')}
|
414
|
+
inventory show
|
415
|
+
|
416
|
+
#{colorize(:cyan, 'Usage')}
|
417
|
+
bolt inventory show [options]
|
418
|
+
|
419
|
+
#{colorize(:cyan, 'Description')}
|
420
|
+
Show the list of targets an action would run on. This command will list
|
421
|
+
all targets in the project's inventory by default.
|
422
|
+
|
423
|
+
To filter the targets in the list, use the --targets, --query, or --rerun
|
424
|
+
options. To view detailed configuration and data for targets, use the
|
425
|
+
--detail option. To learn more about the inventory run 'bolt guide inventory'.
|
426
|
+
|
427
|
+
#{colorize(:cyan, 'Documentation')}
|
428
|
+
To learn more about the inventory run 'bolt guide inventory'.
|
429
|
+
HELP
|
430
|
+
|
431
|
+
LOOKUP_HELP = <<~HELP
|
432
|
+
#{colorize(:cyan, 'Name')}
|
433
|
+
lookup
|
434
|
+
|
435
|
+
#{colorize(:cyan, 'Usage')}
|
436
|
+
bolt lookup <key> {--targets TARGETS | --query QUERY | --rerun FILTER | --plan-hierarchy}
|
437
|
+
[options]
|
438
|
+
|
439
|
+
#{colorize(:cyan, 'Description')}
|
440
|
+
Look up a value with Hiera.
|
441
|
+
|
442
|
+
#{colorize(:cyan, 'Documentation')}
|
443
|
+
Learn more about using Hiera with Bolt at https://pup.pt/bolt-hiera.
|
444
|
+
|
445
|
+
#{colorize(:cyan, 'Examples')}
|
446
|
+
bolt lookup password --targets servers
|
447
|
+
bolt lookup password --plan-hierarchy variable=value
|
448
|
+
HELP
|
449
|
+
|
450
|
+
MODULE_HELP = <<~HELP
|
451
|
+
#{colorize(:cyan, 'Name')}
|
452
|
+
module
|
453
|
+
|
454
|
+
#{colorize(:cyan, 'Usage')}
|
455
|
+
bolt module <action> [options]
|
456
|
+
|
457
|
+
#{colorize(:cyan, 'Description')}
|
458
|
+
Manage Bolt project modules.
|
459
|
+
|
460
|
+
#{colorize(:cyan, 'Documentation')}
|
461
|
+
To learn more about Bolt modules run 'bolt guide module'.
|
462
|
+
|
463
|
+
#{colorize(:cyan, 'Actions')}
|
464
|
+
add Add a module to the project
|
465
|
+
generate-types Generate type references to register in plans
|
466
|
+
install Install the project's modules
|
467
|
+
show List modules available to the Bolt project
|
468
|
+
HELP
|
469
|
+
|
470
|
+
MODULE_ADD_HELP = <<~HELP
|
471
|
+
#{colorize(:cyan, 'Name')}
|
472
|
+
module add
|
473
|
+
|
474
|
+
#{colorize(:cyan, 'Usage')}
|
475
|
+
bolt module add <module> [options]
|
476
|
+
|
477
|
+
#{colorize(:cyan, 'Description')}
|
478
|
+
Add a module to the project.
|
479
|
+
|
480
|
+
Module declarations are loaded from the project's configuration
|
481
|
+
file. Bolt will automatically resolve all module dependencies,
|
482
|
+
generate a Puppetfile, and install the modules.
|
483
|
+
|
484
|
+
#{colorize(:cyan, 'Documentation')}
|
485
|
+
To learn more about Bolt modules, run 'bolt guide module'.
|
486
|
+
HELP
|
487
|
+
|
488
|
+
MODULE_GENERATETYPES_HELP = <<~HELP
|
489
|
+
#{colorize(:cyan, 'Name')}
|
490
|
+
module generate-types
|
491
|
+
|
492
|
+
#{colorize(:cyan, 'Usage')}
|
493
|
+
bolt module generate-types [options]
|
494
|
+
|
495
|
+
#{colorize(:cyan, 'Description')}
|
496
|
+
Generate type references to register in plans. To learn more about
|
497
|
+
Bolt modules, run 'bolt guide module'.
|
498
|
+
|
499
|
+
#{colorize(:cyan, 'Documentation')}
|
500
|
+
To learn more about Bolt modules, run 'bolt guide module'.
|
501
|
+
HELP
|
502
|
+
|
503
|
+
MODULE_INSTALL_HELP = <<~HELP
|
504
|
+
#{colorize(:cyan, 'Name')}
|
505
|
+
module install
|
506
|
+
|
507
|
+
#{colorize(:cyan, 'Usage')}
|
508
|
+
bolt module install [options]
|
509
|
+
|
510
|
+
#{colorize(:cyan, 'Description')}
|
511
|
+
Install the project's modules.
|
512
|
+
|
513
|
+
Module declarations are loaded from the project's configuration
|
514
|
+
file. Bolt will automatically resolve all module dependencies,
|
515
|
+
generate a Puppetfile, and install the modules.
|
516
|
+
|
517
|
+
#{colorize(:cyan, 'Documentation')}
|
518
|
+
To learn more about Bolt modules, run 'bolt guide module'.
|
519
|
+
HELP
|
520
|
+
|
521
|
+
MODULE_SHOW_HELP = <<~HELP
|
522
|
+
#{colorize(:cyan, 'Name')}
|
523
|
+
module show
|
524
|
+
|
525
|
+
#{colorize(:cyan, 'Usage')}
|
526
|
+
bolt module show [module name] [options]
|
527
|
+
|
528
|
+
#{colorize(:cyan, 'Description')}
|
529
|
+
List modules available to the Bolt project.
|
530
|
+
|
531
|
+
Providing the name of a module will display detailed documentation for
|
532
|
+
the module.
|
533
|
+
|
534
|
+
#{colorize(:cyan, 'Documentation')}
|
535
|
+
To learn more about Bolt modules, run 'bolt guide module'.
|
536
|
+
HELP
|
537
|
+
|
538
|
+
PLAN_HELP = <<~HELP
|
539
|
+
#{colorize(:cyan, 'Name')}
|
540
|
+
plan
|
541
|
+
|
542
|
+
#{colorize(:cyan, 'Usage')}
|
543
|
+
bolt plan <action> [options]
|
544
|
+
|
545
|
+
#{colorize(:cyan, 'Description')}
|
546
|
+
Convert, create, show, and run Bolt plans.
|
547
|
+
|
548
|
+
#{colorize(:cyan, 'Documentation')}
|
549
|
+
Learn more about Bolt plans at https://pup.pt/bolt-plans.
|
550
|
+
|
551
|
+
#{colorize(:cyan, 'Actions')}
|
552
|
+
convert Convert a YAML plan to a Bolt plan
|
553
|
+
new Create a new plan in the current project
|
554
|
+
run Run a plan on the specified targets
|
555
|
+
show Show available plans and plan documentation
|
556
|
+
HELP
|
557
|
+
|
558
|
+
PLAN_CONVERT_HELP = <<~HELP
|
559
|
+
#{colorize(:cyan, 'Name')}
|
560
|
+
plan convert
|
561
|
+
|
562
|
+
#{colorize(:cyan, 'Usage')}
|
563
|
+
bolt plan convert <plan name> [options]
|
564
|
+
|
565
|
+
#{colorize(:cyan, 'Description')}
|
566
|
+
Convert a YAML plan to a Puppet language plan and print the converted
|
567
|
+
plan to stdout.
|
568
|
+
|
569
|
+
Converting a YAML plan might result in a plan that is syntactically
|
570
|
+
correct but has different behavior. Always verify a converted plan's
|
571
|
+
functionality. Note that the converted plan is not written to a file.
|
572
|
+
|
573
|
+
#{colorize(:cyan, 'Documentation')}
|
574
|
+
Learn more about Bolt plans at https://pup.pt/bolt-plans.
|
575
|
+
|
576
|
+
#{colorize(:cyan, 'Examples')}
|
577
|
+
bolt plan convert myproject::myplan
|
578
|
+
bolt plan convert path/to/plan/myplan.yaml
|
579
|
+
HELP
|
580
|
+
|
581
|
+
PLAN_NEW_HELP = <<~HELP
|
582
|
+
#{colorize(:cyan, 'Name')}
|
583
|
+
plan new
|
584
|
+
|
585
|
+
#{colorize(:cyan, 'Usage')}
|
586
|
+
bolt plan new <plan name> [options]
|
587
|
+
|
588
|
+
#{colorize(:cyan, 'Description')}
|
589
|
+
Create a new plan in the current project.
|
590
|
+
|
591
|
+
#{colorize(:cyan, 'Documentation')}
|
592
|
+
Learn more about Bolt plans at https://pup.pt/bolt-plans.
|
593
|
+
|
594
|
+
#{colorize(:cyan, 'Examples')}
|
595
|
+
bolt plan new myproject::myplan
|
596
|
+
HELP
|
597
|
+
|
598
|
+
PLAN_RUN_HELP = <<~HELP
|
599
|
+
#{colorize(:cyan, 'Name')}
|
600
|
+
plan run
|
601
|
+
|
602
|
+
#{colorize(:cyan, 'Usage')}
|
603
|
+
bolt plan run <plan name> [parameters] [options]
|
604
|
+
|
605
|
+
#{colorize(:cyan, 'Description')}
|
606
|
+
Run a plan on the specified targets.
|
607
|
+
|
608
|
+
#{colorize(:cyan, 'Documentation')}
|
609
|
+
Learn more about Bolt plans at https://pup.pt/bolt-plans.
|
610
|
+
|
611
|
+
#{colorize(:cyan, 'Examples')}
|
612
|
+
bolt plan run canary --targets target1,target2 command=hostname
|
613
|
+
HELP
|
614
|
+
|
615
|
+
PLAN_SHOW_HELP = <<~HELP
|
616
|
+
#{colorize(:cyan, 'Name')}
|
617
|
+
plan show
|
618
|
+
|
619
|
+
#{colorize(:cyan, 'Usage')}
|
620
|
+
bolt plan show [plan name] [options]
|
621
|
+
|
622
|
+
#{colorize(:cyan, 'Description')}
|
623
|
+
Show available plans and plan documentation.
|
624
|
+
|
625
|
+
Omitting the name of a plan will display a list of plans available
|
626
|
+
in the Bolt project.
|
627
|
+
|
628
|
+
Providing the name of a plan will display detailed documentation for
|
629
|
+
the plan, including a list of available parameters.
|
630
|
+
|
631
|
+
#{colorize(:cyan, 'Documentation')}
|
632
|
+
Learn more about Bolt plans at https://pup.pt/bolt-plans.
|
633
|
+
|
634
|
+
#{colorize(:cyan, 'Examples')}
|
635
|
+
Display a list of available plans
|
636
|
+
bolt plan show
|
637
|
+
Display documentation for the aggregate::count plan
|
638
|
+
bolt plan show aggregate::count
|
639
|
+
HELP
|
640
|
+
|
641
|
+
PLUGIN_HELP = <<~HELP
|
642
|
+
#{colorize(:cyan, 'Name')}
|
643
|
+
plugin
|
644
|
+
|
645
|
+
#{colorize(:cyan, 'Usage')}
|
646
|
+
bolt plugin <action> [options]
|
647
|
+
|
648
|
+
#{colorize(:cyan, 'Description')}
|
649
|
+
Show available plugins.
|
650
|
+
|
651
|
+
#{colorize(:cyan, 'Documentation')}
|
652
|
+
Learn more about Bolt plugins at https://pup.pt/bolt-plugins.
|
653
|
+
|
654
|
+
#{colorize(:cyan, 'Actions')}
|
655
|
+
show Show available plugins
|
656
|
+
HELP
|
657
|
+
|
658
|
+
PLUGIN_SHOW_HELP = <<~HELP
|
659
|
+
#{colorize(:cyan, 'Name')}
|
660
|
+
plugin show
|
661
|
+
|
662
|
+
#{colorize(:cyan, 'Usage')}
|
663
|
+
bolt plugin show [options]
|
664
|
+
|
665
|
+
#{colorize(:cyan, 'Description')}
|
666
|
+
Show available plugins.
|
667
|
+
|
668
|
+
#{colorize(:cyan, 'Documentation')}
|
669
|
+
Learn more about Bolt plugins at https://pup.pt/bolt-plugins.
|
670
|
+
HELP
|
671
|
+
|
672
|
+
POLICY_HELP = <<~HELP
|
673
|
+
#{colorize(:cyan, 'Name')}
|
674
|
+
policy
|
675
|
+
|
676
|
+
#{colorize(:cyan, 'Usage')}
|
677
|
+
bolt policy <action> [options]
|
678
|
+
|
679
|
+
#{colorize(:cyan, 'Description')}
|
680
|
+
Apply, create, and show policies.
|
681
|
+
|
682
|
+
#{colorize(:cyan, 'Actions')}
|
683
|
+
apply Apply a policy to the specified targets
|
684
|
+
new Create a new policy in the current project
|
685
|
+
show Show available policy
|
686
|
+
HELP
|
687
|
+
|
688
|
+
POLICY_APPLY_HELP = <<~HELP
|
689
|
+
#{colorize(:cyan, 'Name')}
|
690
|
+
policy apply
|
691
|
+
|
692
|
+
#{colorize(:cyan, 'Usage')}
|
693
|
+
bolt policy apply <policy> [options]
|
694
|
+
|
695
|
+
#{colorize(:cyan, 'Description')}
|
696
|
+
Apply a policy to the specified targets.
|
697
|
+
HELP
|
698
|
+
|
699
|
+
POLICY_NEW_HELP = <<~HELP
|
700
|
+
#{colorize(:cyan, 'Name')}
|
701
|
+
policy new
|
702
|
+
|
703
|
+
#{colorize(:cyan, 'Usage')}
|
704
|
+
bolt policy new <policy> [options]
|
705
|
+
|
706
|
+
#{colorize(:cyan, 'Description')}
|
707
|
+
Create a new policy in the current project.
|
708
|
+
HELP
|
709
|
+
|
710
|
+
POLICY_SHOW_HELP = <<~HELP
|
711
|
+
#{colorize(:cyan, 'Name')}
|
712
|
+
policy show
|
713
|
+
|
714
|
+
#{colorize(:cyan, 'Usage')}
|
715
|
+
bolt policy show [options]
|
716
|
+
|
717
|
+
#{colorize(:cyan, 'Description')}
|
718
|
+
Show available policies.
|
719
|
+
HELP
|
720
|
+
|
721
|
+
PROJECT_HELP = <<~HELP
|
722
|
+
#{colorize(:cyan, 'Name')}
|
723
|
+
project
|
724
|
+
|
725
|
+
#{colorize(:cyan, 'Usage')}
|
726
|
+
bolt project <action> [options]
|
727
|
+
|
728
|
+
#{colorize(:cyan, 'Description')}
|
729
|
+
Create and migrate Bolt projects
|
730
|
+
|
731
|
+
#{colorize(:cyan, 'Documentation')}
|
732
|
+
To learn more about Bolt projects, run 'bolt guide project'.
|
733
|
+
|
734
|
+
#{colorize(:cyan, 'Actions')}
|
735
|
+
init Create a new Bolt project
|
736
|
+
migrate Migrate a Bolt project to the latest version
|
737
|
+
HELP
|
738
|
+
|
739
|
+
PROJECT_INIT_HELP = <<~HELP
|
740
|
+
#{colorize(:cyan, 'Name')}
|
741
|
+
project init
|
742
|
+
|
743
|
+
#{colorize(:cyan, 'Usage')}
|
744
|
+
bolt project init [name] [options]
|
745
|
+
|
746
|
+
#{colorize(:cyan, 'Description')}
|
747
|
+
Create a new Bolt project in the current working directory.
|
748
|
+
|
749
|
+
Specify a name for the Bolt project. Defaults to the basename of the current working directory.
|
750
|
+
|
751
|
+
#{colorize(:cyan, 'Documentation')}
|
752
|
+
To learn more about Bolt projects, run 'bolt guide project'.
|
753
|
+
|
754
|
+
#{colorize(:cyan, 'Examples')}
|
755
|
+
Create a new Bolt project using the directory as the project name.
|
756
|
+
bolt project init
|
757
|
+
Create a new Bolt project with a specified name.
|
758
|
+
bolt project init myproject
|
759
|
+
Create a new Bolt project with existing modules.
|
760
|
+
bolt project init --modules puppetlabs-apt,puppetlabs-ntp
|
761
|
+
HELP
|
762
|
+
|
763
|
+
PROJECT_MIGRATE_HELP = <<~HELP
|
764
|
+
#{colorize(:cyan, 'Name')}
|
765
|
+
project migrate
|
766
|
+
|
767
|
+
#{colorize(:cyan, 'Usage')}
|
768
|
+
bolt project migrate [options]
|
769
|
+
|
770
|
+
#{colorize(:cyan, 'Description')}
|
771
|
+
Migrate a Bolt project to use current best practices and the latest version of
|
772
|
+
configuration files.
|
773
|
+
|
774
|
+
#{colorize(:cyan, 'Documentation')}
|
775
|
+
To learn more about Bolt projects, run 'bolt guide project'.
|
776
|
+
HELP
|
777
|
+
|
778
|
+
SCRIPT_HELP = <<~HELP
|
779
|
+
#{colorize(:cyan, 'Name')}
|
780
|
+
script
|
781
|
+
|
782
|
+
#{colorize(:cyan, 'Usage')}
|
783
|
+
bolt script <action> [options]
|
784
|
+
|
785
|
+
#{colorize(:cyan, 'Description')}
|
786
|
+
Run a script on the specified targets.
|
787
|
+
|
788
|
+
#{colorize(:cyan, 'Documentation')}
|
789
|
+
Learn more about running scripts at https://pup.pt/bolt-commands.
|
790
|
+
|
791
|
+
#{colorize(:cyan, 'Actions')}
|
792
|
+
run Run a script on the specified targets.
|
793
|
+
HELP
|
794
|
+
|
795
|
+
SCRIPT_RUN_HELP = <<~HELP
|
796
|
+
#{colorize(:cyan, 'Name')}
|
797
|
+
script run
|
798
|
+
|
799
|
+
#{colorize(:cyan, 'Usage')}
|
800
|
+
bolt script run <script> [arguments] {--targets TARGETS | --query QUERY | --rerun FILTER}
|
801
|
+
[options]
|
802
|
+
|
803
|
+
#{colorize(:cyan, 'Description')}
|
804
|
+
Run a script on the specified targets.
|
805
|
+
|
806
|
+
Arguments passed to a script are passed literally and are not interpolated
|
807
|
+
by the shell. Any arguments containing spaces or special characters should
|
808
|
+
be quoted.
|
809
|
+
|
810
|
+
#{colorize(:cyan, 'Documentation')}
|
811
|
+
Learn more about running scripts at https://pup.pt/bolt-commands.
|
812
|
+
|
813
|
+
#{colorize(:cyan, 'Examples')}
|
814
|
+
bolt script run myscript.sh 'echo hello' --targets target1,target2
|
815
|
+
HELP
|
816
|
+
|
817
|
+
SECRET_HELP = <<~HELP
|
818
|
+
#{colorize(:cyan, 'Name')}
|
819
|
+
secret
|
820
|
+
|
821
|
+
#{colorize(:cyan, 'Usage')}
|
822
|
+
bolt secret <action> [options]
|
823
|
+
|
824
|
+
#{colorize(:cyan, 'Description')}
|
825
|
+
Create encryption keys and encrypt and decrypt values.
|
826
|
+
|
827
|
+
#{colorize(:cyan, 'Documentation')}
|
828
|
+
Learn more about secrets plugins at http://pup.pt/bolt-plugins.
|
829
|
+
|
830
|
+
#{colorize(:cyan, 'Actions')}
|
831
|
+
createkeys Create new encryption keys
|
832
|
+
encrypt Encrypt a value
|
833
|
+
decrypt Decrypt a value
|
834
|
+
HELP
|
835
|
+
|
836
|
+
SECRET_CREATEKEYS_HELP = <<~HELP
|
837
|
+
#{colorize(:cyan, 'Name')}
|
838
|
+
secret createkeys
|
839
|
+
|
840
|
+
#{colorize(:cyan, 'Usage')}
|
841
|
+
bolt secret createkeys [options]
|
842
|
+
|
843
|
+
#{colorize(:cyan, 'Description')}
|
844
|
+
Create new encryption keys.
|
845
|
+
|
846
|
+
#{colorize(:cyan, 'Documentation')}
|
847
|
+
Learn more about secrets plugins at http://pup.pt/bolt-plugins.
|
848
|
+
HELP
|
849
|
+
|
850
|
+
SECRET_DECRYPT_HELP = <<~HELP
|
851
|
+
#{colorize(:cyan, 'Name')}
|
852
|
+
secret decrypt
|
853
|
+
|
854
|
+
#{colorize(:cyan, 'Usage')}
|
855
|
+
bolt secret decrypt <ciphertext> [options]
|
856
|
+
|
857
|
+
#{colorize(:cyan, 'Description')}
|
858
|
+
Decrypt a value.
|
859
|
+
|
860
|
+
#{colorize(:cyan, 'Documentation')}
|
861
|
+
Learn more about secrets plugins at http://pup.pt/bolt-plugins.
|
862
|
+
HELP
|
863
|
+
|
864
|
+
SECRET_ENCRYPT_HELP = <<~HELP
|
865
|
+
#{colorize(:cyan, 'Name')}
|
866
|
+
secret encrypt
|
867
|
+
|
868
|
+
#{colorize(:cyan, 'Usage')}
|
869
|
+
bolt secret encrypt <plaintext> [options]
|
870
|
+
|
871
|
+
#{colorize(:cyan, 'Description')}
|
872
|
+
Encrypt a value.
|
873
|
+
|
874
|
+
#{colorize(:cyan, 'Documentation')}
|
875
|
+
Learn more about secrets plugins at http://pup.pt/bolt-plugins.
|
876
|
+
HELP
|
877
|
+
|
878
|
+
TASK_HELP = <<~HELP
|
879
|
+
#{colorize(:cyan, 'Name')}
|
880
|
+
task
|
881
|
+
|
882
|
+
#{colorize(:cyan, 'Usage')}
|
883
|
+
bolt task <action> [options]
|
884
|
+
|
885
|
+
#{colorize(:cyan, 'Description')}
|
886
|
+
Show and run Bolt tasks.
|
887
|
+
|
888
|
+
#{colorize(:cyan, 'Documentation')}
|
889
|
+
Learn more about Bolt tasks at http://pup.pt/bolt-tasks.
|
890
|
+
|
891
|
+
#{colorize(:cyan, 'Actions')}
|
892
|
+
run Run a Bolt task
|
893
|
+
show Show available tasks and task documentation
|
894
|
+
HELP
|
895
|
+
|
896
|
+
TASK_RUN_HELP = <<~HELP
|
897
|
+
#{colorize(:cyan, 'Name')}
|
898
|
+
task run
|
899
|
+
|
900
|
+
#{colorize(:cyan, 'Usage')}
|
901
|
+
bolt task run <task name> [parameters] {--targets TARGETS | --query QUERY | --rerun FILTER}
|
902
|
+
[options]
|
903
|
+
|
904
|
+
#{colorize(:cyan, 'Description')}
|
905
|
+
Run a task on the specified targets.
|
906
|
+
|
907
|
+
Parameters take the form parameter=value.
|
908
|
+
|
909
|
+
#{colorize(:cyan, 'Documentation')}
|
910
|
+
Learn more about Bolt tasks at http://pup.pt/bolt-tasks.
|
911
|
+
|
912
|
+
#{colorize(:cyan, 'Examples')}
|
913
|
+
bolt task run package --targets target1,target2 action=status name=bash
|
914
|
+
HELP
|
915
|
+
|
916
|
+
TASK_SHOW_HELP = <<~HELP
|
917
|
+
#{colorize(:cyan, 'Name')}
|
918
|
+
task show
|
919
|
+
|
920
|
+
#{colorize(:cyan, 'Usage')}
|
921
|
+
bolt task show [task name] [options]
|
922
|
+
|
923
|
+
#{colorize(:cyan, 'Description')}
|
924
|
+
Show available tasks and task documentation.
|
925
|
+
|
926
|
+
Omitting the name of a task will display a list of tasks available
|
927
|
+
in the Bolt project.
|
928
|
+
|
929
|
+
Providing the name of a task will display detailed documentation for
|
930
|
+
the task, including a list of available parameters.
|
931
|
+
|
932
|
+
#{colorize(:cyan, 'Documentation')}
|
933
|
+
Learn more about Bolt tasks at http://pup.pt/bolt-tasks.
|
934
|
+
|
935
|
+
#{colorize(:cyan, 'Examples')}
|
936
|
+
Display a list of available tasks
|
937
|
+
bolt task show
|
938
|
+
Display documentation for the canary task
|
939
|
+
bolt task show canary
|
940
|
+
HELP
|
941
|
+
|
942
|
+
def initialize(options)
|
943
|
+
super()
|
944
|
+
|
945
|
+
@options = options
|
946
|
+
|
947
|
+
separator "\n#{self.class.colorize(:cyan, 'Inventory options')}"
|
948
|
+
define('-t', '--targets TARGETS', 'Identifies the targets of the command.',
|
949
|
+
"For more information, see 'bolt guide targets'.") do |targets|
|
950
|
+
@options[:targets] ||= []
|
951
|
+
@options[:targets] << Bolt::Util.get_arg_input(targets)
|
952
|
+
end
|
953
|
+
define('-q', '--query QUERY', 'Query PuppetDB to determine the targets.') do |query|
|
954
|
+
@options[:query] = query
|
955
|
+
end
|
956
|
+
define("--rerun FILTER", "Retry on targets from the last run.",
|
957
|
+
"Available filters are 'all', 'failure', and 'success'.") do |rerun|
|
958
|
+
@options[:rerun] = rerun
|
959
|
+
end
|
960
|
+
define('--noop', 'See what changes Bolt will make without actually executing the changes.') do |_|
|
961
|
+
@options[:noop] = true
|
962
|
+
end
|
963
|
+
define('--params PARAMETERS',
|
964
|
+
"Parameters to a task or plan as json, a json file '@<file>', or on stdin '-'.") do |params|
|
965
|
+
@options[:params] = parse_params(params)
|
966
|
+
end
|
967
|
+
define('-e', '--execute CODE',
|
968
|
+
"Puppet manifest code to apply to the targets.") do |code|
|
969
|
+
@options[:code] = code
|
970
|
+
end
|
971
|
+
define('--detail', 'Show resolved configuration for the targets.') do |detail|
|
972
|
+
@options[:detail] = detail
|
973
|
+
end
|
974
|
+
|
975
|
+
separator "\n#{self.class.colorize(:cyan, 'Authentication options')}"
|
976
|
+
define('-u', '--user USER', 'User to authenticate as.') do |user|
|
977
|
+
@options[:user] = user
|
978
|
+
end
|
979
|
+
define('-p', '--password PASSWORD',
|
980
|
+
'Password to authenticate with.') do |password|
|
981
|
+
@options[:password] = password
|
982
|
+
end
|
983
|
+
define('--password-prompt', 'Prompt for user to input password.') do |_password|
|
984
|
+
$stderr.print "Please enter your password: "
|
985
|
+
@options[:password] = $stdin.noecho(&:gets).chomp
|
986
|
+
$stderr.puts
|
987
|
+
end
|
988
|
+
define('--private-key KEY', 'Path to private ssh key to authenticate with.') do |key|
|
989
|
+
@options[:'private-key'] = File.expand_path(key)
|
990
|
+
end
|
991
|
+
define('--[no-]host-key-check', 'Check host keys with SSH.') do |host_key_check|
|
992
|
+
@options[:'host-key-check'] = host_key_check
|
993
|
+
end
|
994
|
+
define('--[no-]ssl', 'Use SSL with WinRM.') do |ssl|
|
995
|
+
@options[:ssl] = ssl
|
996
|
+
end
|
997
|
+
define('--[no-]ssl-verify', 'Verify remote host SSL certificate with WinRM.') do |ssl_verify|
|
998
|
+
@options[:'ssl-verify'] = ssl_verify
|
999
|
+
end
|
1000
|
+
|
1001
|
+
separator "\n#{self.class.colorize(:cyan, 'Escalation options')}"
|
1002
|
+
define('--run-as USER', 'User to run as using privilege escalation.') do |user|
|
1003
|
+
@options[:'run-as'] = user
|
1004
|
+
end
|
1005
|
+
define('--sudo-password PASSWORD',
|
1006
|
+
'Password for privilege escalation.') do |password|
|
1007
|
+
@options[:'sudo-password'] = password
|
1008
|
+
end
|
1009
|
+
define('--sudo-password-prompt', 'Prompt for user to input escalation password.') do |_password|
|
1010
|
+
$stderr.print "Please enter your privilege escalation password: "
|
1011
|
+
@options[:'sudo-password'] = $stdin.noecho(&:gets).chomp
|
1012
|
+
$stderr.puts
|
1013
|
+
end
|
1014
|
+
define('--sudo-executable EXEC', "Experimental. Specify an executable for running as another user.") do |exec|
|
1015
|
+
@options[:'sudo-executable'] = exec
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
separator "\n#{self.class.colorize(:cyan, 'Run context options')}"
|
1019
|
+
define('-c', '--concurrency CONCURRENCY', Integer,
|
1020
|
+
'Maximum number of simultaneous connections.') do |concurrency|
|
1021
|
+
@options[:concurrency] = concurrency
|
1022
|
+
end
|
1023
|
+
define('--compile-concurrency CONCURRENCY', Integer,
|
1024
|
+
'Maximum number of simultaneous manifest block compiles (default: number of cores).') do |concurrency|
|
1025
|
+
@options[:'compile-concurrency'] = concurrency
|
1026
|
+
end
|
1027
|
+
define('--[no-]cleanup',
|
1028
|
+
'Whether to clean up temporary files created on targets.') do |cleanup|
|
1029
|
+
@options[:cleanup] = cleanup
|
1030
|
+
end
|
1031
|
+
define('-m', '--modulepath MODULES',
|
1032
|
+
"List of directories containing modules, separated by '#{File::PATH_SEPARATOR}'",
|
1033
|
+
'Directories are case-sensitive.') do |modulepath|
|
1034
|
+
# When specified from the CLI, modulepath entries are relative to pwd
|
1035
|
+
@options[:modulepath] = modulepath.split(File::PATH_SEPARATOR).map do |moduledir|
|
1036
|
+
File.expand_path(moduledir)
|
1037
|
+
end
|
1038
|
+
end
|
1039
|
+
define('--project PATH',
|
1040
|
+
'Path to load the Bolt project from (default: autodiscovered from current dir).') do |path|
|
1041
|
+
@options[:project] = path
|
1042
|
+
end
|
1043
|
+
define('--hiera-config PATH',
|
1044
|
+
'Specify where to load Hiera config from (default: <project>/hiera.yaml).') do |path|
|
1045
|
+
@options[:'hiera-config'] = File.expand_path(path)
|
1046
|
+
end
|
1047
|
+
define('-i', '--inventoryfile PATH',
|
1048
|
+
'Specify where to load inventory from (default: <project>/inventory.yaml).') do |path|
|
1049
|
+
if ENV.include?(Bolt::Inventory::ENVIRONMENT_VAR)
|
1050
|
+
raise Bolt::CLIError, "Cannot pass inventory file when #{Bolt::Inventory::ENVIRONMENT_VAR} is set"
|
1051
|
+
end
|
1052
|
+
@options[:inventoryfile] = File.expand_path(path)
|
1053
|
+
end
|
1054
|
+
define('--[no-]save-rerun', 'Whether to update the rerun file after this command.') do |save|
|
1055
|
+
@options[:'save-rerun'] = save
|
1056
|
+
end
|
1057
|
+
define('--puppetdb INSTANCE', 'The named PuppetDB instance to connect to by default.') do |instance|
|
1058
|
+
@options[:default_puppetdb] = instance
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
separator "\n#{self.class.colorize(:cyan, 'Remote environment options')}"
|
1062
|
+
define('--env-var ENVIRONMENT_VARIABLES', 'Environment variables to set on the target.') do |envvar|
|
1063
|
+
unless envvar.include?('=')
|
1064
|
+
raise Bolt::CLIError, "Environment variables must be specified using 'myenvvar=key' format"
|
1065
|
+
end
|
1066
|
+
@options[:env_vars] ||= {}
|
1067
|
+
@options[:env_vars].store(*envvar.split('=', 2))
|
1068
|
+
end
|
1069
|
+
|
1070
|
+
separator "\n#{self.class.colorize(:cyan, 'Transport options')}"
|
1071
|
+
define('--transport TRANSPORT', TRANSPORTS.keys.map(&:to_s),
|
1072
|
+
"Specify a default transport: #{TRANSPORTS.keys.join(', ')}.",
|
1073
|
+
"For more information, see 'bolt guide transports'.") do |t|
|
1074
|
+
@options[:transport] = t
|
1075
|
+
end
|
1076
|
+
define('--[no-]native-ssh',
|
1077
|
+
'Experimental. Whether to shell out to native SSH or use the net-ssh Ruby library.') do |bool|
|
1078
|
+
@options[:'native-ssh'] = bool
|
1079
|
+
end
|
1080
|
+
define('--ssh-command EXEC', "Experimental. Executable to use instead of the net-ssh Ruby library.") do |exec|
|
1081
|
+
@options[:'ssh-command'] = exec
|
1082
|
+
end
|
1083
|
+
define('--copy-command EXEC',
|
1084
|
+
"Experimental. Command to copy files to remote hosts if using native SSH.") do |exec|
|
1085
|
+
@options[:'copy-command'] = exec
|
1086
|
+
end
|
1087
|
+
define('--connect-timeout TIMEOUT', Integer, 'Connection timeout in seconds (defaults vary).') do |timeout|
|
1088
|
+
@options[:'connect-timeout'] = timeout
|
1089
|
+
end
|
1090
|
+
define('--[no-]tty', 'Request a pseudo TTY on targets that support it.') do |tty|
|
1091
|
+
@options[:tty] = tty
|
1092
|
+
end
|
1093
|
+
define('--tmpdir DIR', 'The directory to upload and execute temporary files on the target.') do |tmpdir|
|
1094
|
+
@options[:tmpdir] = tmpdir
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
separator "\n#{self.class.colorize(:cyan, 'Module options')}"
|
1098
|
+
define('--[no-]resolve',
|
1099
|
+
'Use --no-resolve to install modules listed in the Puppetfile without resolving modules configured',
|
1100
|
+
'in Bolt project configuration.') do |resolve|
|
1101
|
+
@options[:resolve] = resolve
|
1102
|
+
end
|
1103
|
+
|
1104
|
+
separator "\n#{self.class.colorize(:cyan, 'Lookup options')}"
|
1105
|
+
define('--plan-hierarchy', 'Look up a value with Hiera in the context of a specific plan.') do |_|
|
1106
|
+
@options[:plan_hierarchy] = true
|
1107
|
+
end
|
1108
|
+
|
1109
|
+
separator "\n#{self.class.colorize(:cyan, 'Plan options')}"
|
1110
|
+
define('--pp', 'Create a new Puppet language plan.') do |_|
|
1111
|
+
@options[:puppet] = true
|
1112
|
+
end
|
1113
|
+
define('--script SCRIPT', 'Create a new plan that wraps a script.') do |path|
|
1114
|
+
# If the path is a relative, absolute, or not a scripts path, raise an
|
1115
|
+
# error. This flag is intended to be used to create shareable plans.
|
1116
|
+
#
|
1117
|
+
# This also limits valid mounts to files and scripts, which we may want
|
1118
|
+
# to expand in the future.
|
1119
|
+
if File.exist?(path) || Pathname.new(path).absolute? ||
|
1120
|
+
!%w[scripts files].include?(path.split(File::SEPARATOR)[1])
|
1121
|
+
raise Bolt::CLIError, "The script must be a detailed Puppet file reference, " \
|
1122
|
+
"for example 'mymodule/scripts/myscript.sh'. See http://pup.pt/bolt-scripts for " \
|
1123
|
+
"more information on detailed Puppet file references."
|
1124
|
+
end
|
1125
|
+
|
1126
|
+
@options[:plan_script] = path
|
1127
|
+
end
|
1128
|
+
|
1129
|
+
separator "\n#{self.class.colorize(:cyan, 'Display options')}"
|
1130
|
+
define('--filter FILTER', 'Filter tasks and plans by a matching substring.') do |filter|
|
1131
|
+
unless /^[a-z0-9_:]+$/.match(filter)
|
1132
|
+
msg = "Illegal characters in filter string '#{filter}'. Filters can "\
|
1133
|
+
"only include lowercase letters, numbers, underscores, and colons."
|
1134
|
+
raise Bolt::CLIError, msg
|
1135
|
+
end
|
1136
|
+
@options[:filter] = filter
|
1137
|
+
end
|
1138
|
+
define('--format FORMAT', 'Output format to use: human, json, or rainbow.') do |format|
|
1139
|
+
@options[:format] = format
|
1140
|
+
end
|
1141
|
+
define('--[no-]color', 'Whether to show output in color.') do |color|
|
1142
|
+
@options[:color] = color
|
1143
|
+
end
|
1144
|
+
define('-v', '--[no-]verbose', 'Display verbose logging.') do |value|
|
1145
|
+
@options[:verbose] = value
|
1146
|
+
end
|
1147
|
+
define('--stream',
|
1148
|
+
'Stream output from scripts and commands to the console.',
|
1149
|
+
'Run with --no-verbose to prevent Bolt from displaying output',
|
1150
|
+
'a second time after the action is completed.') do |_|
|
1151
|
+
@options[:stream] = true
|
1152
|
+
end
|
1153
|
+
define('--trace', 'Display error stack traces.') do |_|
|
1154
|
+
@options[:trace] = true
|
1155
|
+
end
|
1156
|
+
|
1157
|
+
separator "\n#{self.class.colorize(:cyan, 'Additional options')}"
|
1158
|
+
define('--modules MODULES',
|
1159
|
+
'A comma-separated list of modules to install from the Puppet Forge',
|
1160
|
+
'when initializing a project. Resolves and installs all dependencies.') do |modules|
|
1161
|
+
@options[:modules] = modules.split(',').map { |mod| { 'name' => mod } }
|
1162
|
+
end
|
1163
|
+
define('--force', 'Force a destructive action.') do |_force|
|
1164
|
+
@options[:force] = true
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
separator "\n#{self.class.colorize(:cyan, 'Global options')}"
|
1168
|
+
define('-h', '--help', 'Display help.') do |_|
|
1169
|
+
@options[:help] = true
|
1170
|
+
end
|
1171
|
+
define('--version', 'Display the version.') do |_|
|
1172
|
+
@options[:version] = true
|
1173
|
+
end
|
1174
|
+
define('--log-level LEVEL',
|
1175
|
+
"Set the log level for the console. Available options are",
|
1176
|
+
"trace, debug, info, warn, error, fatal.") do |level|
|
1177
|
+
@options[:log] = { 'console' => { 'level' => level } }
|
1178
|
+
end
|
1179
|
+
define('--clear-cache',
|
1180
|
+
"Clear plugin, plan, and task caches before executing.") do |_|
|
1181
|
+
@options[:clear_cache] = true
|
1182
|
+
end
|
1183
|
+
define('--plugin PLUGIN', 'Select the plugin to use.') do |plug|
|
1184
|
+
@options[:plugin] = plug
|
1185
|
+
end
|
1186
|
+
end
|
1187
|
+
|
1188
|
+
def remove_excluded_opts(option_list)
|
1189
|
+
# Remove any options that are not available for the specified subcommand
|
1190
|
+
top.list.delete_if do |opt|
|
1191
|
+
opt.respond_to?(:switch_name) && !option_list.include?(opt.switch_name)
|
1192
|
+
end
|
1193
|
+
# Remove any separators if all options of that type have been removed
|
1194
|
+
top.list.delete_if do |opt|
|
1195
|
+
i = top.list.index(opt)
|
1196
|
+
opt.is_a?(String) && top.list[i + 1].is_a?(String)
|
1197
|
+
end
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
def update
|
1201
|
+
help_text = get_help_text(@options[:subcommand], @options[:action])
|
1202
|
+
# Update the banner according to the subcommand
|
1203
|
+
self.banner = help_text[:banner]
|
1204
|
+
# Builds the option list for the specified subcommand and removes all excluded
|
1205
|
+
# options from the help text
|
1206
|
+
remove_excluded_opts(help_text[:flags])
|
1207
|
+
end
|
1208
|
+
|
1209
|
+
def parse_params(params)
|
1210
|
+
json = Bolt::Util.get_arg_input(params)
|
1211
|
+
JSON.parse(json)
|
1212
|
+
rescue JSON::ParserError => e
|
1213
|
+
raise Bolt::CLIError, "Unable to parse --params value as JSON: #{e}"
|
1214
|
+
end
|
1215
|
+
|
1216
|
+
def permute(args)
|
1217
|
+
super(args)
|
1218
|
+
rescue OptionParser::MissingArgument => e
|
1219
|
+
raise Bolt::CLIError, "Option '#{e.args.first}' needs a parameter"
|
1220
|
+
rescue OptionParser::InvalidArgument => e
|
1221
|
+
raise Bolt::CLIError, "Invalid parameter specified for option '#{e.args.first}': #{e.args[1]}"
|
1222
|
+
rescue OptionParser::InvalidOption, OptionParser::AmbiguousOption => e
|
1223
|
+
raise Bolt::CLIError, "Unknown argument '#{e.args.first}'"
|
1224
|
+
end
|
1225
|
+
end
|
1226
|
+
end
|