kafo 0.9.5 → 0.9.6
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/README.md +14 -0
- data/lib/kafo/configuration.rb +1 -0
- data/lib/kafo/exit_handler.rb +2 -1
- data/lib/kafo/kafo_configure.rb +26 -19
- data/lib/kafo/puppet_command.rb +1 -1
- data/lib/kafo/puppet_log_parser.rb +25 -0
- data/lib/kafo/store.rb +38 -0
- data/lib/kafo/version.rb +1 -1
- data/modules/kafo_configure/manifests/init.pp +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1abb02cb76f9cc6da781a4445c9d64e70ca1e8e2
|
4
|
+
data.tar.gz: 80bfce63b57202c0a67ce9c97ca9813e336b95aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f40af68f5e25559d989390c134de82122476c8f46321d52bcc5d76025405507f1206b246823298e7a37cfec43e000afd2c2f7603eb20eb66482f8b5553c8de88
|
7
|
+
data.tar.gz: d30b8109790718f85b2ef2b3458c1d95b2f2358552ac6ec696acd4ed8fd36d6e1b65fe2014f6d28232286e0b6135e97056660d5ef4bc66f49f422ca1e7f19f82
|
data/README.md
CHANGED
@@ -365,6 +365,18 @@ and e.g. migration to new scenario is still possible.
|
|
365
365
|
|
366
366
|
Disabled scenario can be enabled back again with `foreman-installer --enable-scenario SCENARIO`.
|
367
367
|
|
368
|
+
## Store
|
369
|
+
|
370
|
+
Kafo features simple key value store that can be used to ship data with the installer.
|
371
|
+
|
372
|
+
The data are loaded from yaml files located in `store.d` directory that is either specified in
|
373
|
+
the scenario config's `store_dir:` or on same directory
|
374
|
+
level as configuration directory containing the scenarios. The files are loaded in
|
375
|
+
alphabetical order and the data are merged in that order.
|
376
|
+
|
377
|
+
The store is read-only during the run and the content can be influenced only by adding
|
378
|
+
new files into the `store.d` directory (e.g. from installer plugins)
|
379
|
+
|
368
380
|
## Documentation
|
369
381
|
|
370
382
|
Every parameter that can be set by kafo *must* be documented. This means that
|
@@ -883,6 +895,7 @@ paths. In order to do that you can use following configuration options:
|
|
883
895
|
* :hook_dirs: /user/share/foreman-installer/hooks
|
884
896
|
* :check_dirs: /user/share/foreman-installer/checks
|
885
897
|
* :kafo_modules_dir: /usr/share/kafo/modules
|
898
|
+
* :store_dir: /etc/foreman-installer/store.d
|
886
899
|
|
887
900
|
Answer file is obvious. The "installer_dir" is the place where your installer is
|
888
901
|
located. E.g. system checks will be loaded from here (under checks
|
@@ -1044,6 +1057,7 @@ Other exit codes that can be returned:
|
|
1044
1057
|
* '25' means that kafo could not get default values from puppet
|
1045
1058
|
* '26' means that kafo could not find the specified scenario
|
1046
1059
|
* '27' means that kafo found found scenario configuration error that prevents installation from continuing
|
1060
|
+
* '28' means that a value is missing for a parameter given on the command line
|
1047
1061
|
* '130' user interrupt (^C)
|
1048
1062
|
|
1049
1063
|
## Running Puppet Profiling
|
data/lib/kafo/configuration.rb
CHANGED
data/lib/kafo/exit_handler.rb
CHANGED
data/lib/kafo/kafo_configure.rb
CHANGED
@@ -13,6 +13,7 @@ require 'kafo/color_scheme'
|
|
13
13
|
require 'kafo_parsers/exceptions'
|
14
14
|
require 'kafo/exceptions'
|
15
15
|
require 'kafo/migrations'
|
16
|
+
require 'kafo/store'
|
16
17
|
require 'kafo/configuration'
|
17
18
|
require 'kafo/logger'
|
18
19
|
require 'kafo/string_helper'
|
@@ -20,6 +21,7 @@ require 'kafo/help_builder'
|
|
20
21
|
require 'kafo/wizard'
|
21
22
|
require 'kafo/system_checker'
|
22
23
|
require 'kafo/puppet_command'
|
24
|
+
require 'kafo/puppet_log_parser'
|
23
25
|
require 'kafo/progress_bar'
|
24
26
|
require 'kafo/hooking'
|
25
27
|
require 'kafo/exit_handler'
|
@@ -33,7 +35,7 @@ module Kafo
|
|
33
35
|
class << self
|
34
36
|
attr_accessor :config, :root_dir, :config_file, :gem_root,
|
35
37
|
:module_dirs, :kafo_modules_dir, :verbose, :app_options, :logger,
|
36
|
-
:check_dirs, :exit_handler, :scenario_manager
|
38
|
+
:check_dirs, :exit_handler, :scenario_manager, :store
|
37
39
|
attr_writer :hooking
|
38
40
|
|
39
41
|
def hooking
|
@@ -102,6 +104,10 @@ module Kafo
|
|
102
104
|
self.class.config
|
103
105
|
end
|
104
106
|
|
107
|
+
def store
|
108
|
+
self.class.store
|
109
|
+
end
|
110
|
+
|
105
111
|
def logger
|
106
112
|
self.class.logger
|
107
113
|
end
|
@@ -230,6 +236,7 @@ module Kafo
|
|
230
236
|
self.class.gem_root = self.class.config.gem_root
|
231
237
|
self.class.kafo_modules_dir = self.class.config.kafo_modules_dir
|
232
238
|
self.class.hooking.load
|
239
|
+
self.class.store = setup_store
|
233
240
|
self.class.hooking.kafo = self
|
234
241
|
end
|
235
242
|
|
@@ -247,6 +254,14 @@ module Kafo
|
|
247
254
|
ScenarioManager.new((defined?(CONFIG_DIR) && CONFIG_DIR) || (defined?(CONFIG_FILE) && CONFIG_FILE))
|
248
255
|
end
|
249
256
|
|
257
|
+
def setup_store
|
258
|
+
store = Store.new()
|
259
|
+
store_path = self.class.config.app[:store_dir]
|
260
|
+
store_path = File.expand_path(File.join(CONFIG_DIR, '../store.d')) if store_path.empty? && defined?(CONFIG_DIR)
|
261
|
+
store.add_dir(store_path) if File.exists?(store_path)
|
262
|
+
store
|
263
|
+
end
|
264
|
+
|
250
265
|
def set_parameters
|
251
266
|
config.preset_defaults_from_puppet
|
252
267
|
self.class.hooking.execute(:pre_values)
|
@@ -357,10 +372,18 @@ module Kafo
|
|
357
372
|
variable_name = u(with_prefix(param))
|
358
373
|
variable_name += '_list' if param.multivalued?
|
359
374
|
cli_value = instance_variable_get("@#{variable_name}")
|
375
|
+
if argument_missing?(cli_value)
|
376
|
+
puts "Parameter #{with_prefix(param)} is missing a value on the command line"
|
377
|
+
self.class.exit(:missing_argument)
|
378
|
+
end
|
360
379
|
param.value = cli_value unless cli_value.nil?
|
361
380
|
end
|
362
381
|
end
|
363
382
|
|
383
|
+
def argument_missing?(value)
|
384
|
+
!!self.class.declared_options.find { |opt| opt.handles?(value) }
|
385
|
+
end
|
386
|
+
|
364
387
|
def store_params(file = nil)
|
365
388
|
data = Hash[config.modules.map { |mod| [mod.identifier, mod.enabled? ? mod.params_hash : false] }]
|
366
389
|
config.store(data, file)
|
@@ -400,10 +423,11 @@ module Kafo
|
|
400
423
|
options.push '--profile' if profile?
|
401
424
|
begin
|
402
425
|
command = PuppetCommand.new('include kafo_configure', options).command
|
426
|
+
log_parser = PuppetLogParser.new
|
403
427
|
PTY.spawn(command) do |stdin, stdout, pid|
|
404
428
|
begin
|
405
429
|
stdin.each do |line|
|
406
|
-
progress_log(*
|
430
|
+
progress_log(*log_parser.parse(line))
|
407
431
|
@progress_bar.update(line) if @progress_bar
|
408
432
|
end
|
409
433
|
rescue Errno::EIO # we reach end of input
|
@@ -432,23 +456,6 @@ module Kafo
|
|
432
456
|
logger.send(method, message)
|
433
457
|
end
|
434
458
|
|
435
|
-
def puppet_parse(line)
|
436
|
-
method, message = case
|
437
|
-
when line =~ /^Error:(.*)/i || line =~ /^Err:(.*)/i
|
438
|
-
[:error, $1]
|
439
|
-
when line =~ /^Warning:(.*)/i || line =~ /^Notice:(.*)/i
|
440
|
-
[:warn, $1]
|
441
|
-
when line =~ /^Info:(.*)/i
|
442
|
-
[:info, $1]
|
443
|
-
when line =~ /^Debug:(.*)/i
|
444
|
-
[:debug, $1]
|
445
|
-
else
|
446
|
-
[:info, line]
|
447
|
-
end
|
448
|
-
|
449
|
-
return [method, message.chomp]
|
450
|
-
end
|
451
|
-
|
452
459
|
def unset
|
453
460
|
params.select { |p| p.module.enabled? && p.value_set.nil? }
|
454
461
|
end
|
data/lib/kafo/puppet_command.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Kafo
|
2
|
+
class PuppetLogParser
|
3
|
+
def initialize
|
4
|
+
@last_level = nil
|
5
|
+
end
|
6
|
+
|
7
|
+
def parse(line)
|
8
|
+
method, message = case
|
9
|
+
when line =~ /^Error:(.*)/i || line =~ /^Err:(.*)/i
|
10
|
+
[:error, $1]
|
11
|
+
when line =~ /^Warning:(.*)/i || line =~ /^Notice:(.*)/i
|
12
|
+
[:warn, $1]
|
13
|
+
when line =~ /^Info:(.*)/i
|
14
|
+
[:info, $1]
|
15
|
+
when line =~ /^Debug:(.*)/i
|
16
|
+
[:debug, $1]
|
17
|
+
else
|
18
|
+
[@last_level.nil? ? :info : @last_level, line]
|
19
|
+
end
|
20
|
+
|
21
|
+
@last_level = method
|
22
|
+
return [method, message.chomp]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/kafo/store.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Kafo
|
4
|
+
class Store
|
5
|
+
attr_accessor :data
|
6
|
+
|
7
|
+
def initialize(path=nil)
|
8
|
+
@data = {}
|
9
|
+
load_path(path) if path
|
10
|
+
end
|
11
|
+
|
12
|
+
def load_path(path)
|
13
|
+
if File.directory?(path)
|
14
|
+
add_dir(path)
|
15
|
+
else
|
16
|
+
add_file(path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def add(data)
|
21
|
+
@data.merge!(data)
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_dir(path)
|
25
|
+
Dir.glob(File.join(path, "*.yaml")).sort.each do |file|
|
26
|
+
add_file(file)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_file(file)
|
31
|
+
add(YAML.load_file(file))
|
32
|
+
end
|
33
|
+
|
34
|
+
def get(key)
|
35
|
+
@data[key]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/kafo/version.rb
CHANGED
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: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Hulan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -249,8 +249,10 @@ files:
|
|
249
249
|
- lib/kafo/progress_bars/black_white.rb
|
250
250
|
- lib/kafo/progress_bars/colored.rb
|
251
251
|
- lib/kafo/puppet_command.rb
|
252
|
+
- lib/kafo/puppet_log_parser.rb
|
252
253
|
- lib/kafo/puppet_module.rb
|
253
254
|
- lib/kafo/scenario_manager.rb
|
255
|
+
- lib/kafo/store.rb
|
254
256
|
- lib/kafo/string_helper.rb
|
255
257
|
- lib/kafo/system_checker.rb
|
256
258
|
- lib/kafo/validator.rb
|