openbolt 5.0.0.rc1 → 5.1.0
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 +4 -4
- data/Puppetfile +18 -12
- data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +5 -3
- data/bolt-modules/boltlib/lib/puppet/functions/download_file.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_resources.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_command.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_container.rb +2 -2
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_resources.rb +2 -2
- data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/wait.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +1 -0
- data/bolt-modules/ctrl/lib/puppet/functions/ctrl/do_until.rb +1 -0
- data/lib/bolt/analytics.rb +1 -1
- data/lib/bolt/application.rb +17 -22
- data/lib/bolt/applicator.rb +4 -0
- data/lib/bolt/bolt_option_parser.rb +10 -8
- data/lib/bolt/cli.rb +7 -6
- data/lib/bolt/config/options.rb +59 -67
- data/lib/bolt/config/transport/base.rb +1 -0
- data/lib/bolt/config/transport/options.rb +59 -59
- data/lib/bolt/config.rb +8 -6
- data/lib/bolt/executor.rb +9 -24
- data/lib/bolt/fiber_executor.rb +3 -1
- data/lib/bolt/inventory/group.rb +3 -0
- data/lib/bolt/inventory/inventory.rb +2 -0
- data/lib/bolt/inventory/options.rb +7 -7
- data/lib/bolt/inventory/target.rb +3 -2
- data/lib/bolt/inventory.rb +1 -0
- data/lib/bolt/logger.rb +2 -0
- data/lib/bolt/module.rb +1 -0
- data/lib/bolt/module_installer/puppetfile.rb +4 -4
- data/lib/bolt/module_installer/resolver.rb +2 -2
- data/lib/bolt/module_installer/specs/forge_spec.rb +4 -4
- data/lib/bolt/module_installer/specs/git_spec.rb +6 -6
- data/lib/bolt/module_installer/specs/id/gitclone.rb +1 -0
- data/lib/bolt/module_installer/specs/id/github.rb +2 -1
- data/lib/bolt/module_installer/specs/id/gitlab.rb +2 -1
- data/lib/bolt/module_installer.rb +3 -1
- data/lib/bolt/outputter/human.rb +9 -4
- data/lib/bolt/outputter/rainbow.rb +1 -0
- data/lib/bolt/pal/yaml_plan/parameter.rb +2 -2
- data/lib/bolt/pal/yaml_plan/step/resources.rb +1 -1
- data/lib/bolt/pal.rb +7 -4
- data/lib/bolt/plan_creator.rb +5 -4
- data/lib/bolt/plugin/cache.rb +2 -0
- data/lib/bolt/plugin/module.rb +7 -0
- data/lib/bolt/plugin/puppet_connect_data.rb +1 -0
- data/lib/bolt/plugin/task.rb +3 -0
- data/lib/bolt/plugin.rb +4 -0
- data/lib/bolt/project.rb +3 -3
- data/lib/bolt/project_manager/config_migrator.rb +3 -3
- data/lib/bolt/project_manager/inventory_migrator.rb +1 -1
- data/lib/bolt/project_manager/module_migrator.rb +7 -6
- data/lib/bolt/project_manager.rb +11 -11
- data/lib/bolt/puppetdb/config.rb +4 -0
- data/lib/bolt/puppetdb/instance.rb +1 -0
- data/lib/bolt/rerun.rb +1 -0
- data/lib/bolt/resource_instance.rb +1 -1
- data/lib/bolt/result.rb +2 -1
- data/lib/bolt/shell/bash.rb +2 -1
- data/lib/bolt/shell/powershell.rb +4 -3
- data/lib/bolt/shell.rb +1 -1
- data/lib/bolt/task/run.rb +1 -0
- data/lib/bolt/task.rb +3 -0
- data/lib/bolt/transport/docker/connection.rb +2 -0
- data/lib/bolt/transport/jail/connection.rb +2 -0
- data/lib/bolt/transport/lxd/connection.rb +2 -0
- data/lib/bolt/transport/lxd.rb +1 -1
- data/lib/bolt/transport/podman/connection.rb +2 -0
- data/lib/bolt/transport/remote.rb +1 -0
- data/lib/bolt/transport/ssh/connection.rb +1 -1
- data/lib/bolt/transport/winrm/connection.rb +4 -3
- data/lib/bolt/util/format.rb +1 -0
- data/lib/bolt/util.rb +7 -4
- data/lib/bolt/validator.rb +1 -1
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_spec/plans/action_stubs.rb +5 -0
- data/lib/bolt_spec/plans/mock_executor.rb +2 -4
- data/libexec/apply_catalog.rb +2 -1
- data/libexec/custom_facts.rb +1 -1
- data/libexec/query_resources.rb +1 -1
- metadata +63 -77
- data/lib/bolt/config/transport/orch.rb +0 -41
- data/lib/bolt/transport/orch/connection.rb +0 -111
- data/lib/bolt/transport/orch.rb +0 -271
- data/lib/bolt_server/acl.rb +0 -39
- data/lib/bolt_server/base_config.rb +0 -112
- data/lib/bolt_server/config.rb +0 -64
- data/lib/bolt_server/file_cache.rb +0 -200
- data/lib/bolt_server/request_error.rb +0 -11
- data/lib/bolt_server/schemas/action-check_node_connections.json +0 -14
- data/lib/bolt_server/schemas/action-run_command.json +0 -12
- data/lib/bolt_server/schemas/action-run_script.json +0 -47
- data/lib/bolt_server/schemas/action-run_task.json +0 -20
- data/lib/bolt_server/schemas/action-upload_file.json +0 -47
- data/lib/bolt_server/schemas/partials/target-any.json +0 -10
- data/lib/bolt_server/schemas/partials/target-ssh.json +0 -88
- data/lib/bolt_server/schemas/partials/target-winrm.json +0 -67
- data/lib/bolt_server/schemas/partials/task.json +0 -94
- data/lib/bolt_server/schemas/transport-ssh.json +0 -25
- data/lib/bolt_server/schemas/transport-winrm.json +0 -19
- data/lib/bolt_server/transport_app.rb +0 -554
data/lib/bolt/plugin/cache.rb
CHANGED
|
@@ -17,6 +17,7 @@ module Bolt
|
|
|
17
17
|
|
|
18
18
|
def read_and_clean_cache
|
|
19
19
|
return if ttl == 0
|
|
20
|
+
|
|
20
21
|
validate
|
|
21
22
|
|
|
22
23
|
# Luckily we don't need to use a serious hash algorithm
|
|
@@ -53,6 +54,7 @@ module Bolt
|
|
|
53
54
|
# The default cache `plugin-cache` will be validated by the config
|
|
54
55
|
# validator
|
|
55
56
|
return if reference['_cache'].nil?
|
|
57
|
+
|
|
56
58
|
r = reference['_cache']
|
|
57
59
|
unless r.is_a?(Hash)
|
|
58
60
|
raise Bolt::ValidationError,
|
data/lib/bolt/plugin/module.rb
CHANGED
|
@@ -67,6 +67,7 @@ module Bolt
|
|
|
67
67
|
|
|
68
68
|
def process_schema(schema)
|
|
69
69
|
raise InvalidPluginData.new('config specification is not an object', name) unless schema.is_a?(Hash)
|
|
70
|
+
|
|
70
71
|
schema.each do |key, val|
|
|
71
72
|
unless key =~ /\A[a-z][a-z0-9_]*\z/
|
|
72
73
|
raise InvalidPluginData.new("config specification key, '#{key}', is not allowed", name)
|
|
@@ -102,6 +103,7 @@ module Bolt
|
|
|
102
103
|
unless spec['pcore_type'].instance?(val)
|
|
103
104
|
raise Bolt::ValidationError, "#{name} plugin expects a #{spec['type']} for key #{key}, got: #{val}"
|
|
104
105
|
end
|
|
106
|
+
|
|
105
107
|
val.nil?
|
|
106
108
|
end
|
|
107
109
|
nil
|
|
@@ -177,8 +179,10 @@ module Bolt
|
|
|
177
179
|
# Get the intersection of expected types (using Set)
|
|
178
180
|
type_set = @hook_map.each_with_object({}) do |(_hook, task), acc|
|
|
179
181
|
next unless (schema = task['task'].metadata['parameters'])
|
|
182
|
+
|
|
180
183
|
schema.each do |param, scheme|
|
|
181
184
|
next unless scheme['type'].is_a?(String)
|
|
185
|
+
|
|
182
186
|
scheme['type'] = Set.new([scheme['type']])
|
|
183
187
|
if acc.dig(param, 'type').is_a?(Set)
|
|
184
188
|
scheme['type'].merge(acc[param]['type'])
|
|
@@ -189,6 +193,7 @@ module Bolt
|
|
|
189
193
|
# Convert Set to string
|
|
190
194
|
type_set.each do |_param, schema|
|
|
191
195
|
next unless schema['type']
|
|
196
|
+
|
|
192
197
|
schema['type'] = if schema['type'].size > 1
|
|
193
198
|
"Optional[Variant[#{schema['type'].to_a.join(', ')}]]"
|
|
194
199
|
else
|
|
@@ -210,6 +215,7 @@ module Bolt
|
|
|
210
215
|
options).first
|
|
211
216
|
|
|
212
217
|
raise Bolt::Error.new(result.error_hash['msg'], result.error_hash['kind']) unless result.ok
|
|
218
|
+
|
|
213
219
|
result.value
|
|
214
220
|
end
|
|
215
221
|
|
|
@@ -217,6 +223,7 @@ module Bolt
|
|
|
217
223
|
hook = @hook_map[hook_name]
|
|
218
224
|
# This shouldn't happen if the Plugin api is used
|
|
219
225
|
raise PluginError::UnsupportedHook.new(name, hook_name) unless hook
|
|
226
|
+
|
|
220
227
|
result = run_task(hook['task'], opts)
|
|
221
228
|
|
|
222
229
|
if value
|
data/lib/bolt/plugin/task.rb
CHANGED
|
@@ -30,16 +30,19 @@ module Bolt
|
|
|
30
30
|
options = { catch_errors: true }
|
|
31
31
|
|
|
32
32
|
raise Bolt::ValidationError, "Task plugin requires that the 'task' is specified" unless opts['task']
|
|
33
|
+
|
|
33
34
|
task = @context.get_validated_task(opts['task'], params)
|
|
34
35
|
|
|
35
36
|
result = @context.run_local_task(task, params, options).first
|
|
36
37
|
|
|
37
38
|
raise Bolt::Error.new(result.error_hash['msg'], result.error_hash['kind']) if result.error_hash
|
|
39
|
+
|
|
38
40
|
result
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
def validate_options(opts)
|
|
42
44
|
raise Bolt::ValidationError, "Task plugin requires that the 'task' is specified" unless opts['task']
|
|
45
|
+
|
|
43
46
|
@context.get_validated_task(opts['task'], opts['parameters'] || {})
|
|
44
47
|
end
|
|
45
48
|
alias validate_resolve_reference validate_options
|
data/lib/bolt/plugin.rb
CHANGED
|
@@ -203,6 +203,7 @@ module Bolt
|
|
|
203
203
|
|
|
204
204
|
def config_for_plugin(plugin_name)
|
|
205
205
|
return {} unless @unresolved_plugin_configs.include?(plugin_name)
|
|
206
|
+
|
|
206
207
|
if @resolution_stack.include?(plugin_name)
|
|
207
208
|
msg = "Configuration for plugin '#{plugin_name}' depends on the plugin itself"
|
|
208
209
|
raise PluginError.new(msg, 'bolt/plugin-error')
|
|
@@ -225,6 +226,7 @@ module Bolt
|
|
|
225
226
|
plugin = by_name(plugin_name)
|
|
226
227
|
raise PluginError::Unknown, plugin_name unless plugin
|
|
227
228
|
raise PluginError::UnsupportedHook.new(plugin_name, hook) unless plugin.hooks.include?(hook)
|
|
229
|
+
|
|
228
230
|
@analytics.report_bundled_content("Plugin #{hook}", plugin_name)
|
|
229
231
|
|
|
230
232
|
plugin.method(hook)
|
|
@@ -260,6 +262,7 @@ module Bolt
|
|
|
260
262
|
when Bolt::Plugin::Module
|
|
261
263
|
plugin.hook_map.each do |hook, spec|
|
|
262
264
|
next unless hooks.include?(hook)
|
|
265
|
+
|
|
263
266
|
hooks[hook][name] = spec['task'].description
|
|
264
267
|
end
|
|
265
268
|
else
|
|
@@ -277,6 +280,7 @@ module Bolt
|
|
|
277
280
|
private def load_all_plugins
|
|
278
281
|
modules.each do |name, mod|
|
|
279
282
|
next unless mod.plugin?
|
|
283
|
+
|
|
280
284
|
by_name(name)
|
|
281
285
|
end
|
|
282
286
|
|
data/lib/bolt/project.rb
CHANGED
|
@@ -55,7 +55,7 @@ module Bolt
|
|
|
55
55
|
rescue StandardError
|
|
56
56
|
Bolt::Logger.warn(
|
|
57
57
|
"non_writeable_project",
|
|
58
|
-
"Could not create default project at #{path}. Continuing without a writeable project. "\
|
|
58
|
+
"Could not create default project at #{path}. Continuing without a writeable project. " \
|
|
59
59
|
"Log and rerun files will not be written."
|
|
60
60
|
)
|
|
61
61
|
end
|
|
@@ -67,7 +67,7 @@ module Bolt
|
|
|
67
67
|
|
|
68
68
|
if !Bolt::Util.windows? && type != 'environment' && fullpath.world_writable?
|
|
69
69
|
raise Bolt::Error.new(
|
|
70
|
-
"Project directory '#{fullpath}' is world-writable which poses a security risk. Set "\
|
|
70
|
+
"Project directory '#{fullpath}' is world-writable which poses a security risk. Set " \
|
|
71
71
|
"BOLT_PROJECT='#{fullpath}' to force the use of this project directory.",
|
|
72
72
|
"bolt/world-writable-error"
|
|
73
73
|
)
|
|
@@ -203,7 +203,7 @@ module Bolt
|
|
|
203
203
|
and can include lowercase letters, numbers, and underscores.
|
|
204
204
|
ERROR_STRING
|
|
205
205
|
elsif Dir.children(Bolt::Config::Modulepath::BOLTLIB_PATH).include?(name)
|
|
206
|
-
raise Bolt::ValidationError, "The project '#{name}' will not be loaded. The project name conflicts "\
|
|
206
|
+
raise Bolt::ValidationError, "The project '#{name}' will not be loaded. The project name conflicts " \
|
|
207
207
|
"with a built-in Bolt module of the same name."
|
|
208
208
|
end
|
|
209
209
|
elsif name.nil? &&
|
|
@@ -41,7 +41,7 @@ module Bolt
|
|
|
41
41
|
|
|
42
42
|
begin
|
|
43
43
|
@outputter.print_action_step(
|
|
44
|
-
"Moving transportation configuration options '#{transport_data.keys.join(', ')}' "\
|
|
44
|
+
"Moving transportation configuration options '#{transport_data.keys.join(', ')}' " \
|
|
45
45
|
"from bolt.yaml to inventory.yaml"
|
|
46
46
|
)
|
|
47
47
|
|
|
@@ -57,8 +57,8 @@ module Bolt
|
|
|
57
57
|
|
|
58
58
|
command = Bolt::Util.powershell? ? 'Get-Help about_bolt_project' : 'bolt guide project'
|
|
59
59
|
@outputter.print_action_step(
|
|
60
|
-
"Successfully migrated config. Please add a 'name' key to bolt-project.yaml "\
|
|
61
|
-
"to use project-level tasks and plans. Learn more about projects by running "\
|
|
60
|
+
"Successfully migrated config. Please add a 'name' key to bolt-project.yaml " \
|
|
61
|
+
"to use project-level tasks and plans. Learn more about projects by running " \
|
|
62
62
|
"'#{command}'."
|
|
63
63
|
)
|
|
64
64
|
|
|
@@ -34,7 +34,7 @@ module Bolt
|
|
|
34
34
|
true
|
|
35
35
|
rescue StandardError => e
|
|
36
36
|
raise Bolt::FileError.new(
|
|
37
|
-
"Unable to write to #{inventory_file}: #{e.message}. See "\
|
|
37
|
+
"Unable to write to #{inventory_file}: #{e.message}. See " \
|
|
38
38
|
"http://pup.pt/bolt-inventory to manually update.",
|
|
39
39
|
inventory_file
|
|
40
40
|
)
|
|
@@ -21,8 +21,8 @@ module Bolt
|
|
|
21
21
|
# Notify user to manually migrate modules if using non-default modulepath
|
|
22
22
|
if configured_modulepath != new_modulepath && configured_modulepath != old_modulepath
|
|
23
23
|
@outputter.print_action_step(
|
|
24
|
-
"Project has a non-default configured modulepath, unable to automatically "\
|
|
25
|
-
"migrate project modules. To migrate project modules manually, see "\
|
|
24
|
+
"Project has a non-default configured modulepath, unable to automatically " \
|
|
25
|
+
"migrate project modules. To migrate project modules manually, see " \
|
|
26
26
|
"http://pup.pt/bolt-modules"
|
|
27
27
|
)
|
|
28
28
|
true
|
|
@@ -106,7 +106,7 @@ module Bolt
|
|
|
106
106
|
Bolt::ModuleInstaller::Installer.new.install(puppetfile_path, managed_moduledir)
|
|
107
107
|
else
|
|
108
108
|
@outputter.print_action_step(
|
|
109
|
-
"Project does not include any managed modules, deleting Puppetfile "\
|
|
109
|
+
"Project does not include any managed modules, deleting Puppetfile " \
|
|
110
110
|
"at #{puppetfile_path}"
|
|
111
111
|
)
|
|
112
112
|
FileUtils.rm(puppetfile_path)
|
|
@@ -118,9 +118,9 @@ module Bolt
|
|
|
118
118
|
#
|
|
119
119
|
private def select_modules(modules)
|
|
120
120
|
@outputter.print_action_step(
|
|
121
|
-
"Select modules that are direct dependencies of your project. Bolt will "\
|
|
122
|
-
"automatically manage dependencies for each module selected, so do not "\
|
|
123
|
-
"select a module's dependencies unless you use content from it directly "\
|
|
121
|
+
"Select modules that are direct dependencies of your project. Bolt will " \
|
|
122
|
+
"automatically manage dependencies for each module selected, so do not " \
|
|
123
|
+
"select a module's dependencies unless you use content from it directly " \
|
|
124
124
|
"in your project."
|
|
125
125
|
)
|
|
126
126
|
|
|
@@ -161,6 +161,7 @@ module Bolt
|
|
|
161
161
|
source.each_child do |mod|
|
|
162
162
|
next unless mod.directory?
|
|
163
163
|
next if (moduledir + mod.basename).directory?
|
|
164
|
+
|
|
164
165
|
FileUtils.mv(mod, moduledir)
|
|
165
166
|
end
|
|
166
167
|
|
data/lib/bolt/project_manager.rb
CHANGED
|
@@ -70,14 +70,14 @@ module Bolt
|
|
|
70
70
|
if modules
|
|
71
71
|
command = Bolt::Util.powershell? ? 'Add-BoltModule -Module' : 'bolt module add'
|
|
72
72
|
raise Bolt::Error.new(
|
|
73
|
-
"Found existing project directory with #{config.basename} at #{project}, "\
|
|
74
|
-
"unable to initialize project with modules. To add modules to the project, "\
|
|
73
|
+
"Found existing project directory with #{config.basename} at #{project}, " \
|
|
74
|
+
"unable to initialize project with modules. To add modules to the project, " \
|
|
75
75
|
"run '#{command} <module>' instead.",
|
|
76
76
|
'bolt/existing-project-error'
|
|
77
77
|
)
|
|
78
78
|
else
|
|
79
79
|
raise Bolt::Error.new(
|
|
80
|
-
"Found existing project directory with #{config.basename} at #{project}, "\
|
|
80
|
+
"Found existing project directory with #{config.basename} at #{project}, " \
|
|
81
81
|
"unable to initialize project.",
|
|
82
82
|
'bolt/existing-project-error'
|
|
83
83
|
)
|
|
@@ -85,27 +85,27 @@ module Bolt
|
|
|
85
85
|
elsif old_config.exist?
|
|
86
86
|
command = Bolt::Util.powershell? ? 'Update-BoltProject' : 'bolt project migrate'
|
|
87
87
|
raise Bolt::Error.new(
|
|
88
|
-
"Found existing project directory with #{old_config.basename} at #{project}, "\
|
|
89
|
-
"unable to initialize project. #{old_config.basename} is deprecated. To "\
|
|
88
|
+
"Found existing project directory with #{old_config.basename} at #{project}, " \
|
|
89
|
+
"unable to initialize project. #{old_config.basename} is deprecated. To " \
|
|
90
90
|
"update the project to current best practices, run '#{command}'.",
|
|
91
91
|
'bolt/existing-project-error'
|
|
92
92
|
)
|
|
93
93
|
elsif modules && puppetfile.exist?
|
|
94
94
|
raise Bolt::Error.new(
|
|
95
|
-
"Found existing Puppetfile at #{puppetfile}, unable to initialize project "\
|
|
95
|
+
"Found existing Puppetfile at #{puppetfile}, unable to initialize project " \
|
|
96
96
|
"with modules.",
|
|
97
97
|
'bolt/existing-puppetfile-error'
|
|
98
98
|
)
|
|
99
99
|
elsif project_name !~ Bolt::Module::MODULE_NAME_REGEX
|
|
100
100
|
if name
|
|
101
101
|
raise Bolt::ValidationError,
|
|
102
|
-
"The provided project name '#{project_name}' is invalid; project name must "\
|
|
103
|
-
"begin with a lowercase letter and can include lowercase letters, "\
|
|
102
|
+
"The provided project name '#{project_name}' is invalid; project name must " \
|
|
103
|
+
"begin with a lowercase letter and can include lowercase letters, " \
|
|
104
104
|
"numbers, and underscores."
|
|
105
105
|
else
|
|
106
106
|
command = Bolt::Util.powershell? ? 'New-BoltProject -Name' : 'bolt project init'
|
|
107
107
|
raise Bolt::ValidationError,
|
|
108
|
-
"The current directory name '#{project_name}' is an invalid project name. "\
|
|
108
|
+
"The current directory name '#{project_name}' is an invalid project name. " \
|
|
109
109
|
"Please specify a name using '#{command} <name>'."
|
|
110
110
|
end
|
|
111
111
|
end
|
|
@@ -162,8 +162,8 @@ module Bolt
|
|
|
162
162
|
@outputter.print_message("Migrating project #{@config.project.path}\n\n")
|
|
163
163
|
|
|
164
164
|
@outputter.print_action_step(
|
|
165
|
-
"Migrating a Bolt project might make irreversible changes to the project's "\
|
|
166
|
-
"configuration and inventory files. Before continuing, make sure the "\
|
|
165
|
+
"Migrating a Bolt project might make irreversible changes to the project's " \
|
|
166
|
+
"configuration and inventory files. Before continuing, make sure the " \
|
|
167
167
|
"project has a backup or uses a version control system."
|
|
168
168
|
)
|
|
169
169
|
|
data/lib/bolt/puppetdb/config.rb
CHANGED
|
@@ -61,6 +61,7 @@ module Bolt
|
|
|
61
61
|
|
|
62
62
|
def token
|
|
63
63
|
return @token if @token_computed
|
|
64
|
+
|
|
64
65
|
# Allow nil in config to skip loading a token
|
|
65
66
|
if @settings.include?('token')
|
|
66
67
|
if @settings['token']
|
|
@@ -81,6 +82,7 @@ module Bolt
|
|
|
81
82
|
def expand_paths(project_path)
|
|
82
83
|
%w[cacert cert key token].each do |file|
|
|
83
84
|
next unless @settings[file]
|
|
85
|
+
|
|
84
86
|
@settings[file] = File.expand_path(@settings[file], project_path)
|
|
85
87
|
end
|
|
86
88
|
end
|
|
@@ -89,6 +91,7 @@ module Bolt
|
|
|
89
91
|
if @settings[file] && !File.exist?(@settings[file])
|
|
90
92
|
raise Bolt::PuppetDBError, "#{file} file #{@settings[file]} does not exist"
|
|
91
93
|
end
|
|
94
|
+
|
|
92
95
|
true
|
|
93
96
|
end
|
|
94
97
|
|
|
@@ -107,6 +110,7 @@ module Bolt
|
|
|
107
110
|
|
|
108
111
|
def uri
|
|
109
112
|
return @uri if @uri
|
|
113
|
+
|
|
110
114
|
require 'addressable/uri'
|
|
111
115
|
|
|
112
116
|
uri = case @settings['server_urls']
|
data/lib/bolt/rerun.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Bolt
|
|
|
14
14
|
|
|
15
15
|
# Needed by Puppet to serialize with _pcore_init_hash instead of the object's attributes
|
|
16
16
|
def self._pcore_init_from_hash(_init_hash)
|
|
17
|
-
raise "ResourceInstance shouldn't be instantiated from a pcore_init class method. "\
|
|
17
|
+
raise "ResourceInstance shouldn't be instantiated from a pcore_init class method. " \
|
|
18
18
|
"How did this get called?"
|
|
19
19
|
end
|
|
20
20
|
|
data/lib/bolt/result.rb
CHANGED
|
@@ -81,7 +81,7 @@ module Bolt
|
|
|
81
81
|
unless value['_error'].is_a?(Hash) && value['_error'].key?('msg')
|
|
82
82
|
details['original_error'] = value['_error']
|
|
83
83
|
value['_error'] = {
|
|
84
|
-
'msg' => "Invalid error returned from task #{task}: #{value['_error'].inspect}. Error "\
|
|
84
|
+
'msg' => "Invalid error returned from task #{task}: #{value['_error'].inspect}. Error " \
|
|
85
85
|
"must be an object with a msg key.",
|
|
86
86
|
'kind' => 'bolt/invalid-task-error',
|
|
87
87
|
'details' => details
|
|
@@ -148,6 +148,7 @@ module Bolt
|
|
|
148
148
|
if error && !error.is_a?(Hash)
|
|
149
149
|
raise "TODO: how did we get a string error"
|
|
150
150
|
end
|
|
151
|
+
|
|
151
152
|
@value['_error'] = error if error
|
|
152
153
|
@value['_output'] = message if message
|
|
153
154
|
end
|
data/lib/bolt/shell/bash.rb
CHANGED
|
@@ -301,6 +301,7 @@ module Bolt
|
|
|
301
301
|
if result.exit_code != 0
|
|
302
302
|
raise Bolt::Node::FileError.new("Could not make tmpdir: #{result.stderr.string}", 'TMPDIR_ERROR')
|
|
303
303
|
end
|
|
304
|
+
|
|
304
305
|
path = tmppath || result.stdout.string.chomp
|
|
305
306
|
Bolt::Shell::Bash::Tmpdir.new(self, path)
|
|
306
307
|
end
|
|
@@ -482,7 +483,7 @@ module Bolt
|
|
|
482
483
|
when 0
|
|
483
484
|
@logger.trace { "Command `#{command_str}` returned successfully" }
|
|
484
485
|
when 126
|
|
485
|
-
msg = "\n\nThis might be caused by the default tmpdir being mounted "\
|
|
486
|
+
msg = "\n\nThis might be caused by the default tmpdir being mounted " \
|
|
486
487
|
"using 'noexec'. See http://pup.pt/task-failure for details and workarounds."
|
|
487
488
|
result_output.stderr << msg
|
|
488
489
|
result_output.merged_output << msg
|
|
@@ -22,8 +22,8 @@ module Bolt
|
|
|
22
22
|
if !version.empty? && version.to_i < 3
|
|
23
23
|
# This lets us know how many targets have Powershell 2, and lets the
|
|
24
24
|
# user know how many targets they have with PS2
|
|
25
|
-
msg = "Detected PowerShell 2 on one or more targets.\nPowerShell 2 "\
|
|
26
|
-
"is unsupported. See bolt-debug.log or run with '--log-level debug' to see the full "\
|
|
25
|
+
msg = "Detected PowerShell 2 on one or more targets.\nPowerShell 2 " \
|
|
26
|
+
"is unsupported. See bolt-debug.log or run with '--log-level debug' to see the full " \
|
|
27
27
|
"list of targets with PowerShell 2."
|
|
28
28
|
|
|
29
29
|
Bolt::Logger.deprecate_once("powershell_2", msg)
|
|
@@ -45,7 +45,7 @@ module Bolt
|
|
|
45
45
|
|
|
46
46
|
def validate_extensions(ext)
|
|
47
47
|
unless @extensions.include?(ext)
|
|
48
|
-
raise Bolt::Node::FileError.new("File extension #{ext} is not enabled, "\
|
|
48
|
+
raise Bolt::Node::FileError.new("File extension #{ext} is not enabled, " \
|
|
49
49
|
"to run it please add to 'winrm: extensions'", 'FILETYPE_ERROR')
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -143,6 +143,7 @@ module Bolt
|
|
|
143
143
|
if result.exit_code != 0
|
|
144
144
|
raise Bolt::Node::FileError.new("Could not make tmpdir: #{result.stderr.string}", 'TMPDIR_ERROR')
|
|
145
145
|
end
|
|
146
|
+
|
|
146
147
|
result.stdout.string.chomp
|
|
147
148
|
end
|
|
148
149
|
|
data/lib/bolt/shell.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Bolt
|
|
|
11
11
|
|
|
12
12
|
if Bolt::Logger.stream
|
|
13
13
|
Bolt::Logger.warn_once("stream_experimental",
|
|
14
|
-
"The 'stream' option is experimental, and might "\
|
|
14
|
+
"The 'stream' option is experimental, and might " \
|
|
15
15
|
"include breaking changes between minor versions.")
|
|
16
16
|
@stream_logger = Bolt::Logger.logger(:stream)
|
|
17
17
|
# Don't send stream messages to the parent logger
|
data/lib/bolt/task/run.rb
CHANGED
data/lib/bolt/task.rb
CHANGED
|
@@ -99,12 +99,14 @@ module Bolt
|
|
|
99
99
|
Set.new(imp['requirements']).subset?(available_features) && !!remote_impl == @remote
|
|
100
100
|
end
|
|
101
101
|
raise NoImplementationError.new(target, self) unless impl
|
|
102
|
+
|
|
102
103
|
impl = impl.dup
|
|
103
104
|
impl['path'] = file_path(impl['name'])
|
|
104
105
|
impl.delete('requirements')
|
|
105
106
|
impl
|
|
106
107
|
else
|
|
107
108
|
raise NoImplementationError.new(target, self) unless !!metadata['remote'] == @remote
|
|
109
|
+
|
|
108
110
|
name = files.first['name']
|
|
109
111
|
{ 'name' => name, 'path' => file_path(name) }
|
|
110
112
|
end
|
|
@@ -117,6 +119,7 @@ module Bolt
|
|
|
117
119
|
impl['files'] = filenames.map do |file|
|
|
118
120
|
path = file_path(file)
|
|
119
121
|
raise "No file found for reference #{file}" if path.nil?
|
|
122
|
+
|
|
120
123
|
{ 'name' => file, 'path' => path }
|
|
121
124
|
end
|
|
122
125
|
|
|
@@ -11,6 +11,7 @@ module Bolt
|
|
|
11
11
|
|
|
12
12
|
def initialize(target)
|
|
13
13
|
raise Bolt::ValidationError, "Target #{target.safe_name} does not have a host" unless target.host
|
|
14
|
+
|
|
14
15
|
@target = target
|
|
15
16
|
@user = ENV['USER'] || Etc.getlogin
|
|
16
17
|
@logger = Bolt::Logger.logger(target.safe_name)
|
|
@@ -53,6 +54,7 @@ module Bolt
|
|
|
53
54
|
output = execute_local_json_command('ps', ['--no-trunc'])
|
|
54
55
|
index = output.find_index { |item| item["ID"].start_with?(target.host) || item["Names"] == target.host }
|
|
55
56
|
raise "Could not find a container with name or ID matching '#{target.host}'" if index.nil?
|
|
57
|
+
|
|
56
58
|
# Now find the indepth container information
|
|
57
59
|
output = execute_local_json_command('inspect', [output[index]["ID"]])
|
|
58
60
|
# Store the container information for later
|
|
@@ -11,6 +11,7 @@ module Bolt
|
|
|
11
11
|
|
|
12
12
|
def initialize(target)
|
|
13
13
|
raise Bolt::ValidationError, "Target #{target.safe_name} does not have a host" unless target.host
|
|
14
|
+
|
|
14
15
|
@target = target
|
|
15
16
|
@user = @target.user || ENV['USER'] || Etc.getlogin
|
|
16
17
|
@logger = Bolt::Logger.logger(target.safe_name)
|
|
@@ -38,6 +39,7 @@ module Bolt
|
|
|
38
39
|
output = JSON.parse(`jls --libxo=json`)
|
|
39
40
|
@jail_info = output['jail-information']['jail'].select { |jail| jail['hostname'] == target.host }.first
|
|
40
41
|
raise "Could not find a jail with name matching #{target.host}" if @jail_info.nil?
|
|
42
|
+
|
|
41
43
|
@logger.trace { "Opened session" }
|
|
42
44
|
true
|
|
43
45
|
rescue StandardError => e
|
|
@@ -36,10 +36,12 @@ module Bolt
|
|
|
36
36
|
unless status.exitstatus.zero?
|
|
37
37
|
raise "Error listing available containers: #{err}"
|
|
38
38
|
end
|
|
39
|
+
|
|
39
40
|
containers = JSON.parse(out)
|
|
40
41
|
if containers.empty?
|
|
41
42
|
raise "Could not find a container with name or ID matching '#{container_id}'"
|
|
42
43
|
end
|
|
44
|
+
|
|
43
45
|
@logger.trace("Opened session")
|
|
44
46
|
true
|
|
45
47
|
rescue StandardError => e
|
data/lib/bolt/transport/lxd.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Bolt
|
|
|
13
13
|
|
|
14
14
|
def with_connection(target, options = {})
|
|
15
15
|
Bolt::Logger.warn_once("lxd_experimental",
|
|
16
|
-
"The LXD transport is experimental, and might "\
|
|
16
|
+
"The LXD transport is experimental, and might " \
|
|
17
17
|
"include breaking changes between minor versions.")
|
|
18
18
|
conn = Connection.new(target, options)
|
|
19
19
|
conn.connect
|
|
@@ -11,6 +11,7 @@ module Bolt
|
|
|
11
11
|
|
|
12
12
|
def initialize(target)
|
|
13
13
|
raise Bolt::ValidationError, "Target #{target.safe_name} does not have a host" unless target.host
|
|
14
|
+
|
|
14
15
|
@target = target
|
|
15
16
|
@user = ENV['USER'] || Etc.getlogin
|
|
16
17
|
@logger = Bolt::Logger.logger(target.safe_name)
|
|
@@ -44,6 +45,7 @@ module Bolt
|
|
|
44
45
|
Array(item["Names"]).include?(@target.host)
|
|
45
46
|
}
|
|
46
47
|
raise "Could not find a container with name or ID matching '#{@target.host}'" if container.nil?
|
|
48
|
+
|
|
47
49
|
# Now find the indepth container information
|
|
48
50
|
id = container["ID"] || container["Id"]
|
|
49
51
|
output = execute_local_json_command('inspect', [id])
|
|
@@ -16,6 +16,7 @@ module Bolt
|
|
|
16
16
|
def get_proxy(target)
|
|
17
17
|
inventory = target.inventory
|
|
18
18
|
raise "Target was created without inventory? Not get_targets?" unless inventory
|
|
19
|
+
|
|
19
20
|
proxy = inventory.get_targets(target.options['run-on'] || 'localhost').first
|
|
20
21
|
|
|
21
22
|
if proxy.transport == 'remote'
|
|
@@ -227,7 +227,7 @@ module Bolt
|
|
|
227
227
|
end
|
|
228
228
|
[in_wr, out_rd, err_rd, th]
|
|
229
229
|
rescue Errno::EMFILE => e
|
|
230
|
-
msg = "#{e.message}. This might be resolved by increasing your user limit "\
|
|
230
|
+
msg = "#{e.message}. This might be resolved by increasing your user limit " \
|
|
231
231
|
"with 'ulimit -n 1024'. See https://puppet.com/docs/bolt/latest/bolt_known_issues.html for details."
|
|
232
232
|
raise Bolt::Error.new(msg, 'bolt/too-many-files')
|
|
233
233
|
end
|
|
@@ -11,6 +11,7 @@ module Bolt
|
|
|
11
11
|
|
|
12
12
|
def initialize(target, transport_logger)
|
|
13
13
|
raise Bolt::ValidationError, "Target #{target.safe_name} does not have a host" unless target.host
|
|
14
|
+
|
|
14
15
|
@target = target
|
|
15
16
|
|
|
16
17
|
default_port = target.options['ssl'] ? HTTPS_PORT : HTTP_PORT
|
|
@@ -81,8 +82,8 @@ module Bolt
|
|
|
81
82
|
theres_your_problem = "\nAre you using SSL to connect to a non-SSL port?"
|
|
82
83
|
end
|
|
83
84
|
if target.options['ssl-verify'] && e.message.include?('certificate verify failed')
|
|
84
|
-
theres_your_problem = "\nIs the remote host using a self-signed SSL "\
|
|
85
|
-
"certificate? Use --no-ssl-verify to disable "\
|
|
85
|
+
theres_your_problem = "\nIs the remote host using a self-signed SSL " \
|
|
86
|
+
"certificate? Use --no-ssl-verify to disable " \
|
|
86
87
|
"remote host SSL verification."
|
|
87
88
|
end
|
|
88
89
|
raise Bolt::Node::ConnectError.new(
|
|
@@ -137,7 +138,7 @@ module Bolt
|
|
|
137
138
|
|
|
138
139
|
[inp, out_rd, err_rd, th]
|
|
139
140
|
rescue Errno::EMFILE => e
|
|
140
|
-
msg = "#{e.message}. This might be resolved by increasing your user limit "\
|
|
141
|
+
msg = "#{e.message}. This might be resolved by increasing your user limit " \
|
|
141
142
|
"with 'ulimit -n 1024'. See https://puppet.com/docs/bolt/latest/bolt_known_issues.html for details."
|
|
142
143
|
raise Bolt::Error.new(msg, 'bolt/too-many-files')
|
|
143
144
|
rescue StandardError
|
data/lib/bolt/util/format.rb
CHANGED
data/lib/bolt/util.rb
CHANGED
|
@@ -52,7 +52,7 @@ module Bolt
|
|
|
52
52
|
content = File.open(path, "r:UTF-8") { |f| YAML.safe_load(f.read) } || {}
|
|
53
53
|
unless content.is_a?(Hash)
|
|
54
54
|
raise Bolt::FileError.new(
|
|
55
|
-
"Invalid content for #{file_name} file at #{path}\nContent should be a Hash or empty, "\
|
|
55
|
+
"Invalid content for #{file_name} file at #{path}\nContent should be a Hash or empty, " \
|
|
56
56
|
"not #{content.class}",
|
|
57
57
|
path
|
|
58
58
|
)
|
|
@@ -62,11 +62,11 @@ module Bolt
|
|
|
62
62
|
rescue Errno::ENOENT
|
|
63
63
|
raise Bolt::FileError.new("Could not read #{file_name} file at #{path}", path)
|
|
64
64
|
rescue Psych::SyntaxError => e
|
|
65
|
-
raise Bolt::FileError.new("Could not parse #{file_name} file at #{path}, line #{e.line}, "\
|
|
65
|
+
raise Bolt::FileError.new("Could not parse #{file_name} file at #{path}, line #{e.line}, " \
|
|
66
66
|
"column #{e.column}\n#{e.problem}",
|
|
67
67
|
path)
|
|
68
68
|
rescue Psych::BadAlias => e
|
|
69
|
-
raise Bolt::FileError.new('Bolt does not support the use of aliases in YAML files. Alias '\
|
|
69
|
+
raise Bolt::FileError.new('Bolt does not support the use of aliases in YAML files. Alias ' \
|
|
70
70
|
"detected in #{file_name} file at #{path}\n#{e.message}", path)
|
|
71
71
|
rescue Psych::Exception => e
|
|
72
72
|
raise Bolt::FileError.new("Could not parse #{file_name} file at #{path}\n#{e.message}",
|
|
@@ -147,7 +147,7 @@ module Bolt
|
|
|
147
147
|
|
|
148
148
|
# Only accept paths with '/plans/' or '/tasks/'
|
|
149
149
|
unless path.match?(regex)
|
|
150
|
-
msg = "Could not determine module from #{path}. "\
|
|
150
|
+
msg = "Could not determine module from #{path}. " \
|
|
151
151
|
"The path must include 'plans' or 'tasks' directory"
|
|
152
152
|
raise Bolt::Error.new(msg, 'bolt/modulepath-error')
|
|
153
153
|
end
|
|
@@ -361,6 +361,7 @@ module Bolt
|
|
|
361
361
|
elsif stat.directory?
|
|
362
362
|
Dir.foreach(path) do |file|
|
|
363
363
|
next if %w[. ..].include?(file)
|
|
364
|
+
|
|
364
365
|
validate_file(type, File.join(path, file), allow_dir)
|
|
365
366
|
end
|
|
366
367
|
end
|
|
@@ -431,11 +432,13 @@ module Bolt
|
|
|
431
432
|
|
|
432
433
|
def unix_basename(path)
|
|
433
434
|
raise Bolt::ValidationError, "path must be a String, received #{path.class} #{path}" unless path.is_a?(String)
|
|
435
|
+
|
|
434
436
|
path.split('/').last
|
|
435
437
|
end
|
|
436
438
|
|
|
437
439
|
def windows_basename(path)
|
|
438
440
|
raise Bolt::ValidationError, "path must be a String, received #{path.class} #{path}" unless path.is_a?(String)
|
|
441
|
+
|
|
439
442
|
path.split(%r{[/\\]}).last
|
|
440
443
|
end
|
|
441
444
|
|