bolt 2.35.0 → 2.36.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/bolt-modules/boltlib/lib/puppet/datatypes/applyresult.rb +1 -0
- data/lib/bolt/analytics.rb +27 -8
- data/lib/bolt/apply_result.rb +3 -3
- data/lib/bolt/bolt_option_parser.rb +38 -15
- data/lib/bolt/cli.rb +13 -87
- data/lib/bolt/config.rb +131 -52
- data/lib/bolt/config/options.rb +42 -4
- data/lib/bolt/config/transport/base.rb +10 -19
- data/lib/bolt/config/transport/local.rb +0 -7
- data/lib/bolt/config/transport/ssh.rb +8 -14
- data/lib/bolt/config/validator.rb +231 -0
- data/lib/bolt/executor.rb +5 -17
- data/lib/bolt/outputter/rainbow.rb +1 -1
- data/lib/bolt/plugin.rb +0 -7
- data/lib/bolt/project.rb +30 -36
- data/lib/bolt/project_manager.rb +199 -0
- data/lib/bolt/{project_migrator/config.rb → project_manager/config_migrator.rb} +41 -4
- data/lib/bolt/{project_migrator/inventory.rb → project_manager/inventory_migrator.rb} +3 -3
- data/lib/bolt/{project_migrator/base.rb → project_manager/migrator.rb} +2 -2
- data/lib/bolt/{project_migrator/modules.rb → project_manager/module_migrator.rb} +3 -3
- data/lib/bolt/puppetdb/config.rb +1 -2
- data/lib/bolt/shell/bash.rb +1 -1
- data/lib/bolt/task/run.rb +1 -1
- data/lib/bolt/transport/ssh/exec_connection.rb +6 -2
- data/lib/bolt/util.rb +14 -7
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/base_config.rb +3 -1
- data/lib/bolt_server/config.rb +3 -1
- data/lib/bolt_server/schemas/partials/task.json +2 -2
- data/lib/bolt_server/transport_app.rb +5 -5
- data/libexec/apply_catalog.rb +1 -1
- data/libexec/custom_facts.rb +1 -1
- data/libexec/query_resources.rb +1 -1
- metadata +8 -13
- data/lib/bolt/project_migrator.rb +0 -80
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'bolt/
|
3
|
+
require 'bolt/project_manager/migrator'
|
4
4
|
|
5
5
|
module Bolt
|
6
|
-
class
|
7
|
-
class
|
6
|
+
class ProjectManager
|
7
|
+
class ModuleMigrator < Migrator
|
8
8
|
def migrate(project, configured_modulepath)
|
9
9
|
return true unless project.modules.nil?
|
10
10
|
|
data/lib/bolt/puppetdb/config.rb
CHANGED
@@ -18,8 +18,7 @@ module Bolt
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.default_windows_config
|
21
|
-
|
22
|
-
File.expand_path(File.join(Dir::COMMON_APPDATA, 'PuppetLabs/client-tools/puppetdb.conf'))
|
21
|
+
File.expand_path(File.join(ENV['ALLUSERSPROFILE'], 'PuppetLabs/client-tools/puppetdb.conf'))
|
23
22
|
end
|
24
23
|
|
25
24
|
def self.load_config(options, project_path = nil)
|
data/lib/bolt/shell/bash.rb
CHANGED
@@ -199,7 +199,7 @@ module Bolt
|
|
199
199
|
lines = buffer.split(/(?<=\n)/)
|
200
200
|
# handle_sudo will return the line if it is not a sudo prompt or error
|
201
201
|
lines.map! { |line| handle_sudo(inp, line, stdin) }
|
202
|
-
lines.join
|
202
|
+
lines.join
|
203
203
|
# If stream has reached EOF, no password prompt is expected
|
204
204
|
# return an empty string
|
205
205
|
rescue EOFError
|
data/lib/bolt/task/run.rb
CHANGED
@@ -42,7 +42,7 @@ module Bolt
|
|
42
42
|
if targets.empty?
|
43
43
|
Bolt::ResultSet.new([])
|
44
44
|
else
|
45
|
-
result = executor.
|
45
|
+
result = executor.run_task(targets, task, params, options, [], :trace)
|
46
46
|
|
47
47
|
if !result.ok && !options[:catch_errors]
|
48
48
|
raise Bolt::RunFailure.new(result, 'run_task', task.name)
|
@@ -12,8 +12,12 @@ module Bolt
|
|
12
12
|
raise Bolt::ValidationError, "Target #{target.safe_name} does not have a host" unless target.host
|
13
13
|
|
14
14
|
@target = target
|
15
|
-
|
16
|
-
|
15
|
+
begin
|
16
|
+
ssh_config = Net::SSH::Config.for(target.host)
|
17
|
+
@user = @target.user || ssh_config[:user] || Etc.getlogin
|
18
|
+
rescue StandardError
|
19
|
+
@user = @target.user || Etc.getlogin
|
20
|
+
end
|
17
21
|
@logger = Bolt::Logger.logger(self)
|
18
22
|
end
|
19
23
|
|
data/lib/bolt/util.rb
CHANGED
@@ -29,19 +29,26 @@ module Bolt
|
|
29
29
|
path = File.expand_path(path)
|
30
30
|
content = File.open(path, "r:UTF-8") { |f| YAML.safe_load(f.read) } || {}
|
31
31
|
unless content.is_a?(Hash)
|
32
|
-
|
33
|
-
|
32
|
+
raise Bolt::FileError.new(
|
33
|
+
"Invalid content for #{file_name} file at #{path}\nContent should be a Hash or empty, "\
|
34
|
+
"not #{content.class}",
|
35
|
+
path
|
36
|
+
)
|
34
37
|
end
|
35
38
|
logger.trace("Loaded #{file_name} from #{path}")
|
36
39
|
content
|
37
40
|
rescue Errno::ENOENT
|
38
|
-
raise Bolt::FileError.new("Could not read #{file_name} file
|
41
|
+
raise Bolt::FileError.new("Could not read #{file_name} file at #{path}", path)
|
42
|
+
rescue Psych::SyntaxError => e
|
43
|
+
raise Bolt::FileError.new("Could not parse #{file_name} file at #{path}, line #{e.line}, "\
|
44
|
+
"column #{e.column}\n#{e.problem}",
|
45
|
+
path)
|
39
46
|
rescue Psych::Exception => e
|
40
|
-
raise Bolt::FileError.new("Could not parse #{file_name} file
|
41
|
-
|
47
|
+
raise Bolt::FileError.new("Could not parse #{file_name} file at #{path}\n#{e.message}",
|
48
|
+
path)
|
42
49
|
rescue IOError, SystemCallError => e
|
43
|
-
raise Bolt::FileError.new("Could not read #{file_name} file
|
44
|
-
|
50
|
+
raise Bolt::FileError.new("Could not read #{file_name} file at #{path}\n#{e.message}",
|
51
|
+
path)
|
45
52
|
end
|
46
53
|
|
47
54
|
def read_optional_yaml_hash(path, file_name)
|
data/lib/bolt/version.rb
CHANGED
@@ -7,7 +7,9 @@ module BoltServer
|
|
7
7
|
class BaseConfig
|
8
8
|
def config_keys
|
9
9
|
%w[host port ssl-cert ssl-key ssl-ca-cert
|
10
|
-
ssl-cipher-suites loglevel logfile allowlist
|
10
|
+
ssl-cipher-suites loglevel logfile allowlist
|
11
|
+
projects-dir environments-codedir
|
12
|
+
environmentpath basemodulepath]
|
11
13
|
end
|
12
14
|
|
13
15
|
def env_keys
|
data/lib/bolt_server/config.rb
CHANGED
@@ -7,7 +7,9 @@ require 'bolt/error'
|
|
7
7
|
module BoltServer
|
8
8
|
class Config < BoltServer::BaseConfig
|
9
9
|
def config_keys
|
10
|
-
super + %w[concurrency cache-dir file-server-conn-timeout
|
10
|
+
super + %w[concurrency cache-dir file-server-conn-timeout
|
11
|
+
file-server-uri projects-dir environments-codedir
|
12
|
+
environmentpath basemodulepath]
|
11
13
|
end
|
12
14
|
|
13
15
|
def env_keys
|
@@ -64,7 +64,7 @@
|
|
64
64
|
"description": "Environment the task is in",
|
65
65
|
"type": "string"
|
66
66
|
},
|
67
|
-
"
|
67
|
+
"versioned_project": {
|
68
68
|
"description": "Project the task is in",
|
69
69
|
"type": "string"
|
70
70
|
}
|
@@ -77,7 +77,7 @@
|
|
77
77
|
},
|
78
78
|
{
|
79
79
|
"required": [
|
80
|
-
"
|
80
|
+
"versioned_project"
|
81
81
|
]
|
82
82
|
}
|
83
83
|
],
|
@@ -235,9 +235,9 @@ module BoltServer
|
|
235
235
|
#
|
236
236
|
# WARNING: THIS FUNCTION SHOULD ONLY BE CALLED INSIDE A SYNCHRONIZED PAL MUTEX
|
237
237
|
def modulepath_from_environment(environment_name)
|
238
|
-
codedir = DEFAULT_BOLT_CODEDIR
|
239
|
-
environmentpath = "#{codedir}/environments"
|
240
|
-
basemodulepath = "#{codedir}/modules:/opt/puppetlabs/puppet/modules"
|
238
|
+
codedir = @config['environments-codedir'] || DEFAULT_BOLT_CODEDIR
|
239
|
+
environmentpath = @config['environmentpath'] || "#{codedir}/environments"
|
240
|
+
basemodulepath = @config['basemodulepath'] || "#{codedir}/modules:/opt/puppetlabs/puppet/modules"
|
241
241
|
modulepath_dirs = nil
|
242
242
|
with_pe_pal_init_settings(codedir, environmentpath, basemodulepath) do
|
243
243
|
environment = Puppet.lookup(:environments).get!(environment_name)
|
@@ -543,7 +543,7 @@ module BoltServer
|
|
543
543
|
return MISSING_PROJECT_REF_RESPONSE if params['project_ref'].nil?
|
544
544
|
in_bolt_project(params['project_ref']) do |context|
|
545
545
|
ps_parameters = {
|
546
|
-
'
|
546
|
+
'versioned_project' => params['project_ref']
|
547
547
|
}
|
548
548
|
task_info = pe_task_info(context[:pal], params[:module_name], params[:task_name], ps_parameters)
|
549
549
|
task_info = allowed_helper(task_info, context[:config].project.tasks)
|
@@ -645,7 +645,7 @@ module BoltServer
|
|
645
645
|
# Returns a list of targets parsed from a Project inventory
|
646
646
|
#
|
647
647
|
# @param project_ref [String] the project_ref to compute the inventory from
|
648
|
-
|
648
|
+
post '/project_inventory_targets' do
|
649
649
|
return MISSING_PROJECT_REF_RESPONSE if params['project_ref'].nil?
|
650
650
|
bolt_config = config_from_project(params['project_ref'])
|
651
651
|
if bolt_config.inventoryfile && bolt_config.project.inventory_file.to_s != bolt_config.inventoryfile
|
data/libexec/apply_catalog.rb
CHANGED
@@ -74,7 +74,7 @@ begin
|
|
74
74
|
Puppet::ResourceApi::Transport.inject_device(type, transport)
|
75
75
|
|
76
76
|
Puppet[:facts_terminus] = :network_device
|
77
|
-
Puppet[:certname] = conn_info['
|
77
|
+
Puppet[:certname] = conn_info['name']
|
78
78
|
end
|
79
79
|
|
80
80
|
# Ensure custom facts are available for provider suitability tests
|
data/libexec/custom_facts.rb
CHANGED
@@ -51,7 +51,7 @@ Dir.mktmpdir do |puppet_root|
|
|
51
51
|
Puppet::ResourceApi::Transport.inject_device(type, transport)
|
52
52
|
|
53
53
|
Puppet[:facts_terminus] = :network_device
|
54
|
-
Puppet[:certname] = conn_info['
|
54
|
+
Puppet[:certname] = conn_info['name']
|
55
55
|
end
|
56
56
|
|
57
57
|
facts = Puppet::Node::Facts.indirection.find(SecureRandom.uuid, environment: env)
|
data/libexec/query_resources.rb
CHANGED
@@ -59,7 +59,7 @@ Dir.mktmpdir do |puppet_root|
|
|
59
59
|
Puppet::ResourceApi::Transport.inject_device(type, transport)
|
60
60
|
|
61
61
|
Puppet[:facts_terminus] = :network_device
|
62
|
-
Puppet[:certname] = conn_info['
|
62
|
+
Puppet[:certname] = conn_info['name']
|
63
63
|
end
|
64
64
|
|
65
65
|
resources = args['resources'].flat_map do |resource_desc|
|
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.36.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-
|
11
|
+
date: 2020-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -185,9 +185,6 @@ dependencies:
|
|
185
185
|
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: 6.18.0
|
188
|
-
- - "<"
|
189
|
-
- !ruby/object:Gem::Version
|
190
|
-
version: '6.20'
|
191
188
|
type: :runtime
|
192
189
|
prerelease: false
|
193
190
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -195,9 +192,6 @@ dependencies:
|
|
195
192
|
- - ">="
|
196
193
|
- !ruby/object:Gem::Version
|
197
194
|
version: 6.18.0
|
198
|
-
- - "<"
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
version: '6.20'
|
201
195
|
- !ruby/object:Gem::Dependency
|
202
196
|
name: puppetfile-resolver
|
203
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -464,6 +458,7 @@ files:
|
|
464
458
|
- lib/bolt/config/transport/remote.rb
|
465
459
|
- lib/bolt/config/transport/ssh.rb
|
466
460
|
- lib/bolt/config/transport/winrm.rb
|
461
|
+
- lib/bolt/config/validator.rb
|
467
462
|
- lib/bolt/error.rb
|
468
463
|
- lib/bolt/executor.rb
|
469
464
|
- lib/bolt/inventory.rb
|
@@ -516,11 +511,11 @@ files:
|
|
516
511
|
- lib/bolt/plugin/puppetdb.rb
|
517
512
|
- lib/bolt/plugin/task.rb
|
518
513
|
- lib/bolt/project.rb
|
519
|
-
- lib/bolt/
|
520
|
-
- lib/bolt/
|
521
|
-
- lib/bolt/
|
522
|
-
- lib/bolt/
|
523
|
-
- lib/bolt/
|
514
|
+
- lib/bolt/project_manager.rb
|
515
|
+
- lib/bolt/project_manager/config_migrator.rb
|
516
|
+
- lib/bolt/project_manager/inventory_migrator.rb
|
517
|
+
- lib/bolt/project_manager/migrator.rb
|
518
|
+
- lib/bolt/project_manager/module_migrator.rb
|
524
519
|
- lib/bolt/puppetdb.rb
|
525
520
|
- lib/bolt/puppetdb/client.rb
|
526
521
|
- lib/bolt/puppetdb/config.rb
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bolt/project_migrator/config'
|
4
|
-
require 'bolt/project_migrator/inventory'
|
5
|
-
require 'bolt/project_migrator/modules'
|
6
|
-
|
7
|
-
module Bolt
|
8
|
-
class ProjectMigrator
|
9
|
-
def initialize(config, outputter)
|
10
|
-
@config = config
|
11
|
-
@outputter = outputter
|
12
|
-
end
|
13
|
-
|
14
|
-
def migrate
|
15
|
-
unless $stdin.tty?
|
16
|
-
raise Bolt::Error.new(
|
17
|
-
"stdin is not a tty, unable to migrate project",
|
18
|
-
'bolt/stdin-not-a-tty-error'
|
19
|
-
)
|
20
|
-
end
|
21
|
-
|
22
|
-
@outputter.print_message("Migrating project #{@config.project.path}\n\n")
|
23
|
-
|
24
|
-
@outputter.print_action_step(
|
25
|
-
"Migrating a Bolt project may make irreversible changes to the project's "\
|
26
|
-
"configuration and inventory files. Before continuing, make sure the "\
|
27
|
-
"project has a backup or uses a version control system."
|
28
|
-
)
|
29
|
-
|
30
|
-
return 0 unless Bolt::Util.prompt_yes_no("Continue with project migration?", @outputter)
|
31
|
-
|
32
|
-
@outputter.print_message('')
|
33
|
-
|
34
|
-
ok = migrate_inventory && migrate_config && migrate_modules
|
35
|
-
|
36
|
-
if ok
|
37
|
-
@outputter.print_message("Project successfully migrated")
|
38
|
-
else
|
39
|
-
@outputter.print_error("Project could not be migrated completely")
|
40
|
-
end
|
41
|
-
|
42
|
-
ok ? 0 : 1
|
43
|
-
end
|
44
|
-
|
45
|
-
# Migrates the project-level configuration file to the latest version.
|
46
|
-
#
|
47
|
-
private def migrate_config
|
48
|
-
migrator = Bolt::ProjectMigrator::Config.new(@outputter)
|
49
|
-
|
50
|
-
migrator.migrate(
|
51
|
-
@config.project.config_file,
|
52
|
-
@config.project.project_file,
|
53
|
-
@config.inventoryfile || @config.project.inventory_file,
|
54
|
-
@config.project.backup_dir
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
# Migrates the inventory file to the latest version.
|
59
|
-
#
|
60
|
-
private def migrate_inventory
|
61
|
-
migrator = Bolt::ProjectMigrator::Inventory.new(@outputter)
|
62
|
-
|
63
|
-
migrator.migrate(
|
64
|
-
@config.inventoryfile || @config.project.inventory_file,
|
65
|
-
@config.project.backup_dir
|
66
|
-
)
|
67
|
-
end
|
68
|
-
|
69
|
-
# Migrates the project's modules to use current best practices.
|
70
|
-
#
|
71
|
-
private def migrate_modules
|
72
|
-
migrator = Bolt::ProjectMigrator::Modules.new(@outputter)
|
73
|
-
|
74
|
-
migrator.migrate(
|
75
|
-
@config.project,
|
76
|
-
@config.modulepath
|
77
|
-
)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|