kafo 6.4.0 → 6.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -0
- data/lib/kafo/data_type.rb +1 -1
- data/lib/kafo/data_type_parser.rb +1 -1
- data/lib/kafo/data_types/scalar.rb +1 -1
- data/lib/kafo/data_types/{variant.rb → wrapped_data_type.rb} +5 -4
- data/lib/kafo/fact_writer.rb +3 -4
- data/lib/kafo/kafo_configure.rb +4 -8
- data/lib/kafo/logger.rb +7 -1
- data/lib/kafo/logging.rb +1 -1
- data/lib/kafo/puppet_module.rb +1 -1
- data/lib/kafo/version.rb +1 -1
- data/modules/kafo_configure/lib/puppet/functions/kafo_configure/dump_lookups.rb +8 -1
- data/modules/kafo_configure/lib/puppet/functions/kafo_configure/dump_variables.rb +7 -1
- data/modules/kafo_configure/spec/fixtures/hiera/test.yaml +5 -0
- data/modules/kafo_configure/spec/fixtures/modules/dummy/manifests/init.pp +1 -0
- data/modules/kafo_configure/spec/fixtures/modules/dummy/manifests/params.pp +1 -0
- data/modules/kafo_configure/spec/functions/dump_lookups_spec.rb +1 -0
- data/modules/kafo_configure/spec/functions/dump_variables_spec.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 674a595f056324470ff9175d38779f7ab8c153e044ab4892dc99ca0d6487b7ba
|
4
|
+
data.tar.gz: 83ffe976aa56291ebad41e0e7ba22d72908bbe299d926bb1af1aa5b1fbef0a75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8b66a8f86409186fbf2ed5fde7b6b7eb9f6e2fadf4ab33234df205fa4702cadae85021ef043ea096f5450e8735d6b81fade0d81530f2aae43a929dfa2ac8866
|
7
|
+
data.tar.gz: bc3475cace0ec33b3ffb983f8d5921e75b1695908b6f5386b716c3e90434e9ba69f18e38af2c8c0c35372887cec1cfa167ac45c9edb10294fe55cd1384d50ab8
|
data/README.md
CHANGED
@@ -493,6 +493,39 @@ as key:value.
|
|
493
493
|
When parsing the value, the first colon divides key and value. All other
|
494
494
|
colons are ignored.
|
495
495
|
|
496
|
+
## Sensitive arguments
|
497
|
+
|
498
|
+
Puppet's `Sensitive` data type can be used as long as it's configured in Hiera
|
499
|
+
too. Given the following manifest:
|
500
|
+
|
501
|
+
```puppet
|
502
|
+
class example (
|
503
|
+
Sensitive[String[1]] $password,
|
504
|
+
) {
|
505
|
+
```
|
506
|
+
|
507
|
+
Here the following Hiera configuration is needed:
|
508
|
+
```yaml
|
509
|
+
lookup_options:
|
510
|
+
example::password:
|
511
|
+
convert_to: "Sensitive"
|
512
|
+
```
|
513
|
+
|
514
|
+
This is based on [Puppet's documentation](https://puppet.com/docs/puppet/6/securing-sensitive-data.html).
|
515
|
+
|
516
|
+
Note that to provide a default inside the manifest inheritance must be used.
|
517
|
+
|
518
|
+
```puppet
|
519
|
+
class example (
|
520
|
+
Sensitive[String[1]] $password = $example::params::password,
|
521
|
+
) inherits example::params {
|
522
|
+
}
|
523
|
+
|
524
|
+
class example::params {
|
525
|
+
$password = Sensitive('supersecret')
|
526
|
+
}
|
527
|
+
```
|
528
|
+
|
496
529
|
## Default values
|
497
530
|
|
498
531
|
Default values for parameters are read from the class definitions in the
|
data/lib/kafo/data_type.rb
CHANGED
@@ -7,7 +7,7 @@ module Kafo
|
|
7
7
|
def_delegators :@inner_type, :condition_value, :dump_default, :multivalued?, :typecast, :valid?
|
8
8
|
|
9
9
|
def initialize
|
10
|
-
@inner_type = DataTypes::
|
10
|
+
@inner_type = DataTypes::WrappedDataType.new('Integer', 'Float', 'String', 'Boolean', 'Regexp')
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Kafo
|
2
2
|
module DataTypes
|
3
|
-
class
|
3
|
+
class WrappedDataType < DataType
|
4
4
|
def initialize(*inner_types)
|
5
5
|
@inner_types = inner_types.map { |t| DataType.new_from_string(t) }
|
6
6
|
end
|
@@ -16,7 +16,7 @@ module Kafo
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def multivalued?
|
19
|
-
@inner_types.any?
|
19
|
+
@inner_types.any?(&:multivalued?)
|
20
20
|
end
|
21
21
|
|
22
22
|
def to_s
|
@@ -33,7 +33,7 @@ module Kafo
|
|
33
33
|
if type
|
34
34
|
type.valid?(value, errors)
|
35
35
|
else
|
36
|
-
errors << "#{value} is not one of #{
|
36
|
+
errors << "#{value} is not one of #{self}"
|
37
37
|
false
|
38
38
|
end
|
39
39
|
end
|
@@ -45,6 +45,7 @@ module Kafo
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
DataType.register_type('
|
48
|
+
DataType.register_type('Sensitive', WrappedDataType)
|
49
|
+
DataType.register_type('Variant', WrappedDataType)
|
49
50
|
end
|
50
51
|
end
|
data/lib/kafo/fact_writer.rb
CHANGED
@@ -14,10 +14,9 @@ module Kafo
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.wrapper
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
Facter.add(:kafo) { setcode { YAML.load_file(File.join(__dir__, '#{DATA_FILENAME}')) } }
|
17
|
+
<<~WRAPPER
|
18
|
+
require 'yaml'
|
19
|
+
Facter.add(:kafo) { setcode { YAML.load_file(File.join(__dir__, '#{DATA_FILENAME}')) } }
|
21
20
|
WRAPPER
|
22
21
|
end
|
23
22
|
end
|
data/lib/kafo/kafo_configure.rb
CHANGED
@@ -525,8 +525,8 @@ module Kafo
|
|
525
525
|
@progress_bar.update(line) if @progress_bar
|
526
526
|
end
|
527
527
|
rescue Errno::EIO # we reach end of input
|
528
|
-
exit_status = PTY.check(pid, true)
|
529
|
-
if exit_status.nil? # process is still running
|
528
|
+
exit_status = PTY.check(pid, true)
|
529
|
+
if exit_status.nil? # process is still running
|
530
530
|
begin
|
531
531
|
Process.wait(pid)
|
532
532
|
rescue Errno::ECHILD # process could exit meanwhile so we rescue
|
@@ -535,7 +535,7 @@ module Kafo
|
|
535
535
|
end
|
536
536
|
end
|
537
537
|
end
|
538
|
-
rescue PTY::ChildExited => e # could be raised by
|
538
|
+
rescue PTY::ChildExited => e # could be raised by PTY.check
|
539
539
|
self.class.exit_handler.exit_code = e.status.exitstatus
|
540
540
|
end
|
541
541
|
|
@@ -564,11 +564,7 @@ module Kafo
|
|
564
564
|
end
|
565
565
|
|
566
566
|
def normalize_encoding(line)
|
567
|
-
|
568
|
-
line.valid_encoding? ? line : line.encode('UTF-16be', :invalid => :replace, :replace => '?').encode('UTF-8')
|
569
|
-
else # Ruby 1.8.7, doesn't worry about invalid encodings
|
570
|
-
line
|
571
|
-
end
|
567
|
+
line.valid_encoding? ? line : line.encode('UTF-16be', :invalid => :replace, :replace => '?').encode('UTF-8')
|
572
568
|
end
|
573
569
|
end
|
574
570
|
end
|
data/lib/kafo/logger.rb
CHANGED
@@ -13,7 +13,13 @@ module Kafo
|
|
13
13
|
|
14
14
|
def log(level, *args, &block)
|
15
15
|
if Logging.buffering?
|
16
|
-
|
16
|
+
if block_given?
|
17
|
+
data = yield
|
18
|
+
else
|
19
|
+
data = args
|
20
|
+
end
|
21
|
+
|
22
|
+
Logging.to_buffer(@name, ::Logging::LogEvent.new(@name, ::Logging::LEVELS[level.to_s], data, false))
|
17
23
|
else
|
18
24
|
Logging.dump_buffer if Logging.dump_needed?
|
19
25
|
@logger.send(level, *args, &block)
|
data/lib/kafo/logging.rb
CHANGED
data/lib/kafo/puppet_module.rb
CHANGED
data/lib/kafo/version.rb
CHANGED
@@ -10,6 +10,13 @@ Puppet::Functions.create_function(:'kafo_configure::dump_lookups') do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def dump_lookups(parameters)
|
13
|
-
Hash[parameters.map { |param| [param,
|
13
|
+
Hash[parameters.map { |param| [param, lookup(param)] }]
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def lookup(param)
|
19
|
+
value = call_function('lookup', [param], 'default_value' => nil)
|
20
|
+
value.respond_to?(:unwrap) ? value.unwrap : value
|
14
21
|
end
|
15
22
|
end
|
@@ -8,6 +8,12 @@ Puppet::Functions.create_function(:'kafo_configure::dump_variables') do
|
|
8
8
|
|
9
9
|
def dump_variables(variables)
|
10
10
|
scope = closure_scope
|
11
|
-
Hash[variables.map { |var| [var, scope[var]] }]
|
11
|
+
Hash[variables.map { |var| [var, unwrap(scope[var])] }]
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def unwrap(value)
|
17
|
+
value.respond_to?(:unwrap) ? value.unwrap : value
|
12
18
|
end
|
13
19
|
end
|
@@ -4,4 +4,5 @@ describe 'kafo_configure::dump_lookups' do
|
|
4
4
|
let(:hiera_config) { 'spec/fixtures/hiera/hiera.yaml' }
|
5
5
|
it { is_expected.to run.with_params([]).and_return({}) }
|
6
6
|
it { is_expected.to run.with_params(['my_module::param']).and_return({'my_module::param' => 'override'}) }
|
7
|
+
it { is_expected.to run.with_params(['my_module::password']).and_return({'my_module::password' => 'batteryhorsestaple'}) }
|
7
8
|
end
|
@@ -6,5 +6,6 @@ describe 'kafo_configure::dump_variables' do
|
|
6
6
|
context 'with values' do
|
7
7
|
let(:pre_condition) { 'include dummy' }
|
8
8
|
it { is_expected.to run.with_params(['dummy::first']).and_return({'dummy::first' => 'foo'}) }
|
9
|
+
it { is_expected.to run.with_params(['dummy::password']).and_return({'dummy::password' => 'supersecret'}) }
|
9
10
|
end
|
10
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kafo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.4.
|
4
|
+
version: 6.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Hulan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -245,7 +245,7 @@ files:
|
|
245
245
|
- lib/kafo/data_types/tuple.rb
|
246
246
|
- lib/kafo/data_types/type_reference.rb
|
247
247
|
- lib/kafo/data_types/undef.rb
|
248
|
-
- lib/kafo/data_types/
|
248
|
+
- lib/kafo/data_types/wrapped_data_type.rb
|
249
249
|
- lib/kafo/exceptions.rb
|
250
250
|
- lib/kafo/execution_environment.rb
|
251
251
|
- lib/kafo/exit_handler.rb
|
@@ -320,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
320
320
|
- !ruby/object:Gem::Version
|
321
321
|
version: '0'
|
322
322
|
requirements: []
|
323
|
-
rubygems_version: 3.
|
323
|
+
rubygems_version: 3.2.22
|
324
324
|
signing_key:
|
325
325
|
specification_version: 4
|
326
326
|
summary: A gem for making installations based on puppet user friendly
|