kafo 6.1.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +8 -1
- data/lib/kafo/app_option/declaration.rb +0 -2
- data/lib/kafo/app_option/definition.rb +0 -2
- data/lib/kafo/color_scheme.rb +2 -2
- data/lib/kafo/configuration.rb +35 -34
- data/lib/kafo/data_types/integer.rb +3 -1
- data/lib/kafo/data_types/numeric.rb +3 -1
- data/lib/kafo/exceptions.rb +0 -3
- data/lib/kafo/hooking.rb +9 -3
- data/lib/kafo/kafo_configure.rb +39 -15
- data/lib/kafo/param.rb +3 -3
- data/lib/kafo/progress_bar.rb +13 -1
- data/lib/kafo/puppet_command.rb +8 -1
- data/lib/kafo/puppet_module.rb +6 -6
- data/lib/kafo/scenario_manager.rb +5 -4
- data/lib/kafo/scenario_option.rb +92 -0
- data/lib/kafo/store.rb +1 -1
- data/lib/kafo/string_helper.rb +1 -1
- data/lib/kafo/version.rb +1 -1
- data/lib/kafo/wizard.rb +25 -15
- data/modules/kafo_configure/metadata.json +1 -1
- metadata +5 -6
- data/doc/plantuml.jar +0 -0
- data/modules/kafo_configure/spec/fixtures/manifests/site.pp +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d246040f3b21a35b8ec0091c61333fbd5b3ecc8af9fb7d6ed666de850a101bf9
|
|
4
|
+
data.tar.gz: 9ab7731a6e46877cebfdffffbd7b06e5c11951821be90ff2743aa726c889c418
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb5d804b5c587646b9576f4ba6a67c9b0bd3702ddfad877750beb81b61710fd5b104db0fe36b7cf1cfd1f286d1548fb5b48acb9b778652df6c075600176df88d
|
|
7
|
+
data.tar.gz: 406667aac6a714122c3ec8d00a90ec630843bd6939167f23142e94bf465be51c8e098380815e869be64af9090b726a2e6a368542e18137a4fdb2493a52ed6246
|
data/Rakefile
CHANGED
|
@@ -4,7 +4,7 @@ load 'tasks/jenkins.rake'
|
|
|
4
4
|
|
|
5
5
|
Rake::TestTask.new('test:ruby') do |t|
|
|
6
6
|
t.libs << 'lib' << 'test'
|
|
7
|
-
t.test_files = FileList['test/**/*_test.rb']
|
|
7
|
+
t.test_files = FileList['test/**/*_test.rb'] - FileList['test/tmp/**/*_test.rb']
|
|
8
8
|
t.verbose = true
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -31,6 +31,13 @@ namespace 'test' do
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
begin
|
|
35
|
+
require 'rubocop/rake_task'
|
|
36
|
+
RuboCop::RakeTask.new
|
|
37
|
+
rescue LoadError
|
|
38
|
+
puts 'Rubocop not loaded'
|
|
39
|
+
end
|
|
40
|
+
|
|
34
41
|
CLEAN.include 'test/tmp'
|
|
35
42
|
|
|
36
43
|
task :test => ['test:ruby', 'test:puppet_modules']
|
|
@@ -3,7 +3,6 @@ require_relative 'definition'
|
|
|
3
3
|
module Kafo
|
|
4
4
|
module AppOption
|
|
5
5
|
module Declaration
|
|
6
|
-
|
|
7
6
|
include Clamp::Option::Declaration
|
|
8
7
|
|
|
9
8
|
def app_option(switches, type, description, opts = {}, &block)
|
|
@@ -13,7 +12,6 @@ module Kafo
|
|
|
13
12
|
declared_options << option
|
|
14
13
|
end
|
|
15
14
|
end
|
|
16
|
-
|
|
17
15
|
end
|
|
18
16
|
end
|
|
19
17
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
module Kafo
|
|
2
2
|
module AppOption
|
|
3
3
|
class Definition < Clamp::Option::Definition
|
|
4
|
-
|
|
5
4
|
def initialize(switches, type, description, options = {})
|
|
6
5
|
@advanced = options.fetch(:advanced, false)
|
|
7
6
|
super(switches, type, description, options)
|
|
@@ -10,7 +9,6 @@ module Kafo
|
|
|
10
9
|
def advanced?
|
|
11
10
|
@advanced
|
|
12
11
|
end
|
|
13
|
-
|
|
14
12
|
end
|
|
15
13
|
end
|
|
16
14
|
end
|
data/lib/kafo/color_scheme.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'highline
|
|
1
|
+
require 'highline'
|
|
2
2
|
|
|
3
3
|
module Kafo
|
|
4
4
|
class ColorScheme
|
|
@@ -7,7 +7,7 @@ module Kafo
|
|
|
7
7
|
::ENV['TERM'] && !`which tput 2> /dev/null`.empty? && `tput colors`.to_i > 0
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def initialize(options={})
|
|
10
|
+
def initialize(options = {})
|
|
11
11
|
@background = options[:background].nil? ? :dark : options[:background]
|
|
12
12
|
@colors = options[:colors].nil? ? self.class.colors_possible? : options[:colors]
|
|
13
13
|
end
|
data/lib/kafo/configuration.rb
CHANGED
|
@@ -5,43 +5,44 @@ require 'kafo/puppet_module'
|
|
|
5
5
|
require 'kafo/color_scheme'
|
|
6
6
|
require 'kafo/data_type_parser'
|
|
7
7
|
require 'kafo/execution_environment'
|
|
8
|
+
require 'kafo/scenario_option'
|
|
8
9
|
|
|
9
10
|
module Kafo
|
|
10
11
|
class Configuration
|
|
11
12
|
attr_reader :config_file, :answer_file, :scenario_id
|
|
12
13
|
|
|
13
14
|
DEFAULT = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
15
|
+
ScenarioOption::NAME => '',
|
|
16
|
+
ScenarioOption::DESCRIPTION => '',
|
|
17
|
+
ScenarioOption::ENABLED => true,
|
|
18
|
+
ScenarioOption::LOG_DIR => '/var/log/kafo',
|
|
19
|
+
ScenarioOption::LOG_OWNER => nil,
|
|
20
|
+
ScenarioOption::LOG_GROUP => nil,
|
|
21
|
+
ScenarioOption::STORE_DIR => '',
|
|
22
|
+
ScenarioOption::LOG_NAME => 'configuration.log',
|
|
23
|
+
ScenarioOption::LOG_LEVEL => 'notice',
|
|
24
|
+
ScenarioOption::NO_PREFIX => false,
|
|
25
|
+
ScenarioOption::MAPPING => {},
|
|
26
|
+
ScenarioOption::ANSWER_FILE => './config/answers.yaml',
|
|
27
|
+
ScenarioOption::INSTALLER_DIR => '.',
|
|
28
|
+
ScenarioOption::MODULE_DIRS => ['./modules'],
|
|
29
|
+
ScenarioOption::COLORS => Kafo::ColorScheme.colors_possible?,
|
|
30
|
+
ScenarioOption::COLOR_OF_BACKGROUND => :dark,
|
|
31
|
+
ScenarioOption::HOOK_DIRS => [],
|
|
32
|
+
ScenarioOption::CHECK_DIRS => nil,
|
|
33
|
+
ScenarioOption::CUSTOM => {},
|
|
34
|
+
ScenarioOption::FACTS => {},
|
|
35
|
+
ScenarioOption::LOW_PRIORITY_MODULES => [],
|
|
36
|
+
ScenarioOption::VERBOSE => false,
|
|
37
|
+
ScenarioOption::VERBOSE_LOG_LEVEL => 'notice',
|
|
38
|
+
ScenarioOption::SKIP_PUPPET_VERSION_CHECK => false,
|
|
39
|
+
ScenarioOption::PARSER_CACHE_PATH => nil,
|
|
40
|
+
ScenarioOption::IGNORE_UNDOCUMENTED => nil,
|
|
41
|
+
ScenarioOption::ORDER => nil,
|
|
42
|
+
ScenarioOption::HIERA_CONFIG => nil,
|
|
43
|
+
ScenarioOption::KAFO_MODULES_DIR => nil,
|
|
44
|
+
ScenarioOption::CONFIG_HEADER_FILE => nil,
|
|
45
|
+
ScenarioOption::DONT_SAVE_ANSWERS => nil,
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
def self.get_scenario_id(filename)
|
|
@@ -170,7 +171,7 @@ module Kafo
|
|
|
170
171
|
save_configuration(app)
|
|
171
172
|
end
|
|
172
173
|
|
|
173
|
-
def migrate_configuration(from_config, options={})
|
|
174
|
+
def migrate_configuration(from_config, options = {})
|
|
174
175
|
keys_to_skip = options.fetch(:skip, [])
|
|
175
176
|
keys = [:log_dir, :log_name, :log_level, :no_prefix,
|
|
176
177
|
:colors, :color_of_background, :custom, :verbose_log_level]
|
|
@@ -197,7 +198,7 @@ module Kafo
|
|
|
197
198
|
}
|
|
198
199
|
EOS
|
|
199
200
|
|
|
200
|
-
@logger.
|
|
201
|
+
@logger.info "Loading default values from puppet modules..."
|
|
201
202
|
command = PuppetCommand.new(dump_manifest, [], puppetconf, self).command
|
|
202
203
|
stdout, stderr, status = Open3.capture3(*PuppetCommand.format_command(command))
|
|
203
204
|
|
|
@@ -222,7 +223,7 @@ EOS
|
|
|
222
223
|
end
|
|
223
224
|
end
|
|
224
225
|
|
|
225
|
-
@logger.
|
|
226
|
+
@logger.info "... finished loading default values from puppet modules."
|
|
226
227
|
|
|
227
228
|
load_yaml_from_output(stdout.split($/))
|
|
228
229
|
end
|
data/lib/kafo/exceptions.rb
CHANGED
data/lib/kafo/hooking.rb
CHANGED
|
@@ -47,13 +47,19 @@ module Kafo
|
|
|
47
47
|
|
|
48
48
|
def execute(group, log_stage: true)
|
|
49
49
|
logger = Logger.new(group)
|
|
50
|
-
logger.
|
|
51
|
-
|
|
50
|
+
logger.info "Executing hooks in group #{group}" if log_stage
|
|
51
|
+
|
|
52
|
+
sorted_hooks = self.hooks[group].keys.sort do |a, b|
|
|
53
|
+
File.basename(a.to_s) <=> File.basename(b.to_s)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
sorted_hooks.each do |name|
|
|
52
57
|
hook = self.hooks[group][name]
|
|
53
58
|
result = HookContext.execute(self.kafo, logger, &hook)
|
|
54
59
|
logger.debug "Hook #{name} returned #{result.inspect}"
|
|
55
60
|
end
|
|
56
|
-
|
|
61
|
+
|
|
62
|
+
logger.info "All hooks in group #{group} finished" if log_stage
|
|
57
63
|
@group = nil
|
|
58
64
|
end
|
|
59
65
|
|
data/lib/kafo/kafo_configure.rb
CHANGED
|
@@ -143,7 +143,14 @@ module Kafo
|
|
|
143
143
|
# so we limit parsing only to app config options (because of --help and later defined params)
|
|
144
144
|
parse clamp_app_arguments
|
|
145
145
|
parse_app_arguments # set values from ARGS to config.app
|
|
146
|
-
|
|
146
|
+
|
|
147
|
+
if ARGV.any? { |option| ['--help', '--full-help'].include? option }
|
|
148
|
+
Logging.setup_verbose(level: :error)
|
|
149
|
+
else
|
|
150
|
+
Logging.setup(verbose: config.app[:verbose])
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
logger.notice("Loading installer configuration. This will take some time.")
|
|
147
154
|
self.class.set_color_scheme
|
|
148
155
|
|
|
149
156
|
self.class.hooking.execute(:init)
|
|
@@ -166,6 +173,10 @@ module Kafo
|
|
|
166
173
|
def run(*args)
|
|
167
174
|
started_at = Time.now
|
|
168
175
|
logger.debug("Running installer with args #{args.inspect}")
|
|
176
|
+
if config.app[:verbose]
|
|
177
|
+
logger.notice("Running installer with log based terminal output at level #{config.app[:verbose_log_level].upcase}.")
|
|
178
|
+
logger.notice("Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.")
|
|
179
|
+
end
|
|
169
180
|
super
|
|
170
181
|
ensure
|
|
171
182
|
logger.debug("Installer finished in #{Time.now - started_at} seconds")
|
|
@@ -311,6 +322,25 @@ module Kafo
|
|
|
311
322
|
self.class.app_option(*args, &block)
|
|
312
323
|
end
|
|
313
324
|
|
|
325
|
+
def terminal_log_levels_message
|
|
326
|
+
if ARGV.include?('--full-help')
|
|
327
|
+
<<~HEREDOC.chomp
|
|
328
|
+
Log level for log based terminal output.
|
|
329
|
+
The available levels are
|
|
330
|
+
ERROR - Only show errors which prevented the installer from completing successfully.
|
|
331
|
+
WARN - Deprecation warnings and other information users may want to be aware of.
|
|
332
|
+
NOTICE - High level information about installer execution and progress.
|
|
333
|
+
INFO - More detailed information about execution and progress. Also shows when the installer makes a change to system configuration.
|
|
334
|
+
DEBUG - Show all information about execution, including configuration items where no change was needed.
|
|
335
|
+
HEREDOC
|
|
336
|
+
else
|
|
337
|
+
<<~HEREDOC.chomp
|
|
338
|
+
Log level for log based terminal output.
|
|
339
|
+
The available levels are ERROR, WARN, NOTICE, INFO, DEBUG. See --full-help for definitions.
|
|
340
|
+
HEREDOC
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
|
|
314
344
|
def set_app_options
|
|
315
345
|
app_option ['--[no-]colors'], :flag, 'Use color output on STDOUT',
|
|
316
346
|
:default => config.app[:colors], :advanced => true
|
|
@@ -333,7 +363,7 @@ module Kafo
|
|
|
333
363
|
:default => false, :advanced => true
|
|
334
364
|
app_option ['-v', '--[no-]verbose'], :flag, 'Display log on STDOUT instead of progressbar',
|
|
335
365
|
:default => config.app[:verbose]
|
|
336
|
-
app_option ['-l', '--verbose-log-level'], 'LEVEL',
|
|
366
|
+
app_option ['-l', '--verbose-log-level'], 'LEVEL', terminal_log_levels_message,
|
|
337
367
|
:default => 'notice'
|
|
338
368
|
app_option ['-S', '--scenario'], 'SCENARIO', 'Use installation scenario'
|
|
339
369
|
app_option ['--disable-scenario'], 'SCENARIO', 'Disable installation scenario',
|
|
@@ -365,9 +395,9 @@ module Kafo
|
|
|
365
395
|
params.sort.each do |param|
|
|
366
396
|
doc = param.doc.nil? ? 'UNDOCUMENTED' : param.doc.join("\n")
|
|
367
397
|
app_option parametrize(param), '', doc + " (current: #{param.value_to_s})",
|
|
368
|
-
|
|
398
|
+
:multivalued => param.multivalued?
|
|
369
399
|
app_option parametrize(param, 'reset-'), :flag,
|
|
370
|
-
|
|
400
|
+
"Reset #{param.name} to the default value (#{param.default_to_s})"
|
|
371
401
|
end
|
|
372
402
|
end
|
|
373
403
|
|
|
@@ -440,7 +470,7 @@ module Kafo
|
|
|
440
470
|
end
|
|
441
471
|
|
|
442
472
|
def validate_all(logging = true)
|
|
443
|
-
logger.
|
|
473
|
+
logger.info "Running validation checks."
|
|
444
474
|
results = enabled_params.map do |param|
|
|
445
475
|
result = param.valid?
|
|
446
476
|
errors = param.validation_errors.join(', ')
|
|
@@ -477,13 +507,7 @@ module Kafo
|
|
|
477
507
|
log_parser = PuppetLogParser.new
|
|
478
508
|
logger = Logger.new('configure')
|
|
479
509
|
|
|
480
|
-
|
|
481
|
-
Starting system configuration.
|
|
482
|
-
The total number of configuration tasks may increase during the run.
|
|
483
|
-
Observe logs or specify --verbose-log-level to see individual configuration tasks.
|
|
484
|
-
HEREDOC
|
|
485
|
-
|
|
486
|
-
logger.notice(start_message.chomp)
|
|
510
|
+
logger.notice("Starting system configuration.")
|
|
487
511
|
|
|
488
512
|
PTY.spawn(*PuppetCommand.format_command(command)) do |stdin, stdout, pid|
|
|
489
513
|
begin
|
|
@@ -492,9 +516,9 @@ HEREDOC
|
|
|
492
516
|
method, message = log_parser.parse(line)
|
|
493
517
|
progress_log(method, message, logger)
|
|
494
518
|
|
|
495
|
-
if (output = line.match(
|
|
496
|
-
if (output[:count].to_i %
|
|
497
|
-
logger.notice("#{output[:count].to_i - 1} out of #{output[:total]}
|
|
519
|
+
if (output = line.match(/(.+\]): Starting to evaluate the resource( \((?<count>\d+) of (?<total>\d+)\))?/))
|
|
520
|
+
if (output[:count].to_i % 250) == 1 && output[:count].to_i != 1
|
|
521
|
+
logger.notice("#{output[:count].to_i - 1} configuration steps out of #{output[:total]} steps complete.")
|
|
498
522
|
end
|
|
499
523
|
end
|
|
500
524
|
|
data/lib/kafo/param.rb
CHANGED
|
@@ -123,12 +123,12 @@ module Kafo
|
|
|
123
123
|
@type.multivalued?
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
-
def <=>
|
|
126
|
+
def <=>(other)
|
|
127
127
|
unless @module.configuration.app[:no_prefix]
|
|
128
|
-
r = self.module_name <=>
|
|
128
|
+
r = self.module_name <=> other.module_name
|
|
129
129
|
return r unless r == 0
|
|
130
130
|
end
|
|
131
|
-
self.name <=>
|
|
131
|
+
self.name <=> other.name
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
def visible?(context = [])
|
data/lib/kafo/progress_bar.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
require 'highline'
|
|
2
3
|
require 'powerbar'
|
|
3
4
|
require 'ansi/code'
|
|
4
5
|
require 'set'
|
|
@@ -20,7 +21,7 @@ module Kafo
|
|
|
20
21
|
@all_lines = 0
|
|
21
22
|
@total = :unknown
|
|
22
23
|
@resources = Set.new
|
|
23
|
-
@term_width =
|
|
24
|
+
@term_width = terminal_width
|
|
24
25
|
@bar = PowerBar.new
|
|
25
26
|
@bar.settings.tty.infinite.template.main = infinite_template
|
|
26
27
|
@bar.settings.tty.finite.template.main = finite_template
|
|
@@ -85,6 +86,17 @@ module Kafo
|
|
|
85
86
|
|
|
86
87
|
private
|
|
87
88
|
|
|
89
|
+
def terminal_width
|
|
90
|
+
# HighLine 2 has Terminal, 1 has SystemExtensions
|
|
91
|
+
terminal_size = if HighLine.respond_to?(:default_instance)
|
|
92
|
+
HighLine.default_instance.terminal.terminal_size
|
|
93
|
+
else
|
|
94
|
+
HighLine::SystemExtensions.terminal_size
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
terminal_size ? (terminal_size[0] || 0) : 0
|
|
98
|
+
end
|
|
99
|
+
|
|
88
100
|
def done_message
|
|
89
101
|
text = 'Done'
|
|
90
102
|
text + (' ' * (50 - text.length))
|
data/lib/kafo/puppet_command.rb
CHANGED
|
@@ -43,8 +43,15 @@ module Kafo
|
|
|
43
43
|
File.join([bin_path, bin_name].compact)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
def self.is_aio_puppet?
|
|
47
|
+
puppet_command = search_puppet_path('puppet')
|
|
48
|
+
File.realpath(puppet_command).start_with?('/opt/puppetlabs')
|
|
49
|
+
rescue Errno::ENOENT
|
|
50
|
+
false
|
|
51
|
+
end
|
|
52
|
+
|
|
46
53
|
def self.format_command(command)
|
|
47
|
-
if
|
|
54
|
+
if is_aio_puppet?
|
|
48
55
|
[clean_env_vars, command, :unsetenv_others => true]
|
|
49
56
|
else
|
|
50
57
|
[::ENV, command, :unsetenv_others => false]
|
data/lib/kafo/puppet_module.rb
CHANGED
|
@@ -96,16 +96,16 @@ module Kafo
|
|
|
96
96
|
Hash[params.map { |param| [param.name, param.value] }]
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
def <=>
|
|
99
|
+
def <=>(other)
|
|
100
100
|
@configuration.app[:low_priority_modules].each do |module_name|
|
|
101
|
-
return 1 if self.name.include?(module_name) && !
|
|
102
|
-
return -1 if !self.name.include?(module_name) &&
|
|
103
|
-
if self.name.include?(module_name) &&
|
|
104
|
-
return self.name.sub(/.*#{module_name}/, '') <=>
|
|
101
|
+
return 1 if self.name.include?(module_name) && !other.name.include?(module_name)
|
|
102
|
+
return -1 if !self.name.include?(module_name) && other.name.include?(module_name)
|
|
103
|
+
if self.name.include?(module_name) && other.name.include?(module_name)
|
|
104
|
+
return self.name.sub(/.*#{module_name}/, '') <=> other.name.sub(/.*#{module_name}/, '')
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
self.name <=>
|
|
108
|
+
self.name <=> other.name
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
private
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
require 'highline/import'
|
|
2
3
|
require 'kafo_wizards'
|
|
3
4
|
require 'pathname'
|
|
4
5
|
|
|
@@ -6,7 +7,7 @@ module Kafo
|
|
|
6
7
|
class ScenarioManager
|
|
7
8
|
attr_reader :config_dir, :last_scenario_link, :previous_scenario
|
|
8
9
|
|
|
9
|
-
def initialize(config, last_scenario_link_name='last_scenario.yaml')
|
|
10
|
+
def initialize(config, last_scenario_link_name = 'last_scenario.yaml')
|
|
10
11
|
@logger = Logger.new('scenario_manager')
|
|
11
12
|
@config_dir = File.file?(config) ? File.dirname(config) : config
|
|
12
13
|
@last_scenario_link = File.join(config_dir, last_scenario_link_name)
|
|
@@ -31,7 +32,7 @@ module Kafo
|
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
def list_available_scenarios
|
|
34
|
-
say ::HighLine.color("Available scenarios", :
|
|
35
|
+
say ::HighLine.color("Available scenarios", :info)
|
|
35
36
|
available_scenarios.each do |config_file, content|
|
|
36
37
|
scenario = File.basename(config_file, '.yaml')
|
|
37
38
|
use = (File.expand_path(config_file) == @previous_scenario ? 'INSTALLED' : "use: --scenario #{scenario}")
|
|
@@ -77,7 +78,7 @@ module Kafo
|
|
|
77
78
|
!!(defined?(CONFIG_DIR) && CONFIG_DIR)
|
|
78
79
|
end
|
|
79
80
|
|
|
80
|
-
def scenario_from_args(arg_name='--scenario|-S')
|
|
81
|
+
def scenario_from_args(arg_name = '--scenario|-S')
|
|
81
82
|
# try scenario provided in the args via -S or --scenario
|
|
82
83
|
ARGV.each_with_index do |arg, index|
|
|
83
84
|
parsed = arg.match(/^(#{arg_name})($|=(?<scenario>\S+))/)
|
|
@@ -111,7 +112,7 @@ module Kafo
|
|
|
111
112
|
end
|
|
112
113
|
|
|
113
114
|
def show_scenario_diff(prev_scenario, new_scenario)
|
|
114
|
-
say ::HighLine.color("Scenarios are being compared, that may take a while...", :
|
|
115
|
+
say ::HighLine.color("Scenarios are being compared, that may take a while...", :info)
|
|
115
116
|
prev_conf = load_and_setup_configuration(prev_scenario)
|
|
116
117
|
new_conf = load_and_setup_configuration(new_scenario)
|
|
117
118
|
print_scenario_diff(prev_conf, new_conf)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module Kafo
|
|
2
|
+
# A class containing constants for all scenario options
|
|
3
|
+
class ScenarioOption
|
|
4
|
+
# @group Basic
|
|
5
|
+
|
|
6
|
+
# Human readable scenario name
|
|
7
|
+
NAME = :name
|
|
8
|
+
|
|
9
|
+
# Description of the installer scenario and its purpose
|
|
10
|
+
DESCRIPTION = :description
|
|
11
|
+
|
|
12
|
+
# Path to answer file, if the file does not exist a $pwd/config/answers.yaml is used as a fallback
|
|
13
|
+
ANSWER_FILE = :answer_file
|
|
14
|
+
|
|
15
|
+
# Enable colors? If you don't touch this, we'll autodetect terminal capabilities
|
|
16
|
+
COLORS = :colors
|
|
17
|
+
# Color scheme, we support :bright and :dark (first is better for white background, dark for black background)
|
|
18
|
+
COLOR_OF_BACKGROUND = :color_of_background
|
|
19
|
+
|
|
20
|
+
# @group Logging
|
|
21
|
+
|
|
22
|
+
# Destination for the log files
|
|
23
|
+
LOG_DIR = :log_dir
|
|
24
|
+
LOG_NAME = :log_name
|
|
25
|
+
LOG_LEVEL = :log_level
|
|
26
|
+
LOG_OWNER = :log_owner
|
|
27
|
+
LOG_GROUP = :log_group
|
|
28
|
+
|
|
29
|
+
# Whether verbose logging is enabled
|
|
30
|
+
VERBOSE = :verbose
|
|
31
|
+
|
|
32
|
+
# When verbose logging is enabled, which level (and up) is shown.
|
|
33
|
+
VERBOSE_LOG_LEVEL = :verbose_log_level
|
|
34
|
+
|
|
35
|
+
# @group State
|
|
36
|
+
|
|
37
|
+
# Custom storage is handy if you use hooks and you must store some
|
|
38
|
+
# configuration which should persist among installer runs. It can be also
|
|
39
|
+
# used for passing value from one hook to another.
|
|
40
|
+
CUSTOM = :custom
|
|
41
|
+
|
|
42
|
+
FACTS = :facts
|
|
43
|
+
|
|
44
|
+
# @group Advanced
|
|
45
|
+
|
|
46
|
+
# Checks, implemented as executable files, are loaded from the listed
|
|
47
|
+
# directories.
|
|
48
|
+
CHECK_DIRS = :check_dirs
|
|
49
|
+
|
|
50
|
+
# Hooks in these extra directories will be loaded, by default they are
|
|
51
|
+
# loaded from $installer_dir/hooks/$type when you specify your directory,
|
|
52
|
+
# it will be search for $yourdir/$type/*.rb
|
|
53
|
+
HOOK_DIRS = :hook_dirs
|
|
54
|
+
|
|
55
|
+
# Option to load puppet modules from a specific path. Optional and
|
|
56
|
+
# $pwd/modules is used by default, multiple dirs are allowed
|
|
57
|
+
MODULE_DIRS = :module_dirs
|
|
58
|
+
|
|
59
|
+
# Kafo has a cache for information parsed from Puppet modules. This
|
|
60
|
+
# determines the location where that information is stored.
|
|
61
|
+
PARSER_CACHE_PATH = :parser_cache_path
|
|
62
|
+
|
|
63
|
+
# By default all module parameters must be documented or an error is
|
|
64
|
+
# raised. This can be used to not raise an error when undocumented
|
|
65
|
+
# parameters are found.
|
|
66
|
+
IGNORE_UNDOCUMENTED = :ignore_undocumented
|
|
67
|
+
|
|
68
|
+
# Kafo tuning, customization of core functionality
|
|
69
|
+
|
|
70
|
+
# An optional mapping of classes
|
|
71
|
+
MAPPING = :mapping
|
|
72
|
+
NO_PREFIX = :no_prefix
|
|
73
|
+
ORDER = :order
|
|
74
|
+
LOW_PRIORITY_MODULES = :low_priority_modules
|
|
75
|
+
HIERA_CONFIG = :hiera_config
|
|
76
|
+
KAFO_MODULES_DIR = :kafo_modules_dir
|
|
77
|
+
CONFIG_HEADER_FILE = :config_header_file
|
|
78
|
+
DONT_SAVE_ANSWERS = :dont_save_answers
|
|
79
|
+
|
|
80
|
+
# These options are in DEFAULT but not in kafo.yaml.example
|
|
81
|
+
|
|
82
|
+
# Whether the scenario is enabled or not
|
|
83
|
+
ENABLED = :enabled
|
|
84
|
+
STORE_DIR = :store_dir
|
|
85
|
+
INSTALLER_DIR = :installer_dir
|
|
86
|
+
|
|
87
|
+
# Puppet modules declare the Puppet version they're compatible with. Kafo
|
|
88
|
+
# implements checks to verify this is correct with the Puppet version
|
|
89
|
+
# that's running. This can be used to bypass the checks
|
|
90
|
+
SKIP_PUPPET_VERSION_CHECK = :skip_puppet_version_check
|
|
91
|
+
end
|
|
92
|
+
end
|
data/lib/kafo/store.rb
CHANGED
data/lib/kafo/string_helper.rb
CHANGED
data/lib/kafo/version.rb
CHANGED
data/lib/kafo/wizard.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
-
require '
|
|
2
|
+
require 'forwardable'
|
|
3
|
+
require 'highline'
|
|
3
4
|
require 'yaml'
|
|
4
5
|
|
|
5
6
|
module Kafo
|
|
@@ -8,14 +9,17 @@ module Kafo
|
|
|
8
9
|
Kafo::ENV::LANG =~ /UTF-8\z/
|
|
9
10
|
end
|
|
10
11
|
|
|
12
|
+
extend Forwardable
|
|
13
|
+
def_delegators :@highline, :agree, :ask, :choose, :say
|
|
14
|
+
|
|
11
15
|
OK = utf_support? ? '✓' : 'y'
|
|
12
16
|
NO = utf_support? ? '✗' : 'n'
|
|
13
17
|
|
|
14
|
-
def initialize(kafo)
|
|
18
|
+
def initialize(kafo, input = $stdin, output = $stdout)
|
|
15
19
|
@kafo = kafo
|
|
16
20
|
@config = kafo.config
|
|
17
21
|
@name = @config.app[:name] || 'Kafo'
|
|
18
|
-
setup_terminal
|
|
22
|
+
@highline = setup_terminal(input, output)
|
|
19
23
|
end
|
|
20
24
|
|
|
21
25
|
def run
|
|
@@ -68,7 +72,7 @@ END
|
|
|
68
72
|
|
|
69
73
|
def display_hash
|
|
70
74
|
data = Hash[@config.modules.map { |mod| [mod.name, mod.enabled? ? mod.params_hash : false] }]
|
|
71
|
-
say HighLine.color(YAML.dump(data), :
|
|
75
|
+
say HighLine.color(YAML.dump(data), :info)
|
|
72
76
|
end
|
|
73
77
|
|
|
74
78
|
def configure_module(mod)
|
|
@@ -79,7 +83,7 @@ END
|
|
|
79
83
|
menu.prompt = 'Choose an option from the menu... '
|
|
80
84
|
menu.select_by = :index
|
|
81
85
|
|
|
82
|
-
menu.choice("Enable/disable #{mod.name} module, current value: #{HighLine.color(mod.enabled?.to_s, :
|
|
86
|
+
menu.choice("Enable/disable #{mod.name} module, current value: #{HighLine.color(mod.enabled?.to_s, :info)}") { turn_module(mod) }
|
|
83
87
|
if mod.enabled?
|
|
84
88
|
render_params(mod.primary_parameter_group.params, menu)
|
|
85
89
|
|
|
@@ -114,7 +118,7 @@ END
|
|
|
114
118
|
def render_params(params, menu)
|
|
115
119
|
params.each do |param|
|
|
116
120
|
if param.visible?(@kafo.params)
|
|
117
|
-
menu.choice "Set #{HighLine.color(param.name, :important)}, current value: #{HighLine.color(param.value_to_s, :
|
|
121
|
+
menu.choice "Set #{HighLine.color(param.name, :important)}, current value: #{HighLine.color(param.value_to_s, :info)}" do
|
|
118
122
|
configure(param)
|
|
119
123
|
end
|
|
120
124
|
end
|
|
@@ -141,13 +145,13 @@ END
|
|
|
141
145
|
end
|
|
142
146
|
|
|
143
147
|
def configure_single(param)
|
|
144
|
-
say "\ncurrent value: #{HighLine.color(param.value_to_s, :
|
|
148
|
+
say "\ncurrent value: #{HighLine.color(param.value_to_s, :info)}"
|
|
145
149
|
ask("new value:")
|
|
146
150
|
end
|
|
147
151
|
|
|
148
152
|
def configure_multi(param)
|
|
149
|
-
say HighLine.color('every line is a separate value, blank line to quit, for hash use key:value syntax', :
|
|
150
|
-
say "\ncurrent value: #{HighLine.color(param.value_to_s, :
|
|
153
|
+
say HighLine.color('every line is a separate value, blank line to quit, for hash use key:value syntax', :info)
|
|
154
|
+
say "\ncurrent value: #{HighLine.color(param.value_to_s, :info)} %>"
|
|
151
155
|
ask("new value:") do |q|
|
|
152
156
|
q.gather = ""
|
|
153
157
|
end
|
|
@@ -164,7 +168,7 @@ END
|
|
|
164
168
|
say "\n" + HighLine.color("Resetting parameters of module #{mod.name}", :headline)
|
|
165
169
|
choose do |menu|
|
|
166
170
|
mod.params.each do |param|
|
|
167
|
-
menu.choice "Reset #{HighLine.color(param.name, :important)}, current value: #{HighLine.color(param.value_to_s, :
|
|
171
|
+
menu.choice "Reset #{HighLine.color(param.name, :important)}, current value: #{HighLine.color(param.value_to_s, :info)}, default value: #{HighLine.color(param.default_to_s, :info)}" do
|
|
168
172
|
reset(param)
|
|
169
173
|
end if param.visible?(@kafo.params)
|
|
170
174
|
end
|
|
@@ -178,11 +182,17 @@ END
|
|
|
178
182
|
say "\n" + HighLine.color("Value for #{param.name} reset to default", :important)
|
|
179
183
|
end
|
|
180
184
|
|
|
181
|
-
def setup_terminal
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
def setup_terminal(input, output)
|
|
186
|
+
highline = HighLine.new(input, output)
|
|
187
|
+
# HighLine 2 vs 1
|
|
188
|
+
data = if highline.respond_to?(:terminal)
|
|
189
|
+
highline.terminal.terminal_size
|
|
190
|
+
else
|
|
191
|
+
HighLine::SystemExtensions.terminal_size
|
|
192
|
+
end
|
|
193
|
+
highline.wrap_at = data.first > 80 ? 80 : data.first if data.first
|
|
194
|
+
highline.page_at = data.last if data.last
|
|
195
|
+
highline
|
|
186
196
|
end
|
|
187
197
|
end
|
|
188
198
|
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
|
+
version: 6.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:
|
|
11
|
+
date: 2021-03-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -171,7 +171,7 @@ dependencies:
|
|
|
171
171
|
version: 1.6.21
|
|
172
172
|
- - "<"
|
|
173
173
|
- !ruby/object:Gem::Version
|
|
174
|
-
version: '
|
|
174
|
+
version: '3.0'
|
|
175
175
|
type: :runtime
|
|
176
176
|
prerelease: false
|
|
177
177
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -181,7 +181,7 @@ dependencies:
|
|
|
181
181
|
version: 1.6.21
|
|
182
182
|
- - "<"
|
|
183
183
|
- !ruby/object:Gem::Version
|
|
184
|
-
version: '
|
|
184
|
+
version: '3.0'
|
|
185
185
|
- !ruby/object:Gem::Dependency
|
|
186
186
|
name: powerbar
|
|
187
187
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -217,7 +217,6 @@ files:
|
|
|
217
217
|
- config/kafo.yaml.example
|
|
218
218
|
- doc/kafo_run.png
|
|
219
219
|
- doc/kafo_run.uml
|
|
220
|
-
- doc/plantuml.jar
|
|
221
220
|
- lib/kafo.rb
|
|
222
221
|
- lib/kafo/app_option/declaration.rb
|
|
223
222
|
- lib/kafo/app_option/definition.rb
|
|
@@ -276,6 +275,7 @@ files:
|
|
|
276
275
|
- lib/kafo/puppet_log_parser.rb
|
|
277
276
|
- lib/kafo/puppet_module.rb
|
|
278
277
|
- lib/kafo/scenario_manager.rb
|
|
278
|
+
- lib/kafo/scenario_option.rb
|
|
279
279
|
- lib/kafo/store.rb
|
|
280
280
|
- lib/kafo/string_helper.rb
|
|
281
281
|
- lib/kafo/system_checker.rb
|
|
@@ -294,7 +294,6 @@ files:
|
|
|
294
294
|
- modules/kafo_configure/spec/classes/init_spec.rb
|
|
295
295
|
- modules/kafo_configure/spec/fixtures/hiera/hiera.yaml
|
|
296
296
|
- modules/kafo_configure/spec/fixtures/hiera/test.yaml
|
|
297
|
-
- modules/kafo_configure/spec/fixtures/manifests/site.pp
|
|
298
297
|
- modules/kafo_configure/spec/fixtures/modules/dummy/manifests/init.pp
|
|
299
298
|
- modules/kafo_configure/spec/fixtures/modules/dummy/manifests/params.pp
|
|
300
299
|
- modules/kafo_configure/spec/functions/dump_lookups_spec.rb
|
data/doc/plantuml.jar
DELETED
|
Binary file
|
|
File without changes
|