bolt 2.6.0 → 2.11.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 +4 -3
- data/bolt-modules/boltlib/lib/puppet/datatypes/applyresult.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/resourceinstance.rb +27 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/result.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/resultset.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/datatypes/target.rb +4 -3
- data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_task_with.rb +192 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_resources.rb +122 -0
- data/bolt-modules/boltlib/types/planresult.pp +12 -1
- data/bolt-modules/file/lib/puppet/functions/file/exists.rb +3 -1
- data/bolt-modules/file/lib/puppet/functions/file/join.rb +1 -1
- data/bolt-modules/file/lib/puppet/functions/file/read.rb +2 -1
- data/bolt-modules/file/lib/puppet/functions/file/readable.rb +3 -1
- data/bolt-modules/file/lib/puppet/functions/file/write.rb +3 -1
- data/bolt-modules/prompt/lib/puppet/functions/prompt.rb +43 -0
- data/lib/bolt/analytics.rb +1 -1
- data/lib/bolt/applicator.rb +3 -2
- data/lib/bolt/apply_inventory.rb +1 -1
- data/lib/bolt/apply_result.rb +1 -1
- data/lib/bolt/apply_target.rb +11 -2
- data/lib/bolt/bolt_option_parser.rb +27 -7
- data/lib/bolt/catalog.rb +32 -3
- data/lib/bolt/cli.rb +52 -22
- data/lib/bolt/config.rb +51 -27
- data/lib/bolt/config/transport/base.rb +3 -3
- data/lib/bolt/config/transport/docker.rb +7 -1
- data/lib/bolt/config/transport/local.rb +9 -1
- data/lib/bolt/config/transport/orch.rb +4 -2
- data/lib/bolt/config/transport/remote.rb +2 -0
- data/lib/bolt/config/transport/ssh.rb +81 -3
- data/lib/bolt/config/transport/winrm.rb +6 -1
- data/lib/bolt/executor.rb +38 -0
- data/lib/bolt/inventory.rb +2 -1
- data/lib/bolt/inventory/group.rb +1 -0
- data/lib/bolt/inventory/inventory.rb +9 -0
- data/lib/bolt/inventory/target.rb +17 -1
- data/lib/bolt/node/output.rb +1 -1
- data/lib/bolt/outputter/human.rb +5 -4
- data/lib/bolt/outputter/json.rb +1 -1
- data/lib/bolt/pal.rb +32 -14
- data/lib/bolt/pal/yaml_plan.rb +1 -0
- data/lib/bolt/plugin.rb +14 -8
- data/lib/bolt/plugin/env_var.rb +2 -1
- data/lib/bolt/plugin/module.rb +40 -7
- data/lib/bolt/plugin/prompt.rb +1 -1
- data/lib/bolt/plugin/puppetdb.rb +5 -2
- data/lib/bolt/project.rb +135 -0
- data/lib/bolt/puppetdb/config.rb +16 -28
- data/lib/bolt/rerun.rb +1 -1
- data/lib/bolt/resource_instance.rb +126 -0
- data/lib/bolt/result.rb +46 -23
- data/lib/bolt/result_set.rb +2 -5
- data/lib/bolt/secret.rb +20 -4
- data/lib/bolt/shell/bash.rb +27 -14
- data/lib/bolt/shell/bash/tmpdir.rb +1 -1
- data/lib/bolt/shell/powershell.rb +43 -15
- data/lib/bolt/shell/powershell/snippets.rb +1 -1
- data/lib/bolt/target.rb +18 -2
- data/lib/bolt/transport/base.rb +24 -8
- data/lib/bolt/transport/docker.rb +3 -3
- data/lib/bolt/transport/docker/connection.rb +11 -7
- data/lib/bolt/transport/local/connection.rb +13 -7
- data/lib/bolt/transport/orch.rb +5 -1
- data/lib/bolt/transport/ssh.rb +6 -2
- data/lib/bolt/transport/ssh/connection.rb +26 -1
- data/lib/bolt/transport/ssh/exec_connection.rb +110 -0
- data/lib/bolt/transport/winrm/connection.rb +10 -2
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/pe/pal.rb +1 -38
- data/lib/bolt_server/transport_app.rb +7 -7
- data/lib/bolt_spec/bolt_context.rb +3 -6
- data/lib/bolt_spec/plans.rb +78 -8
- data/lib/bolt_spec/plans/action_stubs.rb +37 -7
- data/lib/bolt_spec/plans/action_stubs/plan_stub.rb +55 -0
- data/lib/bolt_spec/plans/mock_executor.rb +62 -2
- data/lib/bolt_spec/run.rb +10 -13
- metadata +26 -7
- data/lib/bolt/boltdir.rb +0 -54
- data/lib/bolt/plugin/pkcs7.rb +0 -104
- data/lib/bolt/secret/base.rb +0 -41
data/lib/bolt/boltdir.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'pathname'
|
4
|
-
|
5
|
-
module Bolt
|
6
|
-
class Boltdir
|
7
|
-
BOLTDIR_NAME = 'Boltdir'
|
8
|
-
|
9
|
-
attr_reader :path, :config_file, :inventory_file, :modulepath, :hiera_config,
|
10
|
-
:puppetfile, :rerunfile, :type, :resource_types
|
11
|
-
|
12
|
-
def self.default_boltdir
|
13
|
-
Boltdir.new(File.join('~', '.puppetlabs', 'bolt'), 'user')
|
14
|
-
end
|
15
|
-
|
16
|
-
# Search recursively up the directory hierarchy for the Boltdir. Look for a
|
17
|
-
# directory called Boltdir or a file called bolt.yaml (for a control repo
|
18
|
-
# type Boltdir). Otherwise, repeat the check on each directory up the
|
19
|
-
# hierarchy, falling back to the default if we reach the root.
|
20
|
-
def self.find_boltdir(dir)
|
21
|
-
dir = Pathname.new(dir)
|
22
|
-
if (dir + BOLTDIR_NAME).directory?
|
23
|
-
new(dir + BOLTDIR_NAME, 'embedded')
|
24
|
-
elsif (dir + 'bolt.yaml').file?
|
25
|
-
new(dir, 'local')
|
26
|
-
elsif dir.root?
|
27
|
-
default_boltdir
|
28
|
-
else
|
29
|
-
find_boltdir(dir.parent)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def initialize(path, type = 'option')
|
34
|
-
@path = Pathname.new(path).expand_path
|
35
|
-
@config_file = @path + 'bolt.yaml'
|
36
|
-
@inventory_file = @path + 'inventory.yaml'
|
37
|
-
@modulepath = [(@path + 'modules').to_s, (@path + 'site-modules').to_s, (@path + 'site').to_s]
|
38
|
-
@hiera_config = @path + 'hiera.yaml'
|
39
|
-
@puppetfile = @path + 'Puppetfile'
|
40
|
-
@rerunfile = @path + '.rerun.json'
|
41
|
-
@resource_types = @path + '.resource_types'
|
42
|
-
@type = type
|
43
|
-
end
|
44
|
-
|
45
|
-
def to_s
|
46
|
-
@path.to_s
|
47
|
-
end
|
48
|
-
|
49
|
-
def eql?(other)
|
50
|
-
path == other.path
|
51
|
-
end
|
52
|
-
alias == eql?
|
53
|
-
end
|
54
|
-
end
|
data/lib/bolt/plugin/pkcs7.rb
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bolt/secret/base'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
module Bolt
|
7
|
-
class Plugin
|
8
|
-
class Pkcs7 < Bolt::Secret::Base
|
9
|
-
def self.validate_config(config = {})
|
10
|
-
known_keys = %w[private-key public-key keysize]
|
11
|
-
known_keys.each do |key|
|
12
|
-
unless key.is_a? String
|
13
|
-
raise Bolt::ValidationError, "Invalid config for pkcs7 plugin: '#{key}' is not a String"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
config.each_key do |key|
|
18
|
-
unless known_keys.include?(key)
|
19
|
-
raise Bolt::ValidationError, "Unpexpected key in pkcs7 plugin config: #{key}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def name
|
25
|
-
'pkcs7'
|
26
|
-
end
|
27
|
-
|
28
|
-
def initialize(config:, context:, **_opts)
|
29
|
-
self.class.validate_config(config)
|
30
|
-
require 'openssl'
|
31
|
-
@context = context
|
32
|
-
@options = config || {}
|
33
|
-
@logger = Logging.logger[self]
|
34
|
-
end
|
35
|
-
|
36
|
-
def boltdir
|
37
|
-
@context.boltdir
|
38
|
-
end
|
39
|
-
|
40
|
-
def private_key_path
|
41
|
-
path = @options['private-key'] || 'keys/private_key.pkcs7.pem'
|
42
|
-
path = File.expand_path(path, boltdir)
|
43
|
-
@logger.debug("Using private-key: #{path}")
|
44
|
-
path
|
45
|
-
end
|
46
|
-
|
47
|
-
def private_key
|
48
|
-
@private_key ||= OpenSSL::PKey::RSA.new(File.read(private_key_path))
|
49
|
-
end
|
50
|
-
|
51
|
-
def public_key_path
|
52
|
-
path = @options['public-key'] || 'keys/public_key.pkcs7.pem'
|
53
|
-
path = File.expand_path(path, boltdir)
|
54
|
-
@logger.debug("Using public-key: #{path}")
|
55
|
-
path
|
56
|
-
end
|
57
|
-
|
58
|
-
def public_key
|
59
|
-
@public_key ||= OpenSSL::X509::Certificate.new(File.read(public_key_path))
|
60
|
-
end
|
61
|
-
|
62
|
-
def keysize
|
63
|
-
@options['keysize'] || 2048
|
64
|
-
end
|
65
|
-
|
66
|
-
# The following implementations are intended to be compatible with hiera-eyaml
|
67
|
-
def encrypt_value(plaintext)
|
68
|
-
cipher = OpenSSL::Cipher::AES.new(256, :CBC)
|
69
|
-
OpenSSL::PKCS7.encrypt([public_key], plaintext, cipher, OpenSSL::PKCS7::BINARY).to_der
|
70
|
-
end
|
71
|
-
|
72
|
-
def decrypt_value(ciphertext)
|
73
|
-
pkcs7 = OpenSSL::PKCS7.new(ciphertext)
|
74
|
-
pkcs7.decrypt(private_key, public_key)
|
75
|
-
end
|
76
|
-
|
77
|
-
def secret_createkeys
|
78
|
-
key = OpenSSL::PKey::RSA.new(keysize)
|
79
|
-
|
80
|
-
cert = OpenSSL::X509::Certificate.new
|
81
|
-
cert.subject = OpenSSL::X509::Name.parse('/')
|
82
|
-
cert.serial = 1
|
83
|
-
cert.version = 2
|
84
|
-
cert.not_before = Time.now
|
85
|
-
cert.not_after = Time.now + 50 * 365 * 24 * 60 * 60
|
86
|
-
cert.public_key = key.public_key
|
87
|
-
cert.sign(key, OpenSSL::Digest.new('SHA512'))
|
88
|
-
|
89
|
-
@logger.warn("Overwriting private-key '#{private_key_path}'") if File.exist?(private_key_path)
|
90
|
-
@logger.warn("Overwriting public-key '#{public_key_path}'") if File.exist?(public_key_path)
|
91
|
-
|
92
|
-
private_keydir = File.dirname(private_key_path)
|
93
|
-
FileUtils.mkdir_p(private_keydir) unless File.exist?(private_keydir)
|
94
|
-
FileUtils.touch(private_key_path)
|
95
|
-
File.chmod(0o600, private_key_path)
|
96
|
-
File.write(private_key_path, key.to_pem)
|
97
|
-
|
98
|
-
public_keydir = File.dirname(public_key_path)
|
99
|
-
FileUtils.mkdir_p(public_keydir) unless File.exist?(public_keydir)
|
100
|
-
File.write(public_key_path, cert.to_pem)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
data/lib/bolt/secret/base.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bolt
|
4
|
-
class Secret
|
5
|
-
class Base
|
6
|
-
def hooks
|
7
|
-
%i[resolve_reference secret_encrypt secret_decrypt secret_createkeys validate_resolve_reference]
|
8
|
-
end
|
9
|
-
|
10
|
-
def encode(raw)
|
11
|
-
coded = Base64.encode64(raw).strip
|
12
|
-
"ENC[#{name.upcase},#{coded}]"
|
13
|
-
end
|
14
|
-
|
15
|
-
def decode(code)
|
16
|
-
format = %r{\AENC\[(?<plugin>\w+),(?<encoded>[\w\s+-=/]+)\]\s*\z}
|
17
|
-
match = format.match(code)
|
18
|
-
|
19
|
-
raise Bolt::ValidationError, "Could not parse as an encrypted value: #{code}" unless match
|
20
|
-
|
21
|
-
raw = Base64.decode64(match[:encoded])
|
22
|
-
[raw, match[:plugin]]
|
23
|
-
end
|
24
|
-
|
25
|
-
def secret_encrypt(opts)
|
26
|
-
encrypted = encrypt_value(opts['plaintext_value'])
|
27
|
-
encode(encrypted)
|
28
|
-
end
|
29
|
-
|
30
|
-
def secret_decrypt(opts)
|
31
|
-
raw, _plugin = decode(opts['encrypted_value'])
|
32
|
-
decrypt_value(raw)
|
33
|
-
end
|
34
|
-
alias resolve_reference secret_decrypt
|
35
|
-
|
36
|
-
def validate_resolve_reference(opts)
|
37
|
-
decode(opts['encrypted_value'])
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|