bolt 3.16.1 → 3.17.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/lib/bolt/application.rb +28 -14
- data/lib/bolt/bolt_option_parser.rb +15 -0
- data/lib/bolt/cli.rb +2 -3
- data/lib/bolt/inventory/inventory.rb +68 -39
- data/lib/bolt/inventory.rb +2 -9
- data/lib/bolt/plan_creator.rb +83 -6
- data/lib/bolt/plugin.rb +11 -17
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/transport_app.rb +1 -1
- data/lib/bolt_spec/bolt_context.rb +1 -1
- data/lib/bolt_spec/run.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '05192d9aa9b3da414b55a21bd75fe10238e8044eb49f75f92be7fac1d0576866'
|
4
|
+
data.tar.gz: 49302c6d080fda48080d5281c9480ce35a734caefa5be9f6f141aaea51f99b70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd0966b7be3a7bba5a1bb0f040a2e8bd8c22708fa1a79492f04b8448037105ac66e12af74969787d3ab4efa69bfcd393c51168154c548d7d35f6f36fc6648c0c
|
7
|
+
data.tar.gz: e7f2741c6e7a2416ebbc61f7f008e1a550bde1897e906e53a8df0dc837cd4fcb0718c783f301cdbde1703ed95a65530cbad9e727ae5978a6c414988bc0206e23
|
data/lib/bolt/application.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'benchmark'
|
4
4
|
|
5
|
+
require 'bolt/plan_creator'
|
5
6
|
require 'bolt/util'
|
6
7
|
|
7
8
|
module Bolt
|
@@ -88,7 +89,7 @@ module Bolt
|
|
88
89
|
# @param env_vars [Hash] Environment variables to set on the target.
|
89
90
|
# @return [Bolt::ResultSet]
|
90
91
|
#
|
91
|
-
def run_command(command, targets, env_vars:
|
92
|
+
def run_command(command, targets, env_vars: nil)
|
92
93
|
targets = inventory.get_targets(targets)
|
93
94
|
|
94
95
|
with_benchmark do
|
@@ -120,8 +121,7 @@ module Bolt
|
|
120
121
|
# @return [Bolt::ResultSet]
|
121
122
|
#
|
122
123
|
def upload_file(source, destination, targets)
|
123
|
-
|
124
|
-
source = find_file(source, future)
|
124
|
+
source = find_file(source)
|
125
125
|
targets = inventory.get_targets(targets)
|
126
126
|
|
127
127
|
Bolt::Util.validate_file('source file', source, true)
|
@@ -327,11 +327,26 @@ module Bolt
|
|
327
327
|
#
|
328
328
|
# @param name [String] The name of the new plan.
|
329
329
|
# @param puppet [Boolean] Create a Puppet language plan.
|
330
|
+
# @param plan_script [String] Reference to the script to run in the new plan.
|
330
331
|
# @return [Boolean]
|
331
332
|
#
|
332
|
-
def new_plan(name, puppet: false)
|
333
|
-
Bolt::PlanCreator.
|
334
|
-
|
333
|
+
def new_plan(name, puppet: false, plan_script: nil)
|
334
|
+
Bolt::PlanCreator.validate_plan_name(config.project, name)
|
335
|
+
|
336
|
+
if plan_script && !config.future&.fetch('file_paths', false)
|
337
|
+
raise Bolt::CLIError,
|
338
|
+
"The --script flag can only be used if future.file_paths is " \
|
339
|
+
"configured in bolt-project.yaml."
|
340
|
+
end
|
341
|
+
|
342
|
+
if plan_script
|
343
|
+
Bolt::Util.validate_file('script', find_file(plan_script))
|
344
|
+
end
|
345
|
+
|
346
|
+
Bolt::PlanCreator.create_plan(config.project.plans_path,
|
347
|
+
name,
|
348
|
+
is_puppet: puppet,
|
349
|
+
script: plan_script)
|
335
350
|
end
|
336
351
|
|
337
352
|
# Run a plan.
|
@@ -433,9 +448,8 @@ module Bolt
|
|
433
448
|
# @param env_vars [Hash] Environment variables to set on the target.
|
434
449
|
# @return [Bolt::ResultSet]
|
435
450
|
#
|
436
|
-
def run_script(script, targets, arguments: [], env_vars:
|
437
|
-
|
438
|
-
script = find_file(script, future)
|
451
|
+
def run_script(script, targets, arguments: [], env_vars: nil)
|
452
|
+
script = find_file(script)
|
439
453
|
|
440
454
|
Bolt::Util.validate_file('script', script)
|
441
455
|
|
@@ -555,18 +569,18 @@ module Bolt
|
|
555
569
|
# directory.
|
556
570
|
#
|
557
571
|
# @param path [String] The path to the file.
|
558
|
-
# @param future_file_paths [Boolean] Whether to use future file path behavior.
|
559
572
|
#
|
560
|
-
private def find_file(path
|
573
|
+
private def find_file(path)
|
561
574
|
return path if File.exist?(path) || Pathname.new(path).absolute?
|
562
575
|
modulepath = Bolt::Config::Modulepath.new(config.modulepath)
|
563
576
|
modules = Bolt::Module.discover(modulepath.full_modulepath, config.project)
|
564
|
-
mod, file
|
577
|
+
mod, file = path.split(File::SEPARATOR, 2)
|
578
|
+
future = executor.future&.fetch('file_paths', false)
|
565
579
|
|
566
580
|
if modules[mod]
|
567
581
|
logger.debug("Did not find file at #{File.expand_path(path)}, checking in module '#{mod}'")
|
568
|
-
found = Bolt::Util.find_file_in_module(modules[mod].path, file || "",
|
569
|
-
path
|
582
|
+
found = Bolt::Util.find_file_in_module(modules[mod].path, file || "", future)
|
583
|
+
path = found.nil? ? File.join(modules[mod].path, 'files', file) : found
|
570
584
|
end
|
571
585
|
|
572
586
|
path
|
@@ -1042,6 +1042,21 @@ module Bolt
|
|
1042
1042
|
define('--pp', 'Create a new Puppet language plan.') do |_|
|
1043
1043
|
@options[:puppet] = true
|
1044
1044
|
end
|
1045
|
+
define('--script SCRIPT', 'Create a new plan that wraps a script.') do |path|
|
1046
|
+
# If the path is a relative, absolute, or not a scripts path, raise an
|
1047
|
+
# error. This flag is intended to be used to create shareable plans.
|
1048
|
+
#
|
1049
|
+
# This also limits valid mounts to files and scripts, which we may want
|
1050
|
+
# to expand in the future.
|
1051
|
+
if File.exist?(path) || Pathname.new(path).absolute? ||
|
1052
|
+
!%w[scripts files].include?(path.split(File::SEPARATOR)[1])
|
1053
|
+
raise Bolt::CLIError, "The script must be a detailed Puppet file reference, " \
|
1054
|
+
"for example 'mymodule/scripts/myscript.sh'. See http://pup.pt/bolt-scripts for " \
|
1055
|
+
"more information on detailed Puppet file references."
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
@options[:plan_script] = path
|
1059
|
+
end
|
1045
1060
|
|
1046
1061
|
separator "\n#{self.class.colorize(:cyan, 'Display options')}"
|
1047
1062
|
define('--filter FILTER', 'Filter tasks and plans by a matching substring.') do |filter|
|
data/lib/bolt/cli.rb
CHANGED
@@ -20,7 +20,6 @@ require 'bolt/logger'
|
|
20
20
|
require 'bolt/module_installer'
|
21
21
|
require 'bolt/outputter'
|
22
22
|
require 'bolt/pal'
|
23
|
-
require 'bolt/plan_creator'
|
24
23
|
require 'bolt/plugin'
|
25
24
|
require 'bolt/project_manager'
|
26
25
|
require 'bolt/puppetdb'
|
@@ -435,7 +434,7 @@ module Bolt
|
|
435
434
|
config.project
|
436
435
|
)
|
437
436
|
|
438
|
-
plugins = Bolt::Plugin.
|
437
|
+
plugins = Bolt::Plugin.new(config, pal, analytics)
|
439
438
|
|
440
439
|
inventory = Bolt::Inventory.from_config(config, plugins)
|
441
440
|
|
@@ -611,7 +610,7 @@ module Bolt
|
|
611
610
|
app.convert_plan(options[:object])
|
612
611
|
SUCCESS
|
613
612
|
when 'new'
|
614
|
-
result = app.new_plan(options[:object], **options.slice(:puppet))
|
613
|
+
result = app.new_plan(options[:object], **options.slice(:puppet, :plan_script))
|
615
614
|
outputter.print_new_plan(**result)
|
616
615
|
SUCCESS
|
617
616
|
when 'run'
|
@@ -6,7 +6,7 @@ require 'bolt/inventory/target'
|
|
6
6
|
module Bolt
|
7
7
|
class Inventory
|
8
8
|
class Inventory
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :plugins, :source, :targets, :transport
|
10
10
|
|
11
11
|
class WildcardError < Bolt::Error
|
12
12
|
def initialize(target)
|
@@ -14,25 +14,15 @@ module Bolt
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
# TODO: Pass transport config instead of config object
|
18
17
|
def initialize(data, transport, transports, plugins, source = nil)
|
19
|
-
@logger
|
20
|
-
@data
|
21
|
-
@transport
|
22
|
-
@config
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@source = source
|
28
|
-
|
29
|
-
@groups.resolve_string_targets(@groups.target_aliases, @groups.all_targets)
|
30
|
-
|
31
|
-
collect_groups
|
32
|
-
end
|
33
|
-
|
34
|
-
def validate
|
35
|
-
@groups.validate
|
18
|
+
@logger = Bolt::Logger.logger(self)
|
19
|
+
@data = data || {}
|
20
|
+
@transport = transport
|
21
|
+
@config = transports
|
22
|
+
@config_resolved = transports.values.all?(&:resolved?)
|
23
|
+
@plugins = plugins
|
24
|
+
@targets = {}
|
25
|
+
@source = source
|
36
26
|
end
|
37
27
|
|
38
28
|
def version
|
@@ -43,13 +33,52 @@ module Bolt
|
|
43
33
|
Bolt::Target
|
44
34
|
end
|
45
35
|
|
46
|
-
|
47
|
-
|
48
|
-
|
36
|
+
# Load and resolve the groups in the inventory. Loading groups resolves
|
37
|
+
# all plugin references except for those for target data and config.
|
38
|
+
#
|
39
|
+
# @return [Bolt::Inventory::Group]
|
40
|
+
#
|
41
|
+
def groups
|
42
|
+
@groups ||= Group.new(@data, @plugins, all_group: true).tap do |groups|
|
43
|
+
groups.resolve_string_targets(groups.target_aliases, groups.all_targets)
|
44
|
+
groups.validate
|
45
|
+
end
|
49
46
|
end
|
50
47
|
|
48
|
+
# Return a list of all group names in the inventory.
|
49
|
+
#
|
50
|
+
# @return [Array[String]]
|
51
|
+
#
|
51
52
|
def group_names
|
52
|
-
|
53
|
+
group_lookup.keys
|
54
|
+
end
|
55
|
+
|
56
|
+
# Return a map of all groups in the inventory.
|
57
|
+
#
|
58
|
+
# @return [Hash[String, Bolt::Inventory::Group]]
|
59
|
+
#
|
60
|
+
def group_lookup
|
61
|
+
@group_lookup ||= groups.collect_groups
|
62
|
+
end
|
63
|
+
|
64
|
+
# Return a map of transport configuration for the inventory. Any
|
65
|
+
# unresolved plugin references are resolved.
|
66
|
+
#
|
67
|
+
# @return [Hash[String, Bolt::Config::Transport]]
|
68
|
+
#
|
69
|
+
def config
|
70
|
+
if @config_resolved
|
71
|
+
@config
|
72
|
+
else
|
73
|
+
@config_resolved = true
|
74
|
+
@config.transform_values! { |t| t.resolved? ? t : t.resolve(@plugins) }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Validates the inventory.
|
79
|
+
#
|
80
|
+
def validate
|
81
|
+
groups.validate
|
53
82
|
end
|
54
83
|
|
55
84
|
def group_names_for(target_name)
|
@@ -57,7 +86,7 @@ module Bolt
|
|
57
86
|
end
|
58
87
|
|
59
88
|
def target_names
|
60
|
-
|
89
|
+
groups.all_targets
|
61
90
|
end
|
62
91
|
# alias for analytics
|
63
92
|
alias node_names target_names
|
@@ -81,7 +110,7 @@ module Bolt
|
|
81
110
|
|
82
111
|
#### PRIVATE ####
|
83
112
|
def group_data_for(target_name)
|
84
|
-
|
113
|
+
groups.group_collect(target_name)
|
85
114
|
end
|
86
115
|
|
87
116
|
# If target is a group name, expand it to the members of that group.
|
@@ -89,15 +118,15 @@ module Bolt
|
|
89
118
|
# If a wildcard string, error if no matches are found.
|
90
119
|
# Else fall back to [target] if no matches are found.
|
91
120
|
def resolve_name(target)
|
92
|
-
if (group =
|
121
|
+
if (group = group_lookup[target])
|
93
122
|
group.all_targets
|
94
123
|
else
|
95
124
|
# Try to wildcard match targets in inventory
|
96
125
|
# Ignore case because hostnames are generally case-insensitive
|
97
126
|
regexp = Regexp.new("^#{Regexp.escape(target).gsub('\*', '.*?')}$", Regexp::IGNORECASE)
|
98
127
|
|
99
|
-
targets =
|
100
|
-
targets +=
|
128
|
+
targets = groups.all_targets.select { |targ| targ =~ regexp }
|
129
|
+
targets += groups.target_aliases.select { |target_alias, _target| target_alias =~ regexp }.values
|
101
130
|
|
102
131
|
if targets.empty?
|
103
132
|
raise(WildcardError, target) if target.include?('*')
|
@@ -165,7 +194,7 @@ module Bolt
|
|
165
194
|
# associated references. This is used when a target is resolved by
|
166
195
|
# get_targets.
|
167
196
|
def create_target_from_inventory(target_name)
|
168
|
-
target_data =
|
197
|
+
target_data = groups.target_collect(target_name) || { 'uri' => target_name }
|
169
198
|
|
170
199
|
target = Bolt::Inventory::Target.new(target_data, self)
|
171
200
|
@targets[target.name] = target
|
@@ -187,24 +216,24 @@ module Bolt
|
|
187
216
|
@targets[new_target.name] = new_target
|
188
217
|
|
189
218
|
if existing_target
|
190
|
-
clear_alia_from_group(
|
219
|
+
clear_alia_from_group(groups, new_target.name)
|
191
220
|
else
|
192
221
|
add_to_group([new_target], 'all')
|
193
222
|
end
|
194
223
|
|
195
224
|
if new_target.target_alias
|
196
|
-
|
225
|
+
groups.insert_alia(new_target.name, Array(new_target.target_alias))
|
197
226
|
end
|
198
227
|
|
199
228
|
new_target
|
200
229
|
end
|
201
230
|
|
202
231
|
def validate_target_from_hash(target)
|
203
|
-
|
204
|
-
|
232
|
+
used_groups = Set.new(group_names)
|
233
|
+
used_targets = target_names
|
205
234
|
|
206
235
|
# Make sure there are no group name conflicts
|
207
|
-
if
|
236
|
+
if used_groups.include?(target.name)
|
208
237
|
raise ValidationError.new("Target name #{target.name} conflicts with group of the same name", nil)
|
209
238
|
end
|
210
239
|
|
@@ -217,11 +246,11 @@ module Bolt
|
|
217
246
|
end
|
218
247
|
|
219
248
|
# Make sure there are no conflicts with the new target aliases
|
220
|
-
used_aliases =
|
249
|
+
used_aliases = groups.target_aliases
|
221
250
|
Array(target.target_alias).each do |alia|
|
222
|
-
if
|
251
|
+
if used_groups.include?(alia)
|
223
252
|
raise ValidationError.new("Alias #{alia} conflicts with group of the same name", nil)
|
224
|
-
elsif
|
253
|
+
elsif used_targets.include?(alia)
|
225
254
|
raise ValidationError.new("Alias #{alia} conflicts with target of the same name", nil)
|
226
255
|
elsif used_aliases[alia] && used_aliases[alia] != target.name
|
227
256
|
raise ValidationError.new(
|
@@ -250,7 +279,7 @@ module Bolt
|
|
250
279
|
end
|
251
280
|
|
252
281
|
if group_names.include?(desired_group)
|
253
|
-
remove_target(
|
282
|
+
remove_target(groups, @targets[target.first.name], desired_group)
|
254
283
|
else
|
255
284
|
raise ValidationError.new("Group #{desired_group} does not exist in inventory", nil)
|
256
285
|
end
|
@@ -260,7 +289,7 @@ module Bolt
|
|
260
289
|
if group_names.include?(desired_group)
|
261
290
|
targets.each do |target|
|
262
291
|
# Add the inventory copy of the target
|
263
|
-
add_target(
|
292
|
+
add_target(groups, @targets[target.name], desired_group)
|
264
293
|
end
|
265
294
|
else
|
266
295
|
raise ValidationError.new("Group #{desired_group} does not exist in inventory", nil)
|
data/lib/bolt/inventory.rb
CHANGED
@@ -91,19 +91,12 @@ module Bolt
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
# Resolve plugin references from transport config
|
95
|
-
config.transports.each_value do |t|
|
96
|
-
t.resolve(plugins) unless t.resolved?
|
97
|
-
end
|
98
|
-
|
99
94
|
Bolt::Validator.new.tap do |validator|
|
100
95
|
validator.validate(data, schema, source)
|
101
96
|
validator.warnings.each { |warning| Bolt::Logger.warn(warning[:id], warning[:msg]) }
|
102
97
|
end
|
103
98
|
|
104
|
-
|
105
|
-
inventory.validate
|
106
|
-
inventory
|
99
|
+
create_version(data, config.transport, config.transports, plugins, source)
|
107
100
|
end
|
108
101
|
|
109
102
|
def self.create_version(data, transport, transports, plugins, source = nil)
|
@@ -119,7 +112,7 @@ module Bolt
|
|
119
112
|
|
120
113
|
def self.empty
|
121
114
|
config = Bolt::Config.default
|
122
|
-
plugins = Bolt::Plugin.
|
115
|
+
plugins = Bolt::Plugin.new(config, nil)
|
123
116
|
|
124
117
|
create_version({}, config.transport, config.transports, plugins, nil)
|
125
118
|
end
|
data/lib/bolt/plan_creator.rb
CHANGED
@@ -7,7 +7,7 @@ require '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
|
@@ -90,7 +105,11 @@ module Bolt
|
|
90
105
|
[prefix, name_segments, basename]
|
91
106
|
end
|
92
107
|
|
93
|
-
|
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
|
-
|
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
|
data/lib/bolt/plugin.rb
CHANGED
@@ -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
|
data/lib/bolt/version.rb
CHANGED
@@ -832,7 +832,7 @@ module BoltServer
|
|
832
832
|
}
|
833
833
|
|
834
834
|
connect_plugin = BoltServer::Plugin::PuppetConnectData.new(body['puppet_connect_data'])
|
835
|
-
plugins = Bolt::Plugin.
|
835
|
+
plugins = Bolt::Plugin.new(context[:config], context[:pal], load_plugins: false)
|
836
836
|
plugins.add_plugin(connect_plugin)
|
837
837
|
%w[aws_inventory azure_inventory gcloud_inventory].each do |plugin_name|
|
838
838
|
plugins.add_module_plugin(plugin_name) if plugins.known_plugin?(plugin_name)
|
data/lib/bolt_spec/run.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bolt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|