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.

Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +14 -14
  3. data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +1 -4
  4. data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -4
  5. data/bolt-modules/file/lib/puppet/functions/file/exists.rb +1 -4
  6. data/bolt-modules/file/lib/puppet/functions/file/read.rb +1 -4
  7. data/bolt-modules/file/lib/puppet/functions/file/readable.rb +1 -4
  8. data/lib/bolt/analytics.rb +2 -2
  9. data/lib/bolt/application.rb +177 -12
  10. data/lib/bolt/applicator.rb +7 -6
  11. data/lib/bolt/apply_inventory.rb +3 -3
  12. data/lib/bolt/apply_result.rb +2 -2
  13. data/lib/bolt/bolt_option_parser.rb +87 -22
  14. data/lib/bolt/catalog.rb +10 -11
  15. data/lib/bolt/cli.rb +66 -24
  16. data/lib/bolt/config/modulepath.rb +1 -1
  17. data/lib/bolt/config/options.rb +42 -13
  18. data/lib/bolt/config/transport/base.rb +4 -4
  19. data/lib/bolt/config/transport/docker.rb +2 -2
  20. data/lib/bolt/config/transport/local.rb +2 -2
  21. data/lib/bolt/config/transport/lxd.rb +2 -2
  22. data/lib/bolt/config/transport/options.rb +3 -2
  23. data/lib/bolt/config/transport/orch.rb +2 -2
  24. data/lib/bolt/config/transport/podman.rb +2 -2
  25. data/lib/bolt/config/transport/remote.rb +2 -2
  26. data/lib/bolt/config/transport/ssh.rb +2 -2
  27. data/lib/bolt/config/transport/winrm.rb +2 -2
  28. data/lib/bolt/config.rb +9 -5
  29. data/lib/bolt/container_result.rb +2 -2
  30. data/lib/bolt/error.rb +1 -1
  31. data/lib/bolt/executor.rb +17 -14
  32. data/lib/bolt/fiber_executor.rb +2 -2
  33. data/lib/bolt/inventory/group.rb +4 -4
  34. data/lib/bolt/inventory/inventory.rb +3 -9
  35. data/lib/bolt/inventory/options.rb +1 -1
  36. data/lib/bolt/inventory/target.rb +1 -1
  37. data/lib/bolt/inventory.rb +8 -8
  38. data/lib/bolt/module_installer/installer.rb +2 -2
  39. data/lib/bolt/module_installer/puppetfile/forge_module.rb +1 -1
  40. data/lib/bolt/module_installer/puppetfile/git_module.rb +1 -1
  41. data/lib/bolt/module_installer/puppetfile/module.rb +1 -1
  42. data/lib/bolt/module_installer/puppetfile.rb +3 -3
  43. data/lib/bolt/module_installer/resolver.rb +3 -3
  44. data/lib/bolt/module_installer/specs/forge_spec.rb +1 -1
  45. data/lib/bolt/module_installer/specs/git_spec.rb +1 -1
  46. data/lib/bolt/module_installer/specs.rb +3 -3
  47. data/lib/bolt/module_installer.rb +6 -6
  48. data/lib/bolt/node/errors.rb +1 -1
  49. data/lib/bolt/node/output.rb +1 -1
  50. data/lib/bolt/outputter/human.rb +45 -2
  51. data/lib/bolt/outputter/json.rb +8 -0
  52. data/lib/bolt/outputter/logger.rb +1 -1
  53. data/lib/bolt/outputter/rainbow.rb +1 -1
  54. data/lib/bolt/outputter.rb +4 -4
  55. data/lib/bolt/pal/logging.rb +1 -1
  56. data/lib/bolt/pal/yaml_plan/evaluator.rb +1 -1
  57. data/lib/bolt/pal/yaml_plan/loader.rb +2 -2
  58. data/lib/bolt/pal/yaml_plan/step.rb +11 -11
  59. data/lib/bolt/pal/yaml_plan/transpiler.rb +3 -3
  60. data/lib/bolt/pal/yaml_plan.rb +2 -2
  61. data/lib/bolt/pal.rb +25 -11
  62. data/lib/bolt/plan_creator.rb +4 -4
  63. data/lib/bolt/plan_result.rb +2 -2
  64. data/lib/bolt/plugin/cache.rb +2 -2
  65. data/lib/bolt/plugin/module.rb +1 -1
  66. data/lib/bolt/plugin.rb +7 -7
  67. data/lib/bolt/project.rb +7 -5
  68. data/lib/bolt/project_manager/config_migrator.rb +1 -1
  69. data/lib/bolt/project_manager/inventory_migrator.rb +1 -1
  70. data/lib/bolt/project_manager/migrator.rb +1 -1
  71. data/lib/bolt/project_manager/module_migrator.rb +5 -5
  72. data/lib/bolt/project_manager.rb +23 -4
  73. data/lib/bolt/puppetdb/config.rb +1 -1
  74. data/lib/bolt/puppetdb.rb +3 -3
  75. data/lib/bolt/result.rb +1 -1
  76. data/lib/bolt/shell/bash.rb +14 -8
  77. data/lib/bolt/shell/powershell.rb +23 -4
  78. data/lib/bolt/shell.rb +2 -2
  79. data/lib/bolt/target.rb +2 -2
  80. data/lib/bolt/transport/base.rb +1 -1
  81. data/lib/bolt/transport/docker/connection.rb +1 -1
  82. data/lib/bolt/transport/docker.rb +2 -2
  83. data/lib/bolt/transport/local/connection.rb +2 -2
  84. data/lib/bolt/transport/local.rb +3 -3
  85. data/lib/bolt/transport/lxd/connection.rb +1 -1
  86. data/lib/bolt/transport/lxd.rb +4 -4
  87. data/lib/bolt/transport/orch.rb +2 -2
  88. data/lib/bolt/transport/podman/connection.rb +1 -1
  89. data/lib/bolt/transport/podman.rb +2 -2
  90. data/lib/bolt/transport/remote.rb +2 -2
  91. data/lib/bolt/transport/simple.rb +3 -3
  92. data/lib/bolt/transport/ssh/connection.rb +3 -3
  93. data/lib/bolt/transport/ssh.rb +5 -5
  94. data/lib/bolt/transport/winrm/connection.rb +2 -2
  95. data/lib/bolt/transport/winrm.rb +3 -3
  96. data/lib/bolt/util.rb +11 -31
  97. data/lib/bolt/validator.rb +1 -1
  98. data/lib/bolt/version.rb +1 -1
  99. data/lib/bolt.rb +1 -1
  100. data/lib/bolt_server/transport_app.rb +26 -5
  101. data/lib/bolt_spec/bolt_context.rb +6 -4
  102. data/lib/bolt_spec/plans/mock_executor.rb +3 -3
  103. data/libexec/bolt_catalog +1 -1
  104. metadata +6 -6
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'fileutils'
4
- require 'bolt/error'
5
- require 'bolt/util'
4
+ require_relative '../../bolt/error'
5
+ require_relative '../../bolt/util'
6
6
 
7
7
  module Bolt
8
8
  class Plugin
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/task/run'
3
+ require_relative '../../bolt/task/run'
4
4
 
5
5
  module Bolt
6
6
  class Plugin
data/lib/bolt/plugin.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/inventory'
4
- require 'bolt/executor'
5
- require 'bolt/module'
6
- require 'bolt/pal'
7
- require 'bolt/plugin/cache'
8
- require 'bolt/plugin/puppetdb'
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
- require 'bolt/plugin/module'
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
- require 'bolt/config'
5
- require 'bolt/validator'
6
- require 'bolt/pal'
7
- require 'bolt/module'
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
- require 'bolt/project_manager/migrator'
3
+ require_relative '../../bolt/project_manager/migrator'
4
4
 
5
5
  module Bolt
6
6
  class ProjectManager
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/project_manager/migrator'
3
+ require_relative '../../bolt/project_manager/migrator'
4
4
 
5
5
  module Bolt
6
6
  class ProjectManager
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'fileutils'
4
- require 'bolt/error'
4
+ require_relative '../../bolt/error'
5
5
 
6
6
  module Bolt
7
7
  class ProjectManager
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/project_manager/migrator'
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
- require 'bolt/module_installer/installer'
47
- require 'bolt/module_installer/puppetfile'
48
- require 'bolt/module_installer/resolver'
49
- require 'bolt/module_installer/specs'
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}")
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/project_manager/config_migrator'
4
- require 'bolt/project_manager/inventory_migrator'
5
- require 'bolt/project_manager/module_migrator'
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
- require 'bolt/module_installer'
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'bolt/util'
4
+ require_relative '../../bolt/util'
5
5
 
6
6
  module Bolt
7
7
  module PuppetDB
data/lib/bolt/puppetdb.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/puppetdb/client'
5
- require 'bolt/puppetdb/config'
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'bolt/error'
4
+ require_relative '../bolt/error'
5
5
 
6
6
  module Bolt
7
7
  class Result
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/shell/bash/tmpdir'
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
- output = execute([path, *arguments], environment: options[:env_vars], sudoable: true)
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
- '#{interpreter}' '#{task_path}' <<'EOF'
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
- if command.is_a?(Array)
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
- require 'bolt/shell/powershell/snippets'
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
- path, args = *process_from_extension(script_path)
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
- path = interpreter
265
- args = [task_path]
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
@@ -101,5 +101,5 @@ module Bolt
101
101
  end
102
102
  end
103
103
 
104
- require 'bolt/shell/bash'
105
- require 'bolt/shell/powershell'
104
+ require_relative 'shell/bash'
105
+ require_relative 'shell/powershell'
data/lib/bolt/target.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/util'
3
+ require_relative '../bolt/error'
4
+ require_relative '../bolt/util'
5
5
 
6
6
  module Bolt
7
7
  class Target
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logging'
4
- require 'bolt/result'
4
+ require_relative '../../bolt/result'
5
5
 
6
6
  module Bolt
7
7
  module Transport
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logging'
4
- require 'bolt/node/errors'
4
+ require_relative '../../../bolt/node/errors'
5
5
 
6
6
  module Bolt
7
7
  module Transport
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'json'
4
4
  require 'shellwords'
5
- require 'bolt/transport/simple'
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
- require 'bolt/transport/docker/connection'
23
+ require_relative 'docker/connection'
@@ -3,8 +3,8 @@
3
3
  require 'open3'
4
4
  require 'fileutils'
5
5
  require 'tempfile'
6
- require 'bolt/node/output'
7
- require 'bolt/util'
6
+ require_relative '../../../bolt/node/output'
7
+ require_relative '../../../bolt/util'
8
8
 
9
9
  module Bolt
10
10
  module Transport
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/logger'
4
- require 'bolt/transport/simple'
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
- require 'bolt/transport/local/connection'
24
+ require_relative 'local/connection'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logging'
4
- require 'bolt/node/errors'
4
+ require_relative '../../../bolt/node/errors'
5
5
 
6
6
  module Bolt
7
7
  module Transport
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/logger'
4
- require 'bolt/node/errors'
5
- require 'bolt/transport/simple'
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
- require 'bolt/transport/lxd/connection'
26
+ require_relative 'lxd/connection'
@@ -4,8 +4,8 @@ require 'base64'
4
4
  require 'find'
5
5
  require 'json'
6
6
  require 'pathname'
7
- require 'bolt/transport/base'
8
- require 'bolt/transport/orch/connection'
7
+ require_relative '../../bolt/transport/base'
8
+ require_relative 'orch/connection'
9
9
 
10
10
  module Bolt
11
11
  module Transport
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logging'
4
- require 'bolt/node/errors'
4
+ require_relative '../../../bolt/node/errors'
5
5
 
6
6
  module Bolt
7
7
  module Transport
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'json'
4
4
  require 'shellwords'
5
- require 'bolt/transport/base'
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
- require 'bolt/transport/podman/connection'
19
+ require_relative 'podman/connection'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/task'
4
- require 'bolt/transport/base'
3
+ require_relative '../../bolt/task'
4
+ require_relative '../../bolt/transport/base'
5
5
 
6
6
  module Bolt
7
7
  module Transport
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logging'
4
- require 'bolt/result'
5
- require 'bolt/shell'
6
- require 'bolt/transport/base'
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
- require 'bolt/node/errors'
6
- require 'bolt/node/output'
7
- require 'bolt/util'
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
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/logger'
4
- require 'bolt/node/errors'
5
- require 'bolt/transport/simple'
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
- require 'bolt/transport/ssh/connection'
48
- require 'bolt/transport/ssh/exec_connection'
47
+ require_relative 'ssh/connection'
48
+ require_relative 'ssh/exec_connection'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/node/errors'
4
- require 'bolt/node/output'
3
+ require_relative '../../../bolt/node/errors'
4
+ require_relative '../../../bolt/node/output'
5
5
 
6
6
  module Bolt
7
7
  module Transport
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/node/errors'
4
- require 'bolt/transport/base'
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
- require 'bolt/transport/winrm/connection'
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, fallback = false)
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
- find_file_in_module(mod_path, file_pattern, fallback) if mod_path
118
+ search_module(mod_path, file_pattern) if mod_path
116
119
  end
117
120
 
118
- # This method is used by Bolt to find files when provided a
119
- # module-style path without loading Puppet. It takes the absolute path to
120
- # the module root and the module-style path minus the module name and
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 find_file_in_module(module_path, module_file, fallback = false)
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)) && fallback
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
  #
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
3
+ require_relative '../bolt/error'
4
4
 
5
5
  # This class validates config against a schema, raising an error that includes
6
6
  # details about any invalid configuration.
data/lib/bolt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bolt
4
- VERSION = '3.17.0'
4
+ VERSION = '3.21.0'
5
5
  end