bolt 3.15.0 → 3.18.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 +7 -7
- 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 +4 -21
- data/lib/bolt/application.rb +627 -0
- 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 +27 -3
- data/lib/bolt/catalog.rb +10 -11
- data/lib/bolt/cli.rb +607 -809
- data/lib/bolt/config/modulepath.rb +1 -1
- data/lib/bolt/config/options.rb +32 -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/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 +5 -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 +9 -5
- data/lib/bolt/inventory/group.rb +4 -4
- data/lib/bolt/inventory/inventory.rb +64 -41
- data/lib/bolt/inventory/options.rb +1 -1
- data/lib/bolt/inventory/target.rb +1 -1
- data/lib/bolt/inventory.rb +10 -17
- 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 +27 -13
- 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 +85 -34
- data/lib/bolt/outputter/json.rb +63 -38
- 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 +11 -11
- data/lib/bolt/plan_creator.rb +88 -29
- data/lib/bolt/plan_future.rb +11 -6
- data/lib/bolt/plan_result.rb +3 -3
- data/lib/bolt/plugin/cache.rb +2 -2
- data/lib/bolt/plugin/module.rb +1 -1
- data/lib/bolt/plugin.rb +18 -24
- data/lib/bolt/project.rb +4 -11
- 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/result_set.rb +2 -1
- data/lib/bolt/shell/bash.rb +12 -2
- data/lib/bolt/shell/powershell.rb +9 -2
- 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 +19 -3
- 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/connection.rb +13 -1
- 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 +8 -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/file_cache.rb +12 -0
- data/lib/bolt_server/schemas/action-apply.json +32 -0
- data/lib/bolt_server/schemas/action-apply_prep.json +19 -0
- data/lib/bolt_server/transport_app.rb +129 -26
- data/lib/bolt_spec/bolt_context.rb +7 -5
- data/lib/bolt_spec/plans/mock_executor.rb +3 -3
- data/lib/bolt_spec/run.rb +1 -1
- data/libexec/bolt_catalog +1 -1
- metadata +7 -5
- data/lib/bolt/secret.rb +0 -37
data/lib/bolt/pal.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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:
|
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
|
data/lib/bolt/plan_creator.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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.
|
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
|
-
|
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
|
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
|
@@ -77,25 +92,7 @@ module Bolt
|
|
77
92
|
)
|
78
93
|
end
|
79
94
|
|
80
|
-
|
81
|
-
show_command = 'Get-BoltPlan -Name '
|
82
|
-
run_command = 'Invoke-BoltPlan -Name '
|
83
|
-
else
|
84
|
-
show_command = 'bolt plan show'
|
85
|
-
run_command = 'bolt plan run'
|
86
|
-
end
|
87
|
-
|
88
|
-
output = <<~OUTPUT
|
89
|
-
Created plan '#{plan_name}' at '#{plan_path}'
|
90
|
-
|
91
|
-
Show this plan with:
|
92
|
-
#{show_command} #{plan_name}
|
93
|
-
Run this plan with:
|
94
|
-
#{run_command} #{plan_name}
|
95
|
-
OUTPUT
|
96
|
-
|
97
|
-
outputter.print_message(output)
|
98
|
-
0
|
95
|
+
{ name: plan_name, path: plan_path }
|
99
96
|
end
|
100
97
|
|
101
98
|
def self.segment_plan_name(plan_name)
|
@@ -108,7 +105,11 @@ module Bolt
|
|
108
105
|
[prefix, name_segments, basename]
|
109
106
|
end
|
110
107
|
|
111
|
-
|
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)
|
112
113
|
<<~YAML
|
113
114
|
# This is the structure of a simple plan. To learn more about writing
|
114
115
|
# YAML plans, see the documentation: http://pup.pt/bolt-yaml-plans
|
@@ -137,7 +138,42 @@ module Bolt
|
|
137
138
|
YAML
|
138
139
|
end
|
139
140
|
|
140
|
-
|
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)
|
141
177
|
<<~PUPPET
|
142
178
|
# This is the structure of a simple plan. To learn more about writing
|
143
179
|
# Puppet plans, see the documentation: http://pup.pt/bolt-puppet-plans
|
@@ -156,5 +192,28 @@ module Bolt
|
|
156
192
|
}
|
157
193
|
PUPPET
|
158
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
|
159
218
|
end
|
160
219
|
end
|
data/lib/bolt/plan_future.rb
CHANGED
@@ -4,14 +4,19 @@ require 'fiber'
|
|
4
4
|
|
5
5
|
module Bolt
|
6
6
|
class PlanFuture
|
7
|
-
attr_reader :fiber, :id
|
7
|
+
attr_reader :fiber, :id, :scope
|
8
8
|
attr_accessor :value, :plan_stack
|
9
9
|
|
10
|
-
def initialize(fiber, id, plan_id:, name: nil)
|
11
|
-
@fiber
|
12
|
-
@id
|
13
|
-
@name
|
14
|
-
@value
|
10
|
+
def initialize(fiber, id, plan_id:, name: nil, scope: nil)
|
11
|
+
@fiber = fiber
|
12
|
+
@id = id
|
13
|
+
@name = name
|
14
|
+
@value = nil
|
15
|
+
|
16
|
+
# Default to Puppet's current global_scope, otherwise things will
|
17
|
+
# blow up when the Fiber Executor tries to override the global_scope.
|
18
|
+
@scope = scope || Puppet.lookup(:global_scope) { nil }
|
19
|
+
|
15
20
|
# The plan invocation ID when the Future is created may be
|
16
21
|
# different from the plan ID of the Future when we switch to it if a new
|
17
22
|
# plan was run inside the Future, so keep track of the plans that a
|
data/lib/bolt/plan_result.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'json'
|
4
|
-
|
5
|
-
|
4
|
+
require_relative '../bolt/error'
|
5
|
+
require_relative '../bolt/util'
|
6
6
|
|
7
7
|
module Bolt
|
8
8
|
class PlanResult
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :status, :value
|
10
10
|
|
11
11
|
# This must be called from inside a compiler
|
12
12
|
def self.from_pcore(result, status)
|
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
|
@@ -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
|
-
|
136
|
+
attr_writer :plugin_hooks
|
149
137
|
|
150
|
-
|
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
|
-
|
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
|
-
|
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
|
@@ -209,12 +209,5 @@ module Bolt
|
|
209
209
|
Bolt::Logger.warn("missing_project_name", message)
|
210
210
|
end
|
211
211
|
end
|
212
|
-
|
213
|
-
def check_deprecated_file
|
214
|
-
if (@path + 'project.yaml').file?
|
215
|
-
msg = "Project configuration file 'project.yaml' is deprecated; use 'bolt-project.yaml' instead."
|
216
|
-
Bolt::Logger.warn("project_yaml", msg)
|
217
|
-
end
|
218
|
-
end
|
219
212
|
end
|
220
213
|
end
|
@@ -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/result_set.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)
|
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
|
-
|
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
|
-
|
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
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'
|