bolt 3.17.0 → 3.21.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bolt might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Puppetfile +14 -14
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +1 -4
- data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -4
- data/bolt-modules/file/lib/puppet/functions/file/exists.rb +1 -4
- data/bolt-modules/file/lib/puppet/functions/file/read.rb +1 -4
- data/bolt-modules/file/lib/puppet/functions/file/readable.rb +1 -4
- data/lib/bolt/analytics.rb +2 -2
- data/lib/bolt/application.rb +177 -12
- data/lib/bolt/applicator.rb +7 -6
- data/lib/bolt/apply_inventory.rb +3 -3
- data/lib/bolt/apply_result.rb +2 -2
- data/lib/bolt/bolt_option_parser.rb +87 -22
- data/lib/bolt/catalog.rb +10 -11
- data/lib/bolt/cli.rb +66 -24
- data/lib/bolt/config/modulepath.rb +1 -1
- data/lib/bolt/config/options.rb +42 -13
- data/lib/bolt/config/transport/base.rb +4 -4
- data/lib/bolt/config/transport/docker.rb +2 -2
- data/lib/bolt/config/transport/local.rb +2 -2
- data/lib/bolt/config/transport/lxd.rb +2 -2
- data/lib/bolt/config/transport/options.rb +3 -2
- data/lib/bolt/config/transport/orch.rb +2 -2
- data/lib/bolt/config/transport/podman.rb +2 -2
- data/lib/bolt/config/transport/remote.rb +2 -2
- data/lib/bolt/config/transport/ssh.rb +2 -2
- data/lib/bolt/config/transport/winrm.rb +2 -2
- data/lib/bolt/config.rb +9 -5
- data/lib/bolt/container_result.rb +2 -2
- data/lib/bolt/error.rb +1 -1
- data/lib/bolt/executor.rb +17 -14
- data/lib/bolt/fiber_executor.rb +2 -2
- data/lib/bolt/inventory/group.rb +4 -4
- data/lib/bolt/inventory/inventory.rb +3 -9
- data/lib/bolt/inventory/options.rb +1 -1
- data/lib/bolt/inventory/target.rb +1 -1
- data/lib/bolt/inventory.rb +8 -8
- data/lib/bolt/module_installer/installer.rb +2 -2
- data/lib/bolt/module_installer/puppetfile/forge_module.rb +1 -1
- data/lib/bolt/module_installer/puppetfile/git_module.rb +1 -1
- data/lib/bolt/module_installer/puppetfile/module.rb +1 -1
- data/lib/bolt/module_installer/puppetfile.rb +3 -3
- data/lib/bolt/module_installer/resolver.rb +3 -3
- data/lib/bolt/module_installer/specs/forge_spec.rb +1 -1
- data/lib/bolt/module_installer/specs/git_spec.rb +1 -1
- data/lib/bolt/module_installer/specs.rb +3 -3
- data/lib/bolt/module_installer.rb +6 -6
- data/lib/bolt/node/errors.rb +1 -1
- data/lib/bolt/node/output.rb +1 -1
- data/lib/bolt/outputter/human.rb +45 -2
- data/lib/bolt/outputter/json.rb +8 -0
- data/lib/bolt/outputter/logger.rb +1 -1
- data/lib/bolt/outputter/rainbow.rb +1 -1
- data/lib/bolt/outputter.rb +4 -4
- data/lib/bolt/pal/logging.rb +1 -1
- data/lib/bolt/pal/yaml_plan/evaluator.rb +1 -1
- data/lib/bolt/pal/yaml_plan/loader.rb +2 -2
- data/lib/bolt/pal/yaml_plan/step.rb +11 -11
- data/lib/bolt/pal/yaml_plan/transpiler.rb +3 -3
- data/lib/bolt/pal/yaml_plan.rb +2 -2
- data/lib/bolt/pal.rb +25 -11
- data/lib/bolt/plan_creator.rb +4 -4
- data/lib/bolt/plan_result.rb +2 -2
- data/lib/bolt/plugin/cache.rb +2 -2
- data/lib/bolt/plugin/module.rb +1 -1
- data/lib/bolt/plugin.rb +7 -7
- data/lib/bolt/project.rb +7 -5
- data/lib/bolt/project_manager/config_migrator.rb +1 -1
- data/lib/bolt/project_manager/inventory_migrator.rb +1 -1
- data/lib/bolt/project_manager/migrator.rb +1 -1
- data/lib/bolt/project_manager/module_migrator.rb +5 -5
- data/lib/bolt/project_manager.rb +23 -4
- data/lib/bolt/puppetdb/config.rb +1 -1
- data/lib/bolt/puppetdb.rb +3 -3
- data/lib/bolt/result.rb +1 -1
- data/lib/bolt/shell/bash.rb +14 -8
- data/lib/bolt/shell/powershell.rb +23 -4
- data/lib/bolt/shell.rb +2 -2
- data/lib/bolt/target.rb +2 -2
- data/lib/bolt/transport/base.rb +1 -1
- data/lib/bolt/transport/docker/connection.rb +1 -1
- data/lib/bolt/transport/docker.rb +2 -2
- data/lib/bolt/transport/local/connection.rb +2 -2
- data/lib/bolt/transport/local.rb +3 -3
- data/lib/bolt/transport/lxd/connection.rb +1 -1
- data/lib/bolt/transport/lxd.rb +4 -4
- data/lib/bolt/transport/orch.rb +2 -2
- data/lib/bolt/transport/podman/connection.rb +1 -1
- data/lib/bolt/transport/podman.rb +2 -2
- data/lib/bolt/transport/remote.rb +2 -2
- data/lib/bolt/transport/simple.rb +3 -3
- data/lib/bolt/transport/ssh/connection.rb +3 -3
- data/lib/bolt/transport/ssh.rb +5 -5
- data/lib/bolt/transport/winrm/connection.rb +2 -2
- data/lib/bolt/transport/winrm.rb +3 -3
- data/lib/bolt/util.rb +11 -31
- data/lib/bolt/validator.rb +1 -1
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt.rb +1 -1
- data/lib/bolt_server/transport_app.rb +26 -5
- data/lib/bolt_spec/bolt_context.rb +6 -4
- data/lib/bolt_spec/plans/mock_executor.rb +3 -3
- data/libexec/bolt_catalog +1 -1
- metadata +6 -6
data/lib/bolt/plugin/cache.rb
CHANGED
data/lib/bolt/plugin/module.rb
CHANGED
data/lib/bolt/plugin.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
require_relative '../bolt/inventory'
|
4
|
+
require_relative '../bolt/executor'
|
5
|
+
require_relative '../bolt/module'
|
6
|
+
require_relative '../bolt/pal'
|
7
|
+
require_relative 'plugin/cache'
|
8
|
+
require_relative 'plugin/puppetdb'
|
9
9
|
|
10
10
|
module Bolt
|
11
11
|
class Plugin
|
@@ -376,4 +376,4 @@ module Bolt
|
|
376
376
|
end
|
377
377
|
|
378
378
|
# references PluginError
|
379
|
-
|
379
|
+
require_relative 'plugin/module'
|
data/lib/bolt/project.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'pathname'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
require_relative '../bolt/config'
|
5
|
+
require_relative '../bolt/validator'
|
6
|
+
require_relative '../bolt/pal'
|
7
|
+
require_relative '../bolt/module'
|
8
8
|
|
9
9
|
module Bolt
|
10
10
|
class Project
|
@@ -14,7 +14,8 @@ module Bolt
|
|
14
14
|
attr_reader :path, :data, :inventory_file, :hiera_config,
|
15
15
|
:puppetfile, :rerunfile, :type, :resource_types, :project_file,
|
16
16
|
:downloads, :plans_path, :modulepath, :managed_moduledir,
|
17
|
-
:backup_dir, :plugin_cache_file, :plan_cache_file, :task_cache_file
|
17
|
+
:backup_dir, :plugin_cache_file, :plan_cache_file, :task_cache_file,
|
18
|
+
:manifests
|
18
19
|
|
19
20
|
def self.default_project
|
20
21
|
create_project(File.expand_path(File.join('~', '.puppetlabs', 'bolt')), 'user')
|
@@ -116,6 +117,7 @@ module Bolt
|
|
116
117
|
@plan_cache_file = @path + '.plan_cache.json'
|
117
118
|
@task_cache_file = @path + '.task_cache.json'
|
118
119
|
@modulepath = [(@path + 'modules').to_s]
|
120
|
+
@manifests = @path + 'manifests'
|
119
121
|
|
120
122
|
if (tc = Bolt::Config::INVENTORY_OPTIONS.keys & data.keys).any?
|
121
123
|
Bolt::Logger.warn(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../../bolt/project_manager/migrator'
|
4
4
|
|
5
5
|
module Bolt
|
6
6
|
class ProjectManager
|
@@ -43,10 +43,10 @@ module Bolt
|
|
43
43
|
# to the new moduledir.
|
44
44
|
#
|
45
45
|
private def migrate_modules_from_puppetfile(config, puppetfile_path, managed_moduledir, modulepath)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
require_relative '../../bolt/module_installer/installer'
|
47
|
+
require_relative '../../bolt/module_installer/puppetfile'
|
48
|
+
require_relative '../../bolt/module_installer/resolver'
|
49
|
+
require_relative '../../bolt/module_installer/specs'
|
50
50
|
|
51
51
|
begin
|
52
52
|
@outputter.print_action_step("Parsing Puppetfile at #{puppetfile_path}")
|
data/lib/bolt/project_manager.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require_relative 'project_manager/config_migrator'
|
4
|
+
require_relative 'project_manager/inventory_migrator'
|
5
|
+
require_relative 'project_manager/module_migrator'
|
6
6
|
|
7
7
|
module Bolt
|
8
8
|
class ProjectManager
|
@@ -36,6 +36,16 @@ module Bolt
|
|
36
36
|
# ssl: false
|
37
37
|
INVENTORY
|
38
38
|
|
39
|
+
GITIGNORE_CONTENT = <<~GITIGNORE
|
40
|
+
.modules/
|
41
|
+
.resource_types/
|
42
|
+
bolt-debug.log
|
43
|
+
.plan_cache.json
|
44
|
+
.plugin_cache.json
|
45
|
+
.task_cache.json
|
46
|
+
.rerun.json
|
47
|
+
GITIGNORE
|
48
|
+
|
39
49
|
def initialize(config, outputter, pal)
|
40
50
|
@config = config
|
41
51
|
@outputter = outputter
|
@@ -45,7 +55,7 @@ module Bolt
|
|
45
55
|
# Creates a new project at the specified directory.
|
46
56
|
#
|
47
57
|
def create(path, name, modules)
|
48
|
-
|
58
|
+
require_relative '../bolt/module_installer'
|
49
59
|
|
50
60
|
project = Pathname.new(File.expand_path(path))
|
51
61
|
old_config = project + 'bolt.yaml'
|
@@ -53,6 +63,7 @@ module Bolt
|
|
53
63
|
puppetfile = project + 'Puppetfile'
|
54
64
|
moduledir = project + '.modules'
|
55
65
|
inventoryfile = project + 'inventory.yaml'
|
66
|
+
gitignore = project + '.gitignore'
|
56
67
|
project_name = name || File.basename(project)
|
57
68
|
|
58
69
|
if config.exist?
|
@@ -125,6 +136,14 @@ module Bolt
|
|
125
136
|
end
|
126
137
|
end
|
127
138
|
|
139
|
+
unless gitignore.exist?
|
140
|
+
begin
|
141
|
+
File.write(gitignore.to_path, GITIGNORE_CONTENT)
|
142
|
+
rescue StandardError => e
|
143
|
+
raise Bolt::FileError.new("Could not create .gitignore at #{project}: #{e.message}", nil)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
128
147
|
@outputter.print_message("Successfully created Bolt project at #{project}")
|
129
148
|
|
130
149
|
0
|
data/lib/bolt/puppetdb/config.rb
CHANGED
data/lib/bolt/puppetdb.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require_relative '../bolt/error'
|
4
|
+
require_relative 'puppetdb/client'
|
5
|
+
require_relative 'puppetdb/config'
|
6
6
|
|
7
7
|
module Bolt
|
8
8
|
class PuppetDBError < Bolt::Error
|
data/lib/bolt/result.rb
CHANGED
data/lib/bolt/shell/bash.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'bash/tmpdir'
|
4
4
|
require 'shellwords'
|
5
5
|
|
6
6
|
module Bolt
|
@@ -94,7 +94,17 @@ module Bolt
|
|
94
94
|
with_tmpdir do |dir|
|
95
95
|
path = write_executable(dir.to_s, script)
|
96
96
|
dir.chown(run_as)
|
97
|
-
|
97
|
+
|
98
|
+
exec_args = [path, *arguments]
|
99
|
+
interpreter = select_interpreter(script, target.options['interpreters'])
|
100
|
+
|
101
|
+
# Only use interpreter if script_interpreter config is enabled
|
102
|
+
if options[:script_interpreter] && interpreter
|
103
|
+
exec_args.unshift(interpreter).flatten!
|
104
|
+
logger.trace("Running '#{script}' using '#{interpreter}' interpreter")
|
105
|
+
end
|
106
|
+
|
107
|
+
output = execute(exec_args, environment: options[:env_vars], sudoable: true)
|
98
108
|
Bolt::Result.for_command(target,
|
99
109
|
output.to_h,
|
100
110
|
'script',
|
@@ -244,7 +254,7 @@ module Bolt
|
|
244
254
|
if interpreter
|
245
255
|
StringIO.new(<<~SCRIPT)
|
246
256
|
#!/bin/sh
|
247
|
-
'#{
|
257
|
+
#{Array(interpreter).map { |word| "'#{word}'" }.join(' ')} '#{task_path}' <<'EOF'
|
248
258
|
#{stdin}
|
249
259
|
EOF
|
250
260
|
SCRIPT
|
@@ -325,11 +335,7 @@ module Bolt
|
|
325
335
|
# Returns string with the interpreter conditionally prepended
|
326
336
|
def inject_interpreter(interpreter, command)
|
327
337
|
if interpreter
|
328
|
-
|
329
|
-
command.unshift(interpreter)
|
330
|
-
else
|
331
|
-
command = [interpreter, command]
|
332
|
-
end
|
338
|
+
command = Array(command).unshift(interpreter).flatten
|
333
339
|
end
|
334
340
|
|
335
341
|
command.is_a?(String) ? command : Shellwords.shelljoin(command)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'powershell/snippets'
|
4
4
|
|
5
5
|
module Bolt
|
6
6
|
class Shell
|
@@ -212,7 +212,20 @@ module Bolt
|
|
212
212
|
elsif powershell_file?(script_path)
|
213
213
|
Snippets.run_script(arguments, script_path)
|
214
214
|
else
|
215
|
-
|
215
|
+
interpreter = select_interpreter(script_path, target.options['interpreters'])
|
216
|
+
if options[:script_interpreter] && interpreter
|
217
|
+
# interpreter can be a String or Array here. Cast it to an array.
|
218
|
+
interpreter_array = Array(interpreter)
|
219
|
+
# Make path the first part of the array - this should be the binary
|
220
|
+
path = interpreter_array.shift
|
221
|
+
# Anything else in interpreters should get prepended to
|
222
|
+
# the command. If interpreters was a string this will
|
223
|
+
# just be [script_path]
|
224
|
+
args = escape_arguments(interpreter_array + Array(script_path))
|
225
|
+
logger.trace("Running '#{script_path}' using '#{interpreter}' interpreter")
|
226
|
+
else
|
227
|
+
path, args = *process_from_extension(script_path)
|
228
|
+
end
|
216
229
|
args += escape_arguments(arguments)
|
217
230
|
execute_process(path, args)
|
218
231
|
end
|
@@ -261,8 +274,14 @@ module Bolt
|
|
261
274
|
run_ps_task(task_path, arguments, input_method)
|
262
275
|
else
|
263
276
|
if (interpreter = select_interpreter(task_path, target.options['interpreters']))
|
264
|
-
|
265
|
-
|
277
|
+
# interpreter can be a String or Array here. Cast it to an array.
|
278
|
+
interpreter_array = Array(interpreter)
|
279
|
+
# Make path the first part of the array - this should be the binary
|
280
|
+
path = interpreter_array.shift
|
281
|
+
# Anything else in interpreters should get prepended to
|
282
|
+
# the command. If interpreters was a string this will
|
283
|
+
# just be [task_path]
|
284
|
+
args = interpreter_array + [task_path]
|
266
285
|
else
|
267
286
|
path, args = *process_from_extension(task_path)
|
268
287
|
end
|
data/lib/bolt/shell.rb
CHANGED
data/lib/bolt/target.rb
CHANGED
data/lib/bolt/transport/base.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
require 'shellwords'
|
5
|
-
|
5
|
+
require_relative '../../bolt/transport/simple'
|
6
6
|
|
7
7
|
module Bolt
|
8
8
|
module Transport
|
@@ -20,4 +20,4 @@ module Bolt
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
require_relative 'docker/connection'
|
data/lib/bolt/transport/local.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require_relative '../../bolt/logger'
|
4
|
+
require_relative '../../bolt/transport/simple'
|
5
5
|
|
6
6
|
module Bolt
|
7
7
|
module Transport
|
@@ -21,4 +21,4 @@ module Bolt
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
require_relative 'local/connection'
|
data/lib/bolt/transport/lxd.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require_relative '../../bolt/logger'
|
4
|
+
require_relative '../../bolt/node/errors'
|
5
|
+
require_relative '../../bolt/transport/simple'
|
6
6
|
|
7
7
|
module Bolt
|
8
8
|
module Transport
|
@@ -23,4 +23,4 @@ module Bolt
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
require_relative 'lxd/connection'
|
data/lib/bolt/transport/orch.rb
CHANGED
@@ -4,8 +4,8 @@ require 'base64'
|
|
4
4
|
require 'find'
|
5
5
|
require 'json'
|
6
6
|
require 'pathname'
|
7
|
-
|
8
|
-
|
7
|
+
require_relative '../../bolt/transport/base'
|
8
|
+
require_relative 'orch/connection'
|
9
9
|
|
10
10
|
module Bolt
|
11
11
|
module Transport
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
require 'shellwords'
|
5
|
-
|
5
|
+
require_relative '../../bolt/transport/base'
|
6
6
|
|
7
7
|
module Bolt
|
8
8
|
module Transport
|
@@ -16,4 +16,4 @@ module Bolt
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
require_relative 'podman/connection'
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'logging'
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
require_relative '../../bolt/result'
|
5
|
+
require_relative '../../bolt/shell'
|
6
|
+
require_relative '../../bolt/transport/base'
|
7
7
|
|
8
8
|
module Bolt
|
9
9
|
module Transport
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'logging'
|
4
4
|
require 'shellwords'
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
require_relative '../../../bolt/node/errors'
|
6
|
+
require_relative '../../../bolt/node/output'
|
7
|
+
require_relative '../../../bolt/util'
|
8
8
|
|
9
9
|
module Bolt
|
10
10
|
module Transport
|
data/lib/bolt/transport/ssh.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require_relative '../../bolt/logger'
|
4
|
+
require_relative '../../bolt/node/errors'
|
5
|
+
require_relative '../../bolt/transport/simple'
|
6
6
|
|
7
7
|
module Bolt
|
8
8
|
module Transport
|
@@ -44,5 +44,5 @@ module Bolt
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
require_relative 'ssh/connection'
|
48
|
+
require_relative 'ssh/exec_connection'
|
data/lib/bolt/transport/winrm.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require_relative '../../bolt/node/errors'
|
4
|
+
require_relative '../../bolt/transport/base'
|
5
5
|
|
6
6
|
module Bolt
|
7
7
|
module Transport
|
@@ -30,4 +30,4 @@ module Bolt
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
require_relative 'winrm/connection'
|
data/lib/bolt/util.rb
CHANGED
@@ -65,6 +65,9 @@ module Bolt
|
|
65
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
|
+
rescue Psych::BadAlias => e
|
69
|
+
raise Bolt::FileError.new('Bolt does not support the use of aliases in YAML files. Alias '\
|
70
|
+
"detected in #{file_name} file at #{path}\n#{e.message}", path)
|
68
71
|
rescue Psych::Exception => e
|
69
72
|
raise Bolt::FileError.new("Could not parse #{file_name} file at #{path}\n#{e.message}",
|
70
73
|
path)
|
@@ -103,7 +106,7 @@ module Bolt
|
|
103
106
|
# absolute path or Puppet module syntax lookup. Returns the path to the
|
104
107
|
# file if found, or nil.
|
105
108
|
#
|
106
|
-
def find_file_from_scope(file, scope
|
109
|
+
def find_file_from_scope(file, scope)
|
107
110
|
# If we got an absolute path, just return that.
|
108
111
|
return file if Pathname.new(file).absolute?
|
109
112
|
|
@@ -112,44 +115,21 @@ module Bolt
|
|
112
115
|
mod_path = scope.compiler.environment.module(module_name)&.path
|
113
116
|
|
114
117
|
# Search the module for the file, falling back to new-style paths if enabled.
|
115
|
-
|
118
|
+
search_module(mod_path, file_pattern) if mod_path
|
116
119
|
end
|
117
120
|
|
118
|
-
# This
|
119
|
-
#
|
120
|
-
#
|
121
|
-
# searches subdirectories in the module in order of precedence.
|
121
|
+
# This searches a module for files under 'files/' or 'scripts/', falling
|
122
|
+
# back to the new style of file loading. It takes the absolute path to the
|
123
|
+
# module root and the relative path provided by the user.
|
122
124
|
#
|
123
|
-
def
|
124
|
-
# If the first part of the path is 'scripts' or 'files', the path may
|
125
|
-
# be a new-style file location and should fall back to the new path.
|
126
|
-
subdir_or_file = split_path(module_file).first
|
127
|
-
case subdir_or_file
|
128
|
-
# For any subdirs that may indicate the user passed a new-style path,
|
129
|
-
# first look in 'mymod/files/<relative_path>' (old-style) then fall
|
130
|
-
# back to 'mymod/<relative_path>' (new-style) if enabled.
|
131
|
-
when 'scripts', 'files'
|
132
|
-
search_module(module_path, module_file, fallback)
|
133
|
-
else
|
134
|
-
# If the path definitely isn't new-style, only look in the 'files/'
|
135
|
-
# directory.
|
136
|
-
search_module(module_path, module_file)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
# This searches a module for files under 'files/' or 'scripts/',
|
141
|
-
# optionally falling back to the new style of file loading. It takes the
|
142
|
-
# absolute path to the module root, the relative path provided by the
|
143
|
-
# user, and whether to fall back to the new-style script loading if the
|
144
|
-
# file isn't found in 'files/'.
|
145
|
-
#
|
146
|
-
private def search_module(module_path, module_file, fallback = false)
|
125
|
+
def search_module(module_path, module_file)
|
147
126
|
if File.exist?(File.join(module_path, 'files', module_file))
|
148
127
|
File.join(module_path, 'files', module_file)
|
149
|
-
elsif File.exist?(File.join(module_path, module_file))
|
128
|
+
elsif File.exist?(File.join(module_path, module_file))
|
150
129
|
File.join(module_path, module_file)
|
151
130
|
end
|
152
131
|
end
|
132
|
+
alias find_file_in_module search_module
|
153
133
|
|
154
134
|
# Copied directly from puppet/lib/puppet/parser/files.rb
|
155
135
|
#
|
data/lib/bolt/validator.rb
CHANGED
data/lib/bolt/version.rb
CHANGED