kafo 7.1.0 → 7.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -5
- data/bin/kafo-export-params +1 -1
- data/lib/kafo/configuration.rb +1 -1
- data/lib/kafo/data_type.rb +2 -2
- data/lib/kafo/data_type_parser.rb +19 -2
- data/lib/kafo/data_types/float.rb +1 -1
- data/lib/kafo/data_types/not_undef.rb +5 -7
- data/lib/kafo/data_types/optional.rb +5 -7
- data/lib/kafo/help_builders/base.rb +2 -4
- data/lib/kafo/hiera_configurer.rb +1 -1
- data/lib/kafo/kafo_configure.rb +19 -21
- data/lib/kafo/multi_stage_hook.rb +2 -2
- data/lib/kafo/param.rb +4 -4
- data/lib/kafo/progress_bar.rb +2 -2
- data/lib/kafo/progress_bars/black_white.rb +1 -1
- data/lib/kafo/progress_bars/colored.rb +1 -1
- data/lib/kafo/puppet_command.rb +2 -2
- data/lib/kafo/{failed_puppet_resource.rb → puppet_failed_resource.rb} +15 -0
- data/lib/kafo/puppet_module.rb +4 -4
- data/lib/kafo/puppet_report.rb +1 -1
- data/lib/kafo/scenario_manager.rb +1 -1
- data/lib/kafo/version.rb +1 -1
- data/lib/kafo/wizard.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8adeff1136ef4700d8f5f00a034912ff73380d0985c28c820223b085909cc4f
|
4
|
+
data.tar.gz: 98d05a4a406ebd9d59870ffd86fab6ad07198b917157e96255244861b994621c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36ed613f932dbc8b12f643e16bc898d9f820b546b8c35b2a956b921662829248bcc17e9114c6d19d2b1bda4146baf91d113969e78f35272c0936dd08e79f08d3
|
7
|
+
data.tar.gz: ac2bd021eab081aecc1b14c7953de9ca869f69b8e0cc01b6721c4cdb79339ad099570ee37d66878df03bdf488640ae6972d5350e708397200bb6103931ebfce0
|
data/Rakefile
CHANGED
@@ -31,11 +31,12 @@ namespace 'test' do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
require 'rubocop/rake_task'
|
35
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
36
|
+
# These make the rubocop experience maybe slightly less terrible
|
37
|
+
task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
|
38
|
+
# Use Rubocop's Github Actions formatter if possible
|
39
|
+
task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true'
|
39
40
|
end
|
40
41
|
|
41
42
|
CLEAN.include 'test/tmp'
|
data/bin/kafo-export-params
CHANGED
@@ -125,7 +125,7 @@ module Kafo
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def print_out
|
128
|
-
puts "| #{
|
128
|
+
puts "| #{'Parameter name'.ljust(40)} | #{'Description'.ljust(@max)} |"
|
129
129
|
puts "| #{'-'*40} | #{'-' * @max} |"
|
130
130
|
@config.modules.sort.each do |mod|
|
131
131
|
mod.params.sort.each do |param|
|
data/lib/kafo/configuration.rb
CHANGED
@@ -383,7 +383,7 @@ EOS
|
|
383
383
|
# Loads YAML from mixed output, finding the "---" and "..." document start/end delimiters
|
384
384
|
def load_yaml_from_output(lines)
|
385
385
|
start = lines.find_index { |l| l.start_with?('---') }
|
386
|
-
last = lines[start
|
386
|
+
last = lines[start..].find_index("...")
|
387
387
|
if start.nil? || last.nil?
|
388
388
|
puts "Could not find default values in output"
|
389
389
|
@logger.error 'Could not find default values in Puppet output, cannot continue'
|
data/lib/kafo/data_type.rb
CHANGED
@@ -61,7 +61,7 @@ module Kafo
|
|
61
61
|
bracket_count = 1
|
62
62
|
until bracket_count.zero?
|
63
63
|
next_bracket = scanner.scan_until(/[\[\]]/) or raise ConfigurationException, "missing close bracket in argument #{args.count + 1} in data type #{input}"
|
64
|
-
case next_bracket[-1
|
64
|
+
case next_bracket[-1..]
|
65
65
|
when '['
|
66
66
|
bracket_count += 1
|
67
67
|
when ']'
|
@@ -102,7 +102,7 @@ module Kafo
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def typecast(value)
|
105
|
-
value == 'UNDEF' ? nil : value
|
105
|
+
(value == 'UNDEF') ? nil : value
|
106
106
|
end
|
107
107
|
|
108
108
|
def valid?(value, errors = [])
|
@@ -8,9 +8,26 @@ module Kafo
|
|
8
8
|
|
9
9
|
def initialize(manifest)
|
10
10
|
@logger = KafoConfigure.logger
|
11
|
-
|
11
|
+
|
12
|
+
lines = []
|
13
|
+
type_line_without_newlines = +''
|
12
14
|
manifest.each_line do |line|
|
13
|
-
|
15
|
+
line = line.force_encoding("UTF-8").strip
|
16
|
+
next if line.start_with?('#')
|
17
|
+
|
18
|
+
line = line.split(' #').first.strip
|
19
|
+
if line =~ TYPE_DEFINITION
|
20
|
+
lines << type_line_without_newlines
|
21
|
+
type_line_without_newlines = line
|
22
|
+
else
|
23
|
+
type_line_without_newlines << line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
lines << type_line_without_newlines
|
27
|
+
|
28
|
+
@types = {}
|
29
|
+
lines.each do |line|
|
30
|
+
if (type = TYPE_DEFINITION.match(line))
|
14
31
|
@types[type[1]] = type[2]
|
15
32
|
end
|
16
33
|
end
|
@@ -8,13 +8,11 @@ module Kafo
|
|
8
8
|
attr_reader :inner_type, :inner_value
|
9
9
|
|
10
10
|
def initialize(inner_type_or_value)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@inner_value = inner_type_or_value
|
17
|
-
end
|
11
|
+
@inner_type = DataType.new_from_string(inner_type_or_value)
|
12
|
+
@inner_value = nil
|
13
|
+
rescue ConfigurationException
|
14
|
+
@inner_type = nil
|
15
|
+
@inner_value = inner_type_or_value
|
18
16
|
end
|
19
17
|
|
20
18
|
def to_s
|
@@ -8,13 +8,11 @@ module Kafo
|
|
8
8
|
attr_reader :inner_type, :inner_value
|
9
9
|
|
10
10
|
def initialize(inner_type_or_value)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@inner_value = inner_type_or_value
|
17
|
-
end
|
11
|
+
@inner_type = DataType.new_from_string(inner_type_or_value)
|
12
|
+
@inner_value = nil
|
13
|
+
rescue ConfigurationException
|
14
|
+
@inner_type = nil
|
15
|
+
@inner_value = inner_type_or_value
|
18
16
|
end
|
19
17
|
|
20
18
|
def to_s
|
@@ -84,10 +84,8 @@ module Kafo
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def parametrization
|
87
|
-
@parametrization ||=
|
88
|
-
|
89
|
-
h.update(parametrize(p) => p, parametrize(p, 'reset-') => p)
|
90
|
-
end
|
87
|
+
@parametrization ||= @params.inject({}) do |h,p|
|
88
|
+
h.update(parametrize(p) => p, parametrize(p, 'reset-') => p)
|
91
89
|
end
|
92
90
|
end
|
93
91
|
end
|
@@ -22,7 +22,7 @@ module Kafo
|
|
22
22
|
classes = []
|
23
23
|
data = modules.select(&:enabled?).inject({}) do |config, mod|
|
24
24
|
classes << mod.class_name
|
25
|
-
config.update(
|
25
|
+
config.update(mod.params_hash.transform_keys { |k| "#{mod.class_name}::#{k}" })
|
26
26
|
end
|
27
27
|
data['classes'] = sort_modules(classes, order)
|
28
28
|
data
|
data/lib/kafo/kafo_configure.rb
CHANGED
@@ -20,8 +20,8 @@ require 'kafo/string_helper'
|
|
20
20
|
require 'kafo/help_builder'
|
21
21
|
require 'kafo/wizard'
|
22
22
|
require 'kafo/system_checker'
|
23
|
-
require 'kafo/failed_puppet_resource'
|
24
23
|
require 'kafo/puppet_command'
|
24
|
+
require 'kafo/puppet_failed_resource'
|
25
25
|
require 'kafo/puppet_log_parser'
|
26
26
|
require 'kafo/puppet_report'
|
27
27
|
require 'kafo/progress_bar'
|
@@ -514,29 +514,27 @@ module Kafo
|
|
514
514
|
logger.notice("Starting system configuration.")
|
515
515
|
|
516
516
|
PTY.spawn(*PuppetCommand.format_command(command)) do |stdin, stdout, pid|
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
if (output
|
524
|
-
|
525
|
-
logger.notice("#{output[:count].to_i - 1} configuration steps out of #{output[:total]} steps complete.")
|
526
|
-
end
|
517
|
+
stdin.each do |line|
|
518
|
+
line = normalize_encoding(line)
|
519
|
+
method, message = log_parser.parse(line)
|
520
|
+
progress_log(method, message, logger)
|
521
|
+
|
522
|
+
if (output = line.match(/(?:.+\]): Starting to evaluate the resource(?: \((?<count>\d+) of (?<total>\d+)\))?/))
|
523
|
+
if (output[:count].to_i % 250) == 1 && output[:count].to_i != 1
|
524
|
+
logger.notice("#{output[:count].to_i - 1} configuration steps out of #{output[:total]} steps complete.")
|
527
525
|
end
|
528
|
-
|
529
|
-
@progress_bar.update(line) if @progress_bar
|
530
526
|
end
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
527
|
+
|
528
|
+
@progress_bar.update(line) if @progress_bar
|
529
|
+
end
|
530
|
+
rescue Errno::EIO # we reach end of input
|
531
|
+
exit_status = PTY.check(pid, true)
|
532
|
+
if exit_status.nil? # process is still running
|
533
|
+
begin
|
534
|
+
Process.wait(pid)
|
535
|
+
rescue Errno::ECHILD # process could exit meanwhile so we rescue
|
539
536
|
end
|
537
|
+
self.class.exit_handler.exit_code = $?.exitstatus
|
540
538
|
end
|
541
539
|
end
|
542
540
|
rescue PTY::ChildExited => e # could be raised by PTY.check
|
@@ -4,8 +4,8 @@ module Kafo
|
|
4
4
|
default_name = name
|
5
5
|
|
6
6
|
types.each do |hook_type|
|
7
|
-
self.class.send(:define_method, hook_type) do |
|
8
|
-
registry.send(:register, hook_type,
|
7
|
+
self.class.send(:define_method, hook_type) do |hook_name = nil, &block|
|
8
|
+
registry.send(:register, hook_type, hook_name || default_name, &block)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/kafo/param.rb
CHANGED
@@ -47,7 +47,7 @@ module Kafo
|
|
47
47
|
# For literal default values, only use 'manifest_default'. For variable or values from a data
|
48
48
|
# lookup, use the value loaded back from the dump in 'default'.
|
49
49
|
def default
|
50
|
-
@type.typecast(dump_default_needed? || !@default.nil? ? @default : manifest_default)
|
50
|
+
@type.typecast((dump_default_needed? || !@default.nil?) ? @default : manifest_default)
|
51
51
|
end
|
52
52
|
|
53
53
|
def default=(default)
|
@@ -71,7 +71,7 @@ module Kafo
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def manifest_default_params_variable
|
74
|
-
manifest_default[1
|
74
|
+
manifest_default[1..] if dump_default_needed?
|
75
75
|
end
|
76
76
|
|
77
77
|
def module_name
|
@@ -132,7 +132,7 @@ module Kafo
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def visible?(context = [])
|
135
|
-
condition.nil? || condition.empty? ? true : evaluate_condition(context)
|
135
|
+
(condition.nil? || condition.empty?) ? true : evaluate_condition(context)
|
136
136
|
end
|
137
137
|
|
138
138
|
def condition_value
|
@@ -155,7 +155,7 @@ module Kafo
|
|
155
155
|
arg
|
156
156
|
end
|
157
157
|
end.map do |arg|
|
158
|
-
arg == :undef ? nil : arg
|
158
|
+
(arg == :undef) ? nil : arg
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
data/lib/kafo/progress_bar.rb
CHANGED
@@ -39,7 +39,7 @@ module Kafo
|
|
39
39
|
|
40
40
|
if (line_monitor = MONITOR_RESOURCE.match(line))
|
41
41
|
@resources << line_monitor[1]
|
42
|
-
@total = (@total == :unknown ? 1 : @total + 1)
|
42
|
+
@total = ((@total == :unknown) ? 1 : @total + 1)
|
43
43
|
end
|
44
44
|
|
45
45
|
if (line_start = EVALTRACE_START.match(line))
|
@@ -71,7 +71,7 @@ module Kafo
|
|
71
71
|
|
72
72
|
def close
|
73
73
|
@bar.show({ :msg => done_message,
|
74
|
-
:done => @total == :unknown ? @bar.done + 1 : @total,
|
74
|
+
:done => (@total == :unknown) ? @bar.done + 1 : @total,
|
75
75
|
:total => @total }, true)
|
76
76
|
@bar.close
|
77
77
|
end
|
data/lib/kafo/puppet_command.rb
CHANGED
@@ -43,7 +43,7 @@ module Kafo
|
|
43
43
|
File.join([bin_path, bin_name].compact)
|
44
44
|
end
|
45
45
|
|
46
|
-
def self.
|
46
|
+
def self.aio_puppet?
|
47
47
|
puppet_command = search_puppet_path('puppet')
|
48
48
|
File.realpath(puppet_command).start_with?('/opt/puppetlabs')
|
49
49
|
rescue Errno::ENOENT
|
@@ -51,7 +51,7 @@ module Kafo
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def self.format_command(command)
|
54
|
-
if
|
54
|
+
if aio_puppet?
|
55
55
|
[clean_env_vars, command, :unsetenv_others => true]
|
56
56
|
else
|
57
57
|
[::ENV, command, :unsetenv_others => false]
|
@@ -49,5 +49,20 @@ module Kafo
|
|
49
49
|
def log_messages
|
50
50
|
@logs.map { |log| log['message'] }
|
51
51
|
end
|
52
|
+
|
53
|
+
# A collection of Puppet log messages grouped by source
|
54
|
+
#
|
55
|
+
# The log messages include detailed information of what failed. Some debug
|
56
|
+
# information, such as timing but crucially the command output, both stdout
|
57
|
+
# and stderr.
|
58
|
+
#
|
59
|
+
# A resource can have multiple sources. For example, exec can have both
|
60
|
+
# unless and returns. Combining the output of those can be confusing, so
|
61
|
+
# this presents them separate.
|
62
|
+
#
|
63
|
+
# @return [Hash[String, Array[String]]] The Puppet log messages for this resource
|
64
|
+
def log_messages_by_source
|
65
|
+
@logs.group_by { |log| log['source'] }.transform_values { |logs| logs.map { |log| log['message'] } }
|
66
|
+
end
|
52
67
|
end
|
53
68
|
end
|
data/lib/kafo/puppet_module.rb
CHANGED
@@ -123,7 +123,7 @@ module Kafo
|
|
123
123
|
|
124
124
|
# mapping from configuration with stringified keys
|
125
125
|
def mapping
|
126
|
-
@mapping ||=
|
126
|
+
@mapping ||= @configuration.app[:mapping].transform_keys(&:to_s)
|
127
127
|
end
|
128
128
|
|
129
129
|
# custom module directory name
|
@@ -137,7 +137,7 @@ module Kafo
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def get_class_name
|
140
|
-
manifest_name == 'init' ? name : "#{dir_name}::#{manifest_name.gsub('/', '::')}"
|
140
|
+
(manifest_name == 'init') ? name : "#{dir_name}::#{manifest_name.gsub('/', '::')}"
|
141
141
|
end
|
142
142
|
|
143
143
|
def get_params_path
|
@@ -165,11 +165,11 @@ module Kafo
|
|
165
165
|
end
|
166
166
|
|
167
167
|
def default_manifest_name
|
168
|
-
identifier.include?('::') ? identifier.split('::')[1
|
168
|
+
identifier.include?('::') ? identifier.split('::')[1..].join('/') : 'init'
|
169
169
|
end
|
170
170
|
|
171
171
|
def default_params_name
|
172
|
-
identifier.include?('::') ? (identifier.split('::')[1
|
172
|
+
identifier.include?('::') ? (identifier.split('::')[1..] + ['params']).join('/') : 'params'
|
173
173
|
end
|
174
174
|
|
175
175
|
def get_name
|
data/lib/kafo/puppet_report.rb
CHANGED
@@ -18,7 +18,7 @@ module Kafo
|
|
18
18
|
data = case File.extname(path)
|
19
19
|
when '.yaml'
|
20
20
|
require 'yaml'
|
21
|
-
content = File.read(path).gsub(
|
21
|
+
content = File.read(path).gsub(%r{!ruby/object.*$}, '')
|
22
22
|
YAML.safe_load(content, permitted_classes: [Time, Symbol])
|
23
23
|
when '.json'
|
24
24
|
require 'json'
|
@@ -35,7 +35,7 @@ module Kafo
|
|
35
35
|
say ::HighLine.color("Available scenarios", :info)
|
36
36
|
available_scenarios.each do |config_file, content|
|
37
37
|
scenario = File.basename(config_file, '.yaml')
|
38
|
-
use = (File.expand_path(config_file) == @previous_scenario ? 'INSTALLED' : "use: --scenario #{scenario}")
|
38
|
+
use = ((File.expand_path(config_file) == @previous_scenario) ? 'INSTALLED' : "use: --scenario #{scenario}")
|
39
39
|
say ::HighLine.color(" #{content[:name]} ", :title)
|
40
40
|
say "(#{use})"
|
41
41
|
say " " + content[:description] if !content[:description].nil? && !content[:description].empty?
|
data/lib/kafo/version.rb
CHANGED
data/lib/kafo/wizard.rb
CHANGED
@@ -190,7 +190,7 @@ END
|
|
190
190
|
else
|
191
191
|
HighLine::SystemExtensions.terminal_size
|
192
192
|
end
|
193
|
-
highline.wrap_at = data.first > 80 ? 80 : data.first if data.first
|
193
|
+
highline.wrap_at = (data.first > 80) ? 80 : data.first if data.first
|
194
194
|
highline.page_at = data.last if data.last
|
195
195
|
highline
|
196
196
|
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: 7.
|
4
|
+
version: 7.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Hulan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -259,7 +259,6 @@ files:
|
|
259
259
|
- lib/kafo/execution_environment.rb
|
260
260
|
- lib/kafo/exit_handler.rb
|
261
261
|
- lib/kafo/fact_writer.rb
|
262
|
-
- lib/kafo/failed_puppet_resource.rb
|
263
262
|
- lib/kafo/help_builder.rb
|
264
263
|
- lib/kafo/help_builders/advanced.rb
|
265
264
|
- lib/kafo/help_builders/base.rb
|
@@ -283,6 +282,7 @@ files:
|
|
283
282
|
- lib/kafo/progress_bars/colored.rb
|
284
283
|
- lib/kafo/puppet_command.rb
|
285
284
|
- lib/kafo/puppet_configurer.rb
|
285
|
+
- lib/kafo/puppet_failed_resource.rb
|
286
286
|
- lib/kafo/puppet_log_parser.rb
|
287
287
|
- lib/kafo/puppet_module.rb
|
288
288
|
- lib/kafo/puppet_report.rb
|