bolt 2.21.0 → 2.25.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 +1 -1
- data/bolt-modules/ctrl/lib/puppet/functions/ctrl/do_until.rb +12 -6
- data/bolt-modules/out/lib/puppet/functions/out/message.rb +1 -1
- data/exe/bolt +1 -0
- data/guides/inventory.txt +19 -0
- data/guides/project.txt +22 -0
- data/lib/bolt/analytics.rb +5 -5
- data/lib/bolt/applicator.rb +4 -3
- data/lib/bolt/bolt_option_parser.rb +64 -23
- data/lib/bolt/catalog.rb +9 -1
- data/lib/bolt/cli.rb +218 -73
- data/lib/bolt/config.rb +7 -0
- data/lib/bolt/config/options.rb +4 -4
- data/lib/bolt/executor.rb +9 -7
- data/lib/bolt/inventory/group.rb +3 -3
- data/lib/bolt/logger.rb +3 -4
- data/lib/bolt/module.rb +2 -1
- data/lib/bolt/outputter.rb +56 -0
- data/lib/bolt/outputter/human.rb +10 -9
- data/lib/bolt/outputter/json.rb +11 -4
- data/lib/bolt/outputter/logger.rb +2 -2
- data/lib/bolt/outputter/rainbow.rb +15 -0
- data/lib/bolt/pal.rb +5 -9
- data/lib/bolt/pal/yaml_plan/evaluator.rb +1 -1
- data/lib/bolt/pal/yaml_plan/transpiler.rb +11 -3
- data/lib/bolt/plugin/prompt.rb +3 -3
- data/lib/bolt/project.rb +6 -4
- data/lib/bolt/project_migrate.rb +138 -0
- data/lib/bolt/shell/bash.rb +7 -7
- data/lib/bolt/transport/docker/connection.rb +9 -9
- data/lib/bolt/transport/local/connection.rb +2 -2
- data/lib/bolt/transport/orch.rb +3 -3
- data/lib/bolt/transport/ssh/connection.rb +5 -5
- data/lib/bolt/transport/ssh/exec_connection.rb +4 -4
- data/lib/bolt/transport/winrm/connection.rb +8 -8
- data/lib/bolt/util.rb +1 -1
- data/lib/bolt/util/puppet_log_level.rb +4 -3
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/base_config.rb +1 -1
- data/lib/bolt_server/pe/pal.rb +1 -1
- data/lib/bolt_server/transport_app.rb +76 -0
- data/lib/bolt_spec/plans.rb +1 -1
- data/lib/bolt_spec/plans/action_stubs.rb +1 -1
- data/lib/bolt_spec/run.rb +3 -0
- data/libexec/apply_catalog.rb +2 -2
- data/libexec/bolt_catalog +1 -1
- data/libexec/custom_facts.rb +1 -1
- data/libexec/query_resources.rb +1 -1
- metadata +7 -4
@@ -4,9 +4,10 @@ module Bolt
|
|
4
4
|
module Util
|
5
5
|
module PuppetLogLevel
|
6
6
|
MAPPING = {
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
# Demote Puppet's logs by one level, since Puppet is an implementation detail of Bolt
|
8
|
+
debug: :trace,
|
9
|
+
info: :debug,
|
10
|
+
notice: :info,
|
10
11
|
warning: :warn,
|
11
12
|
err: :error,
|
12
13
|
# The following are used by Puppet functions of the same name, and are all treated as
|
data/lib/bolt/version.rb
CHANGED
data/lib/bolt_server/pe/pal.rb
CHANGED
@@ -58,7 +58,7 @@ module BoltServer
|
|
58
58
|
# Bolt::PAL::MODULES_PATH which would be more complex if we tried to use @modulepath since
|
59
59
|
# we need to append our modulepaths and exclude modules shiped in bolt gem code
|
60
60
|
modulepath_dirs = environment.modulepath
|
61
|
-
@
|
61
|
+
@user_modulepath = modulepath_dirs
|
62
62
|
@modulepath = [PE_BOLTLIB_PATH, Bolt::PAL::BOLTLIB_PATH, *modulepath_dirs]
|
63
63
|
end
|
64
64
|
end
|
@@ -221,6 +221,56 @@ module BoltServer
|
|
221
221
|
plan_info
|
222
222
|
end
|
223
223
|
|
224
|
+
def build_puppetserver_uri(file_identifier, module_name, environment)
|
225
|
+
segments = file_identifier.split('/', 3)
|
226
|
+
if segments.size == 1
|
227
|
+
{
|
228
|
+
'path' => "/puppet/v3/file_content/tasks/#{module_name}/#{file_identifier}",
|
229
|
+
'params' => {
|
230
|
+
'environment' => environment
|
231
|
+
}
|
232
|
+
}
|
233
|
+
else
|
234
|
+
module_segment, mount_segment, name_segment = *segments
|
235
|
+
{
|
236
|
+
'path' => case mount_segment
|
237
|
+
when 'files'
|
238
|
+
"/puppet/v3/file_content/modules/#{module_segment}/#{name_segment}"
|
239
|
+
when 'tasks'
|
240
|
+
"/puppet/v3/file_content/tasks/#{module_segment}/#{name_segment}"
|
241
|
+
when 'lib'
|
242
|
+
"/puppet/v3/file_content/plugins/#{name_segment}"
|
243
|
+
end,
|
244
|
+
'params' => {
|
245
|
+
'environment' => environment
|
246
|
+
}
|
247
|
+
}
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
def pe_task_info(pal, module_name, task_name, environment)
|
252
|
+
# Handle case where task name is simply module name with special `init` task
|
253
|
+
task_name = if task_name == 'init' || task_name.nil?
|
254
|
+
module_name
|
255
|
+
else
|
256
|
+
"#{module_name}::#{task_name}"
|
257
|
+
end
|
258
|
+
task = pal.get_task(task_name)
|
259
|
+
files = task.files.map do |file_hash|
|
260
|
+
{
|
261
|
+
'filename' => file_hash['name'],
|
262
|
+
'sha256' => Digest::SHA256.hexdigest(File.read(file_hash['path'])),
|
263
|
+
'size_bytes' => File.size(file_hash['path']),
|
264
|
+
'uri' => build_puppetserver_uri(file_hash['name'], module_name, environment)
|
265
|
+
}
|
266
|
+
end
|
267
|
+
{
|
268
|
+
'metadata' => task.metadata,
|
269
|
+
'name' => task.name,
|
270
|
+
'files' => files
|
271
|
+
}
|
272
|
+
end
|
273
|
+
|
224
274
|
get '/' do
|
225
275
|
200
|
226
276
|
end
|
@@ -351,6 +401,16 @@ module BoltServer
|
|
351
401
|
end
|
352
402
|
end
|
353
403
|
|
404
|
+
# Fetches the metadata for a single task
|
405
|
+
#
|
406
|
+
# @param environment [String] the environment to fetch the task from
|
407
|
+
get '/tasks/:module_name/:task_name' do
|
408
|
+
in_pe_pal_env(params['environment']) do |pal|
|
409
|
+
task_info = pe_task_info(pal, params[:module_name], params[:task_name], params['environment'])
|
410
|
+
[200, task_info.to_json]
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
354
414
|
# Fetches the list of plans for an environment, optionally fetching all metadata for each plan
|
355
415
|
#
|
356
416
|
# @param environment [String] the environment to fetch the list of plans from
|
@@ -375,6 +435,22 @@ module BoltServer
|
|
375
435
|
end
|
376
436
|
end
|
377
437
|
|
438
|
+
# Fetches the list of tasks for an environment
|
439
|
+
#
|
440
|
+
# @param environment [String] the environment to fetch the list of tasks from
|
441
|
+
get '/tasks' do
|
442
|
+
in_pe_pal_env(params['environment']) do |pal|
|
443
|
+
tasks = pal.list_tasks
|
444
|
+
tasks_response = tasks.map { |task_name, _description| { 'name' => task_name } }.to_json
|
445
|
+
|
446
|
+
# We structure this array of tasks to be an array of hashes so that it matches the structure
|
447
|
+
# returned by the puppetserver API that serves data like this. Structuring the output this way
|
448
|
+
# makes switching between puppetserver and bolt-server easier, which makes changes to switch
|
449
|
+
# to bolt-server smaller/simpler.
|
450
|
+
[200, tasks_response]
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
378
454
|
error 404 do
|
379
455
|
err = Bolt::Error.new("Could not find route #{request.path}",
|
380
456
|
'boltserver/not-found')
|
data/lib/bolt_spec/plans.rb
CHANGED
@@ -206,7 +206,7 @@ module BoltSpec
|
|
206
206
|
Puppet[:tasks] = true
|
207
207
|
|
208
208
|
# Ensure logger is initialized with Puppet levels so 'notice' works when running plan specs.
|
209
|
-
Logging.init :debug, :info, :notice, :warn, :error, :fatal, :any
|
209
|
+
Logging.init :trace, :debug, :info, :notice, :warn, :error, :fatal, :any
|
210
210
|
end
|
211
211
|
|
212
212
|
# Provided as a class so expectations can be placed on it.
|
@@ -177,7 +177,7 @@ module BoltSpec
|
|
177
177
|
if data['msg'] && data['kind'] && (data.keys - %w[msg kind details issue_code]).empty?
|
178
178
|
@data[:default] = clazz.new(data['msg'], data['kind'], data['details'], data['issue_code'])
|
179
179
|
else
|
180
|
-
|
180
|
+
$stderr.puts "In the future 'error_with()' may require msg and kind, and " \
|
181
181
|
"optionally accept only details and issue_code."
|
182
182
|
@data[:default] = data
|
183
183
|
end
|
data/lib/bolt_spec/run.rb
CHANGED
@@ -8,6 +8,7 @@ require 'bolt/pal'
|
|
8
8
|
require 'bolt/plugin'
|
9
9
|
require 'bolt/puppetdb'
|
10
10
|
require 'bolt/util'
|
11
|
+
require 'bolt/logger'
|
11
12
|
|
12
13
|
# This is intended to provide a relatively stable method of executing bolt in process from tests.
|
13
14
|
module BoltSpec
|
@@ -153,6 +154,8 @@ module BoltSpec
|
|
153
154
|
end
|
154
155
|
|
155
156
|
def initialize(config_data, inventory_data, project_path)
|
157
|
+
Bolt::Logger.initialize_logging
|
158
|
+
|
156
159
|
@config_data = config_data || {}
|
157
160
|
@inventory_data = inventory_data || {}
|
158
161
|
@project_path = project_path
|
data/libexec/apply_catalog.rb
CHANGED
@@ -9,7 +9,7 @@ require 'puppet/module_tool/tar'
|
|
9
9
|
require 'securerandom'
|
10
10
|
require 'tempfile'
|
11
11
|
|
12
|
-
args = JSON.parse(ARGV[0] ? File.read(ARGV[0]) :
|
12
|
+
args = JSON.parse(ARGV[0] ? File.read(ARGV[0]) : $stdin.read)
|
13
13
|
|
14
14
|
# Create temporary directories for all core Puppet settings so we don't clobber
|
15
15
|
# existing state or read from puppet.conf. Also create a temporary modulepath.
|
@@ -110,7 +110,7 @@ ensure
|
|
110
110
|
begin
|
111
111
|
FileUtils.remove_dir(puppet_root)
|
112
112
|
rescue Errno::ENOTEMPTY => e
|
113
|
-
|
113
|
+
$stderr.puts("Could not cleanup temporary directory: #{e}")
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
data/libexec/bolt_catalog
CHANGED
data/libexec/custom_facts.rb
CHANGED
data/libexec/query_resources.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: 2.
|
4
|
+
version: 2.25.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-08-
|
11
|
+
date: 2020-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -187,7 +187,7 @@ dependencies:
|
|
187
187
|
version: 6.16.0
|
188
188
|
- - "<"
|
189
189
|
- !ruby/object:Gem::Version
|
190
|
-
version:
|
190
|
+
version: 6.18.0
|
191
191
|
type: :runtime
|
192
192
|
prerelease: false
|
193
193
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -197,7 +197,7 @@ dependencies:
|
|
197
197
|
version: 6.16.0
|
198
198
|
- - "<"
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version:
|
200
|
+
version: 6.18.0
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: puppetfile-resolver
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -437,6 +437,8 @@ files:
|
|
437
437
|
- bolt-modules/prompt/lib/puppet/functions/prompt.rb
|
438
438
|
- bolt-modules/system/lib/puppet/functions/system/env.rb
|
439
439
|
- exe/bolt
|
440
|
+
- guides/inventory.txt
|
441
|
+
- guides/project.txt
|
440
442
|
- lib/bolt.rb
|
441
443
|
- lib/bolt/analytics.rb
|
442
444
|
- lib/bolt/applicator.rb
|
@@ -498,6 +500,7 @@ files:
|
|
498
500
|
- lib/bolt/plugin/puppetdb.rb
|
499
501
|
- lib/bolt/plugin/task.rb
|
500
502
|
- lib/bolt/project.rb
|
503
|
+
- lib/bolt/project_migrate.rb
|
501
504
|
- lib/bolt/puppetdb.rb
|
502
505
|
- lib/bolt/puppetdb/client.rb
|
503
506
|
- lib/bolt/puppetdb/config.rb
|