bolt 2.26.0 → 2.31.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 +13 -12
- data/bolt-modules/boltlib/lib/puppet/functions/write_file.rb +2 -2
- data/lib/bolt/analytics.rb +4 -0
- data/lib/bolt/applicator.rb +19 -18
- data/lib/bolt/bolt_option_parser.rb +112 -22
- data/lib/bolt/catalog.rb +1 -1
- data/lib/bolt/cli.rb +210 -174
- data/lib/bolt/config.rb +22 -2
- data/lib/bolt/config/modulepath.rb +30 -0
- data/lib/bolt/config/options.rb +30 -0
- data/lib/bolt/config/transport/options.rb +1 -1
- data/lib/bolt/executor.rb +1 -1
- data/lib/bolt/inventory.rb +11 -10
- data/lib/bolt/logger.rb +26 -19
- data/lib/bolt/module_installer.rb +242 -0
- data/lib/bolt/outputter.rb +4 -0
- data/lib/bolt/outputter/human.rb +77 -17
- data/lib/bolt/outputter/json.rb +21 -6
- data/lib/bolt/outputter/logger.rb +2 -2
- data/lib/bolt/pal.rb +46 -25
- data/lib/bolt/plugin.rb +1 -1
- data/lib/bolt/plugin/module.rb +1 -1
- data/lib/bolt/project.rb +62 -12
- data/lib/bolt/project_migrator.rb +80 -0
- data/lib/bolt/project_migrator/base.rb +39 -0
- data/lib/bolt/project_migrator/config.rb +67 -0
- data/lib/bolt/project_migrator/inventory.rb +67 -0
- data/lib/bolt/project_migrator/modules.rb +198 -0
- data/lib/bolt/puppetfile.rb +149 -0
- data/lib/bolt/puppetfile/installer.rb +43 -0
- data/lib/bolt/puppetfile/module.rb +93 -0
- data/lib/bolt/rerun.rb +1 -1
- data/lib/bolt/result.rb +15 -0
- data/lib/bolt/shell/bash.rb +4 -3
- data/lib/bolt/transport/base.rb +4 -4
- data/lib/bolt/transport/ssh/connection.rb +1 -1
- data/lib/bolt/util.rb +51 -10
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/acl.rb +2 -2
- data/lib/bolt_server/base_config.rb +3 -3
- data/lib/bolt_server/config.rb +1 -1
- data/lib/bolt_server/file_cache.rb +11 -11
- data/lib/bolt_server/transport_app.rb +206 -27
- data/lib/bolt_spec/bolt_context.rb +8 -6
- data/lib/bolt_spec/plans.rb +1 -1
- data/lib/bolt_spec/plans/mock_executor.rb +1 -1
- data/lib/bolt_spec/run.rb +1 -1
- metadata +14 -6
- data/lib/bolt/project_migrate.rb +0 -138
- data/lib/bolt_server/pe/pal.rb +0 -67
data/lib/bolt_spec/run.rb
CHANGED
@@ -179,7 +179,7 @@ module BoltSpec
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def pal
|
182
|
-
@pal ||= Bolt::PAL.new(config.modulepath,
|
182
|
+
@pal ||= Bolt::PAL.new(Bolt::Config::Modulepath.new(config.modulepath),
|
183
183
|
config.hiera_config,
|
184
184
|
config.project.resource_types,
|
185
185
|
config.compile_concurrency)
|
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: 2.
|
4
|
+
version: 2.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -198,14 +198,14 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 0.
|
201
|
+
version: '0.4'
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: 0.
|
208
|
+
version: '0.4'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: puppet-resource_api
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -444,6 +444,7 @@ files:
|
|
444
444
|
- lib/bolt/catalog/logging.rb
|
445
445
|
- lib/bolt/cli.rb
|
446
446
|
- lib/bolt/config.rb
|
447
|
+
- lib/bolt/config/modulepath.rb
|
447
448
|
- lib/bolt/config/options.rb
|
448
449
|
- lib/bolt/config/transport/base.rb
|
449
450
|
- lib/bolt/config/transport/docker.rb
|
@@ -461,6 +462,7 @@ files:
|
|
461
462
|
- lib/bolt/inventory/target.rb
|
462
463
|
- lib/bolt/logger.rb
|
463
464
|
- lib/bolt/module.rb
|
465
|
+
- lib/bolt/module_installer.rb
|
464
466
|
- lib/bolt/node/errors.rb
|
465
467
|
- lib/bolt/node/output.rb
|
466
468
|
- lib/bolt/outputter.rb
|
@@ -494,10 +496,17 @@ files:
|
|
494
496
|
- lib/bolt/plugin/puppetdb.rb
|
495
497
|
- lib/bolt/plugin/task.rb
|
496
498
|
- lib/bolt/project.rb
|
497
|
-
- lib/bolt/
|
499
|
+
- lib/bolt/project_migrator.rb
|
500
|
+
- lib/bolt/project_migrator/base.rb
|
501
|
+
- lib/bolt/project_migrator/config.rb
|
502
|
+
- lib/bolt/project_migrator/inventory.rb
|
503
|
+
- lib/bolt/project_migrator/modules.rb
|
498
504
|
- lib/bolt/puppetdb.rb
|
499
505
|
- lib/bolt/puppetdb/client.rb
|
500
506
|
- lib/bolt/puppetdb/config.rb
|
507
|
+
- lib/bolt/puppetfile.rb
|
508
|
+
- lib/bolt/puppetfile/installer.rb
|
509
|
+
- lib/bolt/puppetfile/module.rb
|
501
510
|
- lib/bolt/r10k_log_proxy.rb
|
502
511
|
- lib/bolt/rerun.rb
|
503
512
|
- lib/bolt/resource_instance.rb
|
@@ -534,7 +543,6 @@ files:
|
|
534
543
|
- lib/bolt_server/base_config.rb
|
535
544
|
- lib/bolt_server/config.rb
|
536
545
|
- lib/bolt_server/file_cache.rb
|
537
|
-
- lib/bolt_server/pe/pal.rb
|
538
546
|
- lib/bolt_server/schemas/action-check_node_connections.json
|
539
547
|
- lib/bolt_server/schemas/action-run_command.json
|
540
548
|
- lib/bolt_server/schemas/action-run_script.json
|
data/lib/bolt/project_migrate.rb
DELETED
@@ -1,138 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bolt
|
4
|
-
class ProjectMigrate
|
5
|
-
attr_reader :path, :project_file, :backup_dir, :outputter, :inventory_file, :config_file
|
6
|
-
|
7
|
-
# This init mostly makes testing easier
|
8
|
-
def initialize(path, outputter, configured_inventory = nil)
|
9
|
-
@path = Pathname.new(path).expand_path
|
10
|
-
@project_file = @path + 'bolt-project.yaml'
|
11
|
-
@config_file = @path + 'bolt.yaml'
|
12
|
-
@backup_dir = @path + '.bolt-bak'
|
13
|
-
@inventory_file = configured_inventory || @path + 'inventory.yaml'
|
14
|
-
@outputter = outputter
|
15
|
-
end
|
16
|
-
|
17
|
-
def migrate_project
|
18
|
-
inv_ok = inventory_1_to_2(inventory_file, outputter) if inventory_file.file?
|
19
|
-
config_ok = bolt_yaml_to_bolt_project(inventory_file, outputter)
|
20
|
-
inv_ok && config_ok ? 0 : 1
|
21
|
-
end
|
22
|
-
|
23
|
-
# This could be made public and used elsewhere if the need arises
|
24
|
-
private def backup_file(origin_path)
|
25
|
-
unless File.exist?(origin_path)
|
26
|
-
outputter.print_message "Could not find file #{origin_path}, skipping backup."
|
27
|
-
return
|
28
|
-
end
|
29
|
-
|
30
|
-
date = Time.new.strftime("%Y%m%d_%H%M%S%L")
|
31
|
-
FileUtils.mkdir_p(backup_dir)
|
32
|
-
|
33
|
-
filename = File.basename(origin_path)
|
34
|
-
backup_path = File.join(backup_dir, "#{filename}.#{date}.bak")
|
35
|
-
|
36
|
-
outputter.print_message "Backing up #{filename} from #{origin_path} to #{backup_path}"
|
37
|
-
|
38
|
-
begin
|
39
|
-
FileUtils.cp(origin_path, backup_path)
|
40
|
-
rescue StandardError => e
|
41
|
-
raise Bolt::FileError.new("#{e.message}; unable to create backup of #{filename}.", origin_path)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private def bolt_yaml_to_bolt_project(inventory_file, outputter)
|
46
|
-
# If bolt-project.yaml already exists
|
47
|
-
if project_file.file?
|
48
|
-
outputter.print_message "bolt-project.yaml already exists in Bolt "\
|
49
|
-
"project at #{path}. Skipping project file update."
|
50
|
-
|
51
|
-
# If bolt.yaml doesn't exist
|
52
|
-
elsif !config_file.file?
|
53
|
-
outputter.print_message "Could not find bolt.yaml in project at "\
|
54
|
-
"#{path}. Skipping project file update."
|
55
|
-
|
56
|
-
else
|
57
|
-
config_data = Bolt::Util.read_optional_yaml_hash(config_file, 'config')
|
58
|
-
transport_data, project_data = config_data.partition do |k, _|
|
59
|
-
Bolt::Config::INVENTORY_OPTIONS.keys.include?(k)
|
60
|
-
end.map(&:to_h)
|
61
|
-
|
62
|
-
if transport_data.any?
|
63
|
-
if File.exist?(inventory_file)
|
64
|
-
inventory_data = Bolt::Util.read_yaml_hash(inventory_file, 'inventory')
|
65
|
-
merged = Bolt::Util.deep_merge(transport_data, inventory_data['config'] || {})
|
66
|
-
inventory_data['config'] = merged
|
67
|
-
backup_file(inventory_file)
|
68
|
-
else
|
69
|
-
FileUtils.touch(inventory_file)
|
70
|
-
inventory_data = { 'config' => transport_data }
|
71
|
-
end
|
72
|
-
|
73
|
-
backup_file(config_file)
|
74
|
-
|
75
|
-
begin
|
76
|
-
outputter.print_message "Moving transportation configuration options "\
|
77
|
-
"'#{transport_data.keys.join(', ')}' from bolt.yaml to inventory.yaml"
|
78
|
-
File.write(inventory_file, inventory_data.to_yaml)
|
79
|
-
File.write(config_file, project_data.to_yaml)
|
80
|
-
rescue StandardError => e
|
81
|
-
raise Bolt::FileError.new("#{e.message}; unable to write inventory.", inventory_file)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
outputter.print_message "Renaming bolt.yaml to bolt-project.yaml"
|
86
|
-
FileUtils.mv(config_file, project_file)
|
87
|
-
outputter.print_message "Successfully updated project. Please add a "\
|
88
|
-
"'name' key to bolt-project.yaml to use project-level tasks and plans. "\
|
89
|
-
"Learn more about projects by running 'bolt guide project'."
|
90
|
-
# If nothing errored, this succeeded
|
91
|
-
true
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
private def inventory_1_to_2(inventory_file, outputter)
|
96
|
-
data = Bolt::Util.read_yaml_hash(inventory_file, 'inventory')
|
97
|
-
data.delete('version') if data['version'] != 2
|
98
|
-
migrated = migrate_group(data)
|
99
|
-
|
100
|
-
ok = if migrated
|
101
|
-
backup_file(inventory_file)
|
102
|
-
File.write(inventory_file, data.to_yaml)
|
103
|
-
end
|
104
|
-
|
105
|
-
result = if migrated && ok
|
106
|
-
"Successfully migrated Bolt inventory to the latest version."
|
107
|
-
elsif !migrated
|
108
|
-
"Bolt inventory is already on the latest version. Skipping inventory update."
|
109
|
-
else
|
110
|
-
"Could not migrate Bolt inventory to the latest version. See "\
|
111
|
-
"https://puppet.com/docs/bolt/latest/inventory_file_v2.html to manually update."
|
112
|
-
end
|
113
|
-
outputter.print_message(result)
|
114
|
-
ok
|
115
|
-
end
|
116
|
-
|
117
|
-
# Walks an inventory hash and replaces all 'nodes' keys with 'targets' keys
|
118
|
-
# and all 'name' keys nested in a 'targets' hash with 'uri' keys. Data is
|
119
|
-
# modified in place.
|
120
|
-
private def migrate_group(group)
|
121
|
-
migrated = false
|
122
|
-
if group.key?('nodes')
|
123
|
-
migrated = true
|
124
|
-
targets = group['nodes'].map do |target|
|
125
|
-
target['uri'] = target.delete('name') if target.is_a?(Hash)
|
126
|
-
target
|
127
|
-
end
|
128
|
-
group.delete('nodes')
|
129
|
-
group['targets'] = targets
|
130
|
-
end
|
131
|
-
(group['groups'] || []).each do |subgroup|
|
132
|
-
migrated_group = migrate_group(subgroup)
|
133
|
-
migrated ||= migrated_group
|
134
|
-
end
|
135
|
-
migrated
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
data/lib/bolt_server/pe/pal.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bolt/pal'
|
4
|
-
require 'bolt/util'
|
5
|
-
|
6
|
-
module BoltServer
|
7
|
-
module PE
|
8
|
-
class PAL < Bolt::PAL
|
9
|
-
# PE_BOLTLIB_PATH is intended to function exactly like the BOLTLIB_PATH used
|
10
|
-
# in Bolt::PAL. Paths and variable names are similar to what exists in
|
11
|
-
# Bolt::PAL, but with a 'PE' prefix.
|
12
|
-
PE_BOLTLIB_PATH = '/opt/puppetlabs/server/apps/bolt-server/pe-bolt-modules'
|
13
|
-
|
14
|
-
# For now at least, we maintain an entirely separate codedir from
|
15
|
-
# puppetserver by default, so that filesync can work properly. If filesync
|
16
|
-
# is not used, this can instead match the usual puppetserver codedir.
|
17
|
-
# See the `orchestrator.bolt.codedir` tk config setting.
|
18
|
-
DEFAULT_BOLT_CODEDIR = '/opt/puppetlabs/server/data/orchestration-services/code'
|
19
|
-
|
20
|
-
# This function is nearly identical to Bolt::Pal's `with_puppet_settings` with the
|
21
|
-
# one difference that we set the codedir to point to actual code, rather than the
|
22
|
-
# tmpdir. We only use this funtion inside the PEBolt::PAL initializer so that Puppet
|
23
|
-
# is correctly configured to pull environment configuration correctly. If we don't
|
24
|
-
# set codedir in this way: when we try to load and interpolate the modulepath it
|
25
|
-
# won't correctly load.
|
26
|
-
def with_pe_pal_init_settings(codedir, environmentpath, basemodulepath)
|
27
|
-
Dir.mktmpdir('pe-bolt') do |dir|
|
28
|
-
cli = []
|
29
|
-
Puppet::Settings::REQUIRED_APP_SETTINGS.each do |setting|
|
30
|
-
dir = setting == :codedir ? codedir : dir
|
31
|
-
cli << "--#{setting}" << dir
|
32
|
-
end
|
33
|
-
cli << "--environmentpath" << environmentpath
|
34
|
-
cli << "--basemodulepath" << basemodulepath
|
35
|
-
Puppet.settings.send(:clear_everything_for_tests)
|
36
|
-
Puppet.initialize_settings(cli)
|
37
|
-
yield
|
38
|
-
# Ensure the puppet settings go back to what bolt expects after
|
39
|
-
# we finish with the settings we need for PEBolt::PAL init.
|
40
|
-
with_puppet_settings { |_| nil }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def initialize(plan_executor_config, environment_name, hiera_config = nil, max_compiles = nil)
|
45
|
-
# Bolt::PAL#initialize takes the modulepath as its first argument, but we
|
46
|
-
# want to customize it later, so we pass an empty value:
|
47
|
-
super([], hiera_config, max_compiles)
|
48
|
-
|
49
|
-
codedir = plan_executor_config['codedir'] || DEFAULT_BOLT_CODEDIR
|
50
|
-
environmentpath = plan_executor_config['environmentpath'] || "#{codedir}/environments"
|
51
|
-
basemodulepath = plan_executor_config['basemodulepath'] || "#{codedir}/modules:/opt/puppetlabs/puppet/modules"
|
52
|
-
|
53
|
-
with_pe_pal_init_settings(codedir, environmentpath, basemodulepath) do
|
54
|
-
environment = Puppet.lookup(:environments).get!(environment_name)
|
55
|
-
# A new modulepath is created from scratch (rather than using super's @modulepath)
|
56
|
-
# so that we can have full control over all the entries in modulepath. In the future
|
57
|
-
# it's likely we will need to preceed _both_ Bolt::PAL::BOLTLIB_PATH _and_
|
58
|
-
# Bolt::PAL::MODULES_PATH which would be more complex if we tried to use @modulepath since
|
59
|
-
# we need to append our modulepaths and exclude modules shiped in bolt gem code
|
60
|
-
modulepath_dirs = environment.modulepath
|
61
|
-
@user_modulepath = modulepath_dirs
|
62
|
-
@modulepath = [PE_BOLTLIB_PATH, Bolt::PAL::BOLTLIB_PATH, *modulepath_dirs]
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|