bolt 2.30.0 → 2.34.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 +12 -12
- data/bolt-modules/boltlib/lib/puppet/functions/download_file.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/facts.rb +6 -0
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb +2 -2
- data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_task_with.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/write_file.rb +2 -2
- data/bolt-modules/out/lib/puppet/functions/out/message.rb +44 -1
- data/bolt-modules/prompt/lib/puppet/functions/prompt.rb +3 -0
- data/guides/logging.txt +18 -0
- data/guides/module.txt +19 -0
- data/guides/modulepath.txt +25 -0
- data/lib/bolt/bolt_option_parser.rb +6 -1
- data/lib/bolt/cli.rb +82 -142
- data/lib/bolt/config/modulepath.rb +30 -0
- data/lib/bolt/config/options.rb +31 -13
- data/lib/bolt/config/transport/options.rb +2 -2
- data/lib/bolt/error.rb +13 -3
- data/lib/bolt/executor.rb +24 -12
- data/lib/bolt/inventory.rb +10 -9
- data/lib/bolt/inventory/group.rb +2 -1
- data/lib/bolt/module_installer.rb +117 -91
- data/lib/bolt/{puppetfile → module_installer}/installer.rb +3 -2
- data/lib/bolt/module_installer/puppetfile.rb +117 -0
- data/lib/bolt/module_installer/puppetfile/forge_module.rb +54 -0
- data/lib/bolt/module_installer/puppetfile/git_module.rb +37 -0
- data/lib/bolt/module_installer/puppetfile/module.rb +26 -0
- data/lib/bolt/module_installer/resolver.rb +76 -0
- data/lib/bolt/module_installer/specs.rb +93 -0
- data/lib/bolt/module_installer/specs/forge_spec.rb +85 -0
- data/lib/bolt/module_installer/specs/git_spec.rb +179 -0
- data/lib/bolt/outputter.rb +0 -47
- data/lib/bolt/outputter/human.rb +46 -16
- data/lib/bolt/outputter/json.rb +17 -8
- data/lib/bolt/pal.rb +52 -40
- data/lib/bolt/pal/yaml_plan.rb +4 -2
- data/lib/bolt/pal/yaml_plan/evaluator.rb +23 -1
- data/lib/bolt/pal/yaml_plan/loader.rb +14 -9
- data/lib/bolt/plan_creator.rb +160 -0
- data/lib/bolt/plugin.rb +2 -2
- data/lib/bolt/project.rb +6 -11
- data/lib/bolt/project_migrator.rb +1 -1
- data/lib/bolt/project_migrator/base.rb +2 -2
- data/lib/bolt/project_migrator/config.rb +5 -4
- data/lib/bolt/project_migrator/inventory.rb +3 -3
- data/lib/bolt/project_migrator/modules.rb +23 -21
- data/lib/bolt/puppetdb/config.rb +5 -5
- data/lib/bolt/result.rb +23 -11
- data/lib/bolt/shell/bash.rb +14 -8
- data/lib/bolt/shell/powershell.rb +12 -7
- data/lib/bolt/task/run.rb +1 -1
- data/lib/bolt/transport/base.rb +18 -18
- data/lib/bolt/transport/docker.rb +23 -6
- data/lib/bolt/transport/orch.rb +26 -17
- data/lib/bolt/transport/remote.rb +3 -3
- data/lib/bolt/transport/simple.rb +6 -6
- data/lib/bolt/transport/ssh/connection.rb +1 -1
- data/lib/bolt/util.rb +5 -0
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/file_cache.rb +2 -0
- data/lib/bolt_server/schemas/partials/task.json +17 -2
- data/lib/bolt_server/transport_app.rb +92 -12
- data/lib/bolt_spec/bolt_context.rb +4 -2
- data/lib/bolt_spec/plans.rb +1 -1
- data/lib/bolt_spec/plans/action_stubs/command_stub.rb +1 -1
- data/lib/bolt_spec/plans/action_stubs/script_stub.rb +1 -1
- data/lib/bolt_spec/plans/mock_executor.rb +5 -5
- data/lib/bolt_spec/run.rb +1 -1
- metadata +24 -9
- data/lib/bolt/puppetfile.rb +0 -142
- data/lib/bolt/puppetfile/module.rb +0 -90
- data/lib/bolt_server/pe/pal.rb +0 -67
- data/modules/secure_env_vars/plans/init.pp +0 -20
@@ -1,90 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bolt/error'
|
4
|
-
|
5
|
-
# This class represents a module specification. It used by the Bolt::Puppetfile
|
6
|
-
# class to have a consistent API for accessing a module's attributes.
|
7
|
-
#
|
8
|
-
module Bolt
|
9
|
-
class Puppetfile
|
10
|
-
class Module
|
11
|
-
attr_reader :owner, :name, :version
|
12
|
-
|
13
|
-
def initialize(owner, name, version = nil)
|
14
|
-
@owner = owner
|
15
|
-
@name = name
|
16
|
-
@version = version unless version == :latest
|
17
|
-
end
|
18
|
-
|
19
|
-
# Creates a new module from a hash.
|
20
|
-
#
|
21
|
-
def self.from_hash(mod)
|
22
|
-
unless mod['name'].is_a?(String)
|
23
|
-
raise Bolt::ValidationError,
|
24
|
-
"Module name must be a String, not #{mod['name'].inspect}"
|
25
|
-
end
|
26
|
-
|
27
|
-
owner, name = mod['name'].tr('/', '-').split('-', 2)
|
28
|
-
|
29
|
-
unless owner && name
|
30
|
-
raise Bolt::ValidationError, "Module name #{mod['name']} must include both the owner and module name."
|
31
|
-
end
|
32
|
-
|
33
|
-
new(owner, name, mod['version_requirement'])
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns the module's title.
|
37
|
-
#
|
38
|
-
def title
|
39
|
-
"#{@owner}-#{@name}"
|
40
|
-
end
|
41
|
-
alias to_s title
|
42
|
-
|
43
|
-
# Checks two modules for equality.
|
44
|
-
#
|
45
|
-
def eql?(other)
|
46
|
-
self.class == other.class &&
|
47
|
-
@owner == other.owner &&
|
48
|
-
@name == other.name &&
|
49
|
-
versions_intersect?(other)
|
50
|
-
end
|
51
|
-
alias == eql?
|
52
|
-
|
53
|
-
# Returns true if the versions of two modules intersect. Used to determine
|
54
|
-
# if an installed module satisfies the version requirement of another.
|
55
|
-
#
|
56
|
-
def versions_intersect?(other)
|
57
|
-
range = ::SemanticPuppet::VersionRange.parse(@version || '')
|
58
|
-
other_range = ::SemanticPuppet::VersionRange.parse(other.version || '')
|
59
|
-
|
60
|
-
range.intersection(other_range) != ::SemanticPuppet::VersionRange::EMPTY_RANGE
|
61
|
-
end
|
62
|
-
|
63
|
-
# Hashes the module.
|
64
|
-
#
|
65
|
-
def hash
|
66
|
-
[@owner, @name].hash
|
67
|
-
end
|
68
|
-
|
69
|
-
# Returns a hash representation similar to the module
|
70
|
-
# declaration.
|
71
|
-
#
|
72
|
-
def to_hash
|
73
|
-
{
|
74
|
-
'name' => title,
|
75
|
-
'version_requirement' => version
|
76
|
-
}.compact
|
77
|
-
end
|
78
|
-
|
79
|
-
# Returns the Puppetfile specification for the module.
|
80
|
-
#
|
81
|
-
def to_spec
|
82
|
-
if @version
|
83
|
-
"mod #{title.inspect}, #{@version.inspect}"
|
84
|
-
else
|
85
|
-
"mod #{title.inspect}"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
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
|
@@ -1,20 +0,0 @@
|
|
1
|
-
plan secure_env_vars(
|
2
|
-
TargetSpec $targets,
|
3
|
-
Optional[String] $command = undef,
|
4
|
-
Optional[String] $script = undef
|
5
|
-
) {
|
6
|
-
$env_vars = parsejson(system::env('BOLT_ENV_VARS'))
|
7
|
-
unless type($command) == Undef or type($script) == Undef {
|
8
|
-
fail_plan('Cannot specify both script and command for secure_env_vars')
|
9
|
-
}
|
10
|
-
|
11
|
-
return if $command {
|
12
|
-
run_command($command, $targets, '_env_vars' => $env_vars)
|
13
|
-
}
|
14
|
-
elsif $script {
|
15
|
-
run_script($script, $targets, '_env_vars' => $env_vars)
|
16
|
-
}
|
17
|
-
else {
|
18
|
-
fail_plan('Must specify either script or command for secure_env_vars')
|
19
|
-
}
|
20
|
-
}
|