bolt 3.16.0 → 3.19.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 (106) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +15 -15
  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 +24 -17
  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 +15 -0
  14. data/lib/bolt/catalog.rb +10 -11
  15. data/lib/bolt/cli.rb +20 -22
  16. data/lib/bolt/config/modulepath.rb +1 -1
  17. data/lib/bolt/config/options.rb +32 -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/orch.rb +2 -2
  23. data/lib/bolt/config/transport/podman.rb +2 -2
  24. data/lib/bolt/config/transport/remote.rb +2 -2
  25. data/lib/bolt/config/transport/ssh.rb +2 -2
  26. data/lib/bolt/config/transport/winrm.rb +2 -2
  27. data/lib/bolt/config.rb +5 -5
  28. data/lib/bolt/container_result.rb +2 -2
  29. data/lib/bolt/error.rb +1 -1
  30. data/lib/bolt/executor.rb +17 -14
  31. data/lib/bolt/fiber_executor.rb +2 -2
  32. data/lib/bolt/inventory/group.rb +4 -4
  33. data/lib/bolt/inventory/inventory.rb +64 -41
  34. data/lib/bolt/inventory/options.rb +1 -1
  35. data/lib/bolt/inventory/target.rb +1 -1
  36. data/lib/bolt/inventory.rb +10 -17
  37. data/lib/bolt/module_installer/installer.rb +2 -2
  38. data/lib/bolt/module_installer/puppetfile/forge_module.rb +1 -1
  39. data/lib/bolt/module_installer/puppetfile/git_module.rb +1 -1
  40. data/lib/bolt/module_installer/puppetfile/module.rb +1 -1
  41. data/lib/bolt/module_installer/puppetfile.rb +27 -13
  42. data/lib/bolt/module_installer/resolver.rb +3 -3
  43. data/lib/bolt/module_installer/specs/forge_spec.rb +1 -1
  44. data/lib/bolt/module_installer/specs/git_spec.rb +1 -1
  45. data/lib/bolt/module_installer/specs.rb +3 -3
  46. data/lib/bolt/module_installer.rb +6 -6
  47. data/lib/bolt/node/errors.rb +1 -1
  48. data/lib/bolt/node/output.rb +1 -1
  49. data/lib/bolt/outputter/human.rb +2 -2
  50. data/lib/bolt/outputter/logger.rb +1 -1
  51. data/lib/bolt/outputter/rainbow.rb +1 -1
  52. data/lib/bolt/outputter.rb +4 -4
  53. data/lib/bolt/pal/logging.rb +1 -1
  54. data/lib/bolt/pal/yaml_plan/evaluator.rb +1 -1
  55. data/lib/bolt/pal/yaml_plan/loader.rb +2 -2
  56. data/lib/bolt/pal/yaml_plan/step.rb +11 -11
  57. data/lib/bolt/pal/yaml_plan/transpiler.rb +3 -3
  58. data/lib/bolt/pal/yaml_plan.rb +2 -2
  59. data/lib/bolt/pal.rb +11 -11
  60. data/lib/bolt/plan_creator.rb +87 -10
  61. data/lib/bolt/plan_result.rb +2 -2
  62. data/lib/bolt/plugin/cache.rb +2 -2
  63. data/lib/bolt/plugin/module.rb +1 -1
  64. data/lib/bolt/plugin.rb +18 -24
  65. data/lib/bolt/project.rb +4 -4
  66. data/lib/bolt/project_manager/config_migrator.rb +1 -1
  67. data/lib/bolt/project_manager/inventory_migrator.rb +1 -1
  68. data/lib/bolt/project_manager/migrator.rb +1 -1
  69. data/lib/bolt/project_manager/module_migrator.rb +5 -5
  70. data/lib/bolt/project_manager.rb +23 -4
  71. data/lib/bolt/puppetdb/config.rb +1 -1
  72. data/lib/bolt/puppetdb.rb +3 -3
  73. data/lib/bolt/result.rb +1 -1
  74. data/lib/bolt/shell/bash.rb +12 -2
  75. data/lib/bolt/shell/powershell.rb +9 -2
  76. data/lib/bolt/shell.rb +2 -2
  77. data/lib/bolt/target.rb +2 -2
  78. data/lib/bolt/transport/base.rb +1 -1
  79. data/lib/bolt/transport/docker/connection.rb +1 -1
  80. data/lib/bolt/transport/docker.rb +2 -2
  81. data/lib/bolt/transport/local/connection.rb +2 -2
  82. data/lib/bolt/transport/local.rb +3 -3
  83. data/lib/bolt/transport/lxd/connection.rb +1 -1
  84. data/lib/bolt/transport/lxd.rb +4 -4
  85. data/lib/bolt/transport/orch.rb +2 -2
  86. data/lib/bolt/transport/podman/connection.rb +1 -1
  87. data/lib/bolt/transport/podman.rb +2 -2
  88. data/lib/bolt/transport/remote.rb +2 -2
  89. data/lib/bolt/transport/simple.rb +3 -3
  90. data/lib/bolt/transport/ssh/connection.rb +3 -3
  91. data/lib/bolt/transport/ssh.rb +5 -5
  92. data/lib/bolt/transport/winrm/connection.rb +2 -2
  93. data/lib/bolt/transport/winrm.rb +3 -3
  94. data/lib/bolt/util.rb +8 -31
  95. data/lib/bolt/validator.rb +1 -1
  96. data/lib/bolt/version.rb +1 -1
  97. data/lib/bolt.rb +1 -1
  98. data/lib/bolt_server/file_cache.rb +12 -0
  99. data/lib/bolt_server/schemas/action-apply.json +32 -0
  100. data/lib/bolt_server/schemas/action-apply_prep.json +19 -0
  101. data/lib/bolt_server/transport_app.rb +139 -29
  102. data/lib/bolt_spec/bolt_context.rb +7 -5
  103. data/lib/bolt_spec/plans/mock_executor.rb +3 -3
  104. data/lib/bolt_spec/run.rb +1 -1
  105. data/libexec/bolt_catalog +1 -1
  106. metadata +6 -4
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/pal/yaml_plan/loader'
5
- require 'bolt/util'
3
+ require_relative '../../../bolt/error'
4
+ require_relative '../../../bolt/pal/yaml_plan/loader'
5
+ require_relative '../../../bolt/util'
6
6
 
7
7
  module Bolt
8
8
  class PAL
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/pal/yaml_plan/parameter'
4
- require 'bolt/pal/yaml_plan/step'
3
+ require_relative 'yaml_plan/parameter'
4
+ require_relative 'yaml_plan/step'
5
5
 
6
6
  module Bolt
7
7
  class PAL
data/lib/bolt/pal.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/applicator'
4
- require 'bolt/executor'
5
- require 'bolt/error'
6
- require 'bolt/plan_result'
7
- require 'bolt/util'
8
- require 'bolt/config/modulepath'
3
+ require_relative '../bolt/applicator'
4
+ require_relative '../bolt/executor'
5
+ require_relative '../bolt/error'
6
+ require_relative '../bolt/plan_result'
7
+ require_relative '../bolt/util'
8
+ require_relative '../bolt/config/modulepath'
9
9
  require 'etc'
10
10
 
11
11
  module Bolt
@@ -101,10 +101,10 @@ module Bolt
101
101
  raise Bolt::Error.new("Puppet must be installed to execute tasks", "bolt/puppet-missing")
102
102
  end
103
103
 
104
- require 'bolt/pal/logging'
105
- require 'bolt/pal/issues'
106
- require 'bolt/pal/yaml_plan/loader'
107
- require 'bolt/pal/yaml_plan/transpiler'
104
+ require_relative 'pal/logging'
105
+ require_relative 'pal/issues'
106
+ require_relative 'pal/yaml_plan/loader'
107
+ require_relative 'pal/yaml_plan/transpiler'
108
108
 
109
109
  # Now that puppet is loaded we can include puppet mixins in data types
110
110
  Bolt::ResultSet.include_iterable
@@ -736,7 +736,7 @@ module Bolt
736
736
  #
737
737
  # Every future except for the main plan needs to have a plan id in
738
738
  # order to be tracked for the `wait()` function with no arguments.
739
- future = executor.create_future(name: plan_name, plan_id: 1) do |_scope|
739
+ future = executor.create_future(name: plan_name, plan_id: 0) do |_scope|
740
740
  r = compiler.call_function('run_plan', plan_name, params.merge('_bolt_api_call' => true))
741
741
  Bolt::PlanResult.from_pcore(r, 'success')
742
742
  rescue Bolt::Error => e
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bolt/error'
4
- require 'bolt/logger'
5
- require 'bolt/module'
6
- require 'bolt/util'
3
+ require_relative '../bolt/error'
4
+ require_relative '../bolt/logger'
5
+ require_relative '../bolt/module'
6
+ require_relative '../bolt/util'
7
7
 
8
8
  module Bolt
9
9
  module PlanCreator
10
- def self.validate_input(project, plan_name)
10
+ def self.validate_plan_name(project, plan_name)
11
11
  if project.name.nil?
12
12
  raise Bolt::Error.new(
13
13
  "Project directory '#{project.path}' is not a named project. Unable to create "\
@@ -51,7 +51,15 @@ module Bolt
51
51
  end
52
52
  end
53
53
 
54
- def self.create_plan(plans_path, plan_name, is_puppet)
54
+ # Create a new plan from the plan templates based on which language the
55
+ # user configured, and whether the plan wraps a script.
56
+ #
57
+ # @param plans_path [string] The path to the new plan
58
+ # @param plan_name [string] The name of the new plan
59
+ # @param is_puppet [boolean] Whether to create a Puppet language plan
60
+ # @param script [string] A reference to a script for the new plan to run
61
+ #
62
+ def self.create_plan(plans_path, plan_name, is_puppet: false, script: nil)
55
63
  _, name_segments, basename = segment_plan_name(plan_name)
56
64
  dir_path = plans_path.join(*name_segments)
57
65
 
@@ -66,8 +74,15 @@ module Bolt
66
74
 
67
75
  type = is_puppet ? 'pp' : 'yaml'
68
76
  plan_path = dir_path + "#{basename}.#{type}"
69
- plan_template = is_puppet ? puppet_plan(plan_name) : yaml_plan(plan_name)
70
-
77
+ plan_template = if is_puppet && script
78
+ puppet_script_plan(plan_name, script)
79
+ elsif is_puppet
80
+ puppet_plan(plan_name)
81
+ elsif script
82
+ yaml_script_plan(script)
83
+ else
84
+ yaml_plan(plan_name)
85
+ end
71
86
  begin
72
87
  File.write(plan_path, plan_template)
73
88
  rescue Errno::EACCES => e
@@ -90,7 +105,11 @@ module Bolt
90
105
  [prefix, name_segments, basename]
91
106
  end
92
107
 
93
- def self.yaml_plan(plan_name)
108
+ # Template for a new simple YAML plan.
109
+ #
110
+ # @param plan_name [string] The name of the new plan
111
+ #
112
+ private_class_method def self.yaml_plan(plan_name)
94
113
  <<~YAML
95
114
  # This is the structure of a simple plan. To learn more about writing
96
115
  # YAML plans, see the documentation: http://pup.pt/bolt-yaml-plans
@@ -119,7 +138,42 @@ module Bolt
119
138
  YAML
120
139
  end
121
140
 
122
- def self.puppet_plan(plan_name)
141
+ # Template for a new YAML plan that runs a script.
142
+ #
143
+ # @param script [string] A reference to the script to run.
144
+ #
145
+ private_class_method def self.yaml_script_plan(script)
146
+ <<~YAML
147
+ # This is the structure of a simple plan. To learn more about writing
148
+ # YAML plans, see the documentation: http://pup.pt/bolt-yaml-plans
149
+
150
+ # The description sets the description of the plan that will appear
151
+ # in 'bolt plan show' output.
152
+ description: A plan created with bolt plan new
153
+
154
+ # The parameters key defines the parameters that can be passed to
155
+ # the plan.
156
+ parameters:
157
+ targets:
158
+ type: TargetSpec
159
+ description: A list of targets to run actions on
160
+
161
+ # The steps key defines the actions the plan will take in order.
162
+ steps:
163
+ - name: run_script
164
+ script: #{script}
165
+ targets: $targets
166
+
167
+ # The return key sets the return value of the plan.
168
+ return: $run_script
169
+ YAML
170
+ end
171
+
172
+ # Template for a new simple Puppet plan.
173
+ #
174
+ # @param plan_name [string] The name of the new plan
175
+ #
176
+ private_class_method def self.puppet_plan(plan_name)
123
177
  <<~PUPPET
124
178
  # This is the structure of a simple plan. To learn more about writing
125
179
  # Puppet plans, see the documentation: http://pup.pt/bolt-puppet-plans
@@ -138,5 +192,28 @@ module Bolt
138
192
  }
139
193
  PUPPET
140
194
  end
195
+
196
+ # Template for a new Puppet plan that only runs a script.
197
+ #
198
+ # @param plan_name [string] The name of the new plan
199
+ # @param script [string] A reference to the script to run
200
+ #
201
+ private_class_method def self.puppet_script_plan(plan_name, script)
202
+ <<~PUPPET
203
+ # This is the structure of a simple plan. To learn more about writing
204
+ # Puppet plans, see the documentation: http://pup.pt/bolt-puppet-plans
205
+
206
+ # The summary sets the description of the plan that will appear
207
+ # in 'bolt plan show' output. Bolt uses puppet-strings to parse the
208
+ # summary and parameters from the plan.
209
+ # @summary A plan created with bolt plan new.
210
+ # @param targets The targets to run on.
211
+ plan #{plan_name} (
212
+ TargetSpec $targets
213
+ ) {
214
+ return run_script('#{script}', $targets)
215
+ }
216
+ PUPPET
217
+ end
141
218
  end
142
219
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
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 PlanResult
@@ -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
@@ -127,29 +127,15 @@ module Bolt
127
127
  end
128
128
  end
129
129
 
130
- def self.setup(config, pal, analytics = Bolt::Analytics::NoopClient.new, **opts)
131
- plugins = new(config, pal, analytics, **opts)
132
-
133
- config.plugins.each_key do |plugin|
134
- plugins.by_name(plugin)
135
- end
136
-
137
- plugins.plugin_hooks.merge!(plugins.resolve_references(config.plugin_hooks))
138
-
139
- plugins
140
- end
141
-
142
130
  RUBY_PLUGINS = %w[task prompt env_var puppetdb puppet_connect_data].freeze
143
131
  BUILTIN_PLUGINS = %w[task terraform pkcs7 prompt vault aws_inventory puppetdb azure_inventory
144
132
  yaml env_var gcloud_inventory].freeze
145
133
  DEFAULT_PLUGIN_HOOKS = { 'puppet_library' => { 'plugin' => 'puppet_agent', 'stop_service' => true } }.freeze
146
134
 
147
135
  attr_reader :pal, :plugin_context
148
- attr_accessor :plugin_hooks
136
+ attr_writer :plugin_hooks
149
137
 
150
- private_class_method :new
151
-
152
- def initialize(config, pal, analytics, load_plugins: true)
138
+ def initialize(config, pal, analytics = Bolt::Analytics::NoopClient.new, load_plugins: true)
153
139
  @config = config
154
140
  @analytics = analytics
155
141
  @plugin_context = PluginContext.new(config, pal, self)
@@ -166,7 +152,15 @@ module Bolt
166
152
  raise Bolt::Error.new(msg, 'bolt/plugin-error')
167
153
  end
168
154
  @unresolved_plugin_configs['puppetdb'] = config.puppetdb if config.puppetdb
169
- @plugin_hooks = DEFAULT_PLUGIN_HOOKS.dup
155
+ end
156
+
157
+ # Returns a map of configured plugin hooks. Any unresolved plugin references
158
+ # are resolved.
159
+ #
160
+ # @return [Hash[String, Hash]]
161
+ #
162
+ def plugin_hooks
163
+ @plugin_hooks ||= DEFAULT_PLUGIN_HOOKS.merge(resolve_references(@config.plugin_hooks))
170
164
  end
171
165
 
172
166
  def modules
@@ -382,4 +376,4 @@ module Bolt
382
376
  end
383
377
 
384
378
  # references PluginError
385
- 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
@@ -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)
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',
@@ -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,14 @@ 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
+ path = interpreter
218
+ args = escape_arguments([script_path])
219
+ logger.trace("Running '#{script_path}' using '#{interpreter}' interpreter")
220
+ else
221
+ path, args = *process_from_extension(script_path)
222
+ end
216
223
  args += escape_arguments(arguments)
217
224
  execute_process(path, args)
218
225
  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