kafo 6.3.0 → 6.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -0
- data/lib/kafo/configuration.rb +2 -2
- data/lib/kafo/hook_context.rb +2 -2
- data/lib/kafo/hooking.rb +9 -0
- data/lib/kafo/multi_stage_hook.rb +13 -0
- data/lib/kafo/puppet_module.rb +2 -1
- data/lib/kafo/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4298932fae581df1967c430be034c621ed435954ac95acf7cf7b23c9b7692d40
|
4
|
+
data.tar.gz: 8ce698b286d5ec94c19adfcfc23e541c8b0599cb1399e689ee00b4413668552c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 769146a010f1007993961a0075a03b1cbf9c4055a59bd8259940379662eaa36003ad5a83b746452e8dd0b35ea47640eb1a3064516a7a776d6e8030c6403321a1
|
7
|
+
data.tar.gz: dd05194e14a17c54a205b5eacc35677b78fe4f036b8ab851972a8301c59b1e327555dd065772d82476a190d878d50226ed0253afe1c5dc129496ee316555bac3
|
data/README.md
CHANGED
@@ -816,6 +816,32 @@ if app_value(:reset_foreman_db) && !app_value(:noop)
|
|
816
816
|
end
|
817
817
|
```
|
818
818
|
|
819
|
+
Hooks can additionally be defined by combining all related stages into a single file
|
820
|
+
known as a Multi-stage hook. Multi-stage hooks live in a special directory inside
|
821
|
+
the hooks directory: ```$installer_dir/hooks/multi```. Taking the previous example:
|
822
|
+
|
823
|
+
```ruby
|
824
|
+
# hooks/multi/10-reset_option_feature.rb
|
825
|
+
boot do
|
826
|
+
app_option '--reset-foreman-db', :flag, 'Drop foreman database first? You will lose all data!', :default => false
|
827
|
+
end
|
828
|
+
|
829
|
+
pre do
|
830
|
+
if app_value(:reset_foreman_db) && !app_value(:noop)
|
831
|
+
`which foreman-rake > /dev/null 2>&1`
|
832
|
+
if $?.success?
|
833
|
+
logger.info 'Dropping database!'
|
834
|
+
output = `foreman-rake db:drop 2>&1`
|
835
|
+
logger.debug output.to_s
|
836
|
+
unless $?.success?
|
837
|
+
logger.warn "Unable to drop DB, ignoring since it's not fatal, output was: '#{output}''"
|
838
|
+
end
|
839
|
+
else
|
840
|
+
logger.warn 'Foreman not installed yet, can not drop database!'
|
841
|
+
end
|
842
|
+
end
|
843
|
+
end
|
844
|
+
```
|
819
845
|
|
820
846
|
If you want to add more directories to be search you can use the "hook_dirs" option
|
821
847
|
in the installer configuration file.
|
data/lib/kafo/configuration.rb
CHANGED
@@ -130,7 +130,7 @@ module Kafo
|
|
130
130
|
def modules
|
131
131
|
@modules ||= begin
|
132
132
|
register_data_types
|
133
|
-
@data.keys.map { |mod| PuppetModule.new(mod,
|
133
|
+
@data.keys.map { |mod| PuppetModule.new(mod, configuration: self).parse }.sort
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -159,7 +159,7 @@ module Kafo
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def add_module(name)
|
162
|
-
mod = PuppetModule.new(name,
|
162
|
+
mod = PuppetModule.new(name, configuration: self).parse
|
163
163
|
unless modules.map(&:name).include?(mod.name)
|
164
164
|
mod.enable
|
165
165
|
@modules << mod
|
data/lib/kafo/hook_context.rb
CHANGED
@@ -34,8 +34,8 @@ module Kafo
|
|
34
34
|
#
|
35
35
|
# @example
|
36
36
|
# app_option ['-n', '--noop'], :flag, 'Run puppet in noop mode?', :default => false
|
37
|
-
def app_option(*args)
|
38
|
-
self.kafo.class.app_option(*args)
|
37
|
+
def app_option(*args, &block)
|
38
|
+
self.kafo.class.app_option(*args, &block)
|
39
39
|
end
|
40
40
|
|
41
41
|
# Returns whether the given app option exists. This is useful when there's a conditional option that is
|
data/lib/kafo/hooking.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'kafo/hook_context'
|
2
|
+
require 'kafo/multi_stage_hook'
|
2
3
|
|
3
4
|
module Kafo
|
4
5
|
class Hooking
|
@@ -36,6 +37,14 @@ module Kafo
|
|
36
37
|
register(hook_type, file, &hook_block)
|
37
38
|
end
|
38
39
|
end
|
40
|
+
|
41
|
+
# Multi stage hooks are special
|
42
|
+
Dir.glob(File.join(base_dir, 'multi', '*.rb')).sort.each do |file|
|
43
|
+
logger.debug "Loading multi stage hook #{file}"
|
44
|
+
hook = File.read(file)
|
45
|
+
MultiStageHook.new(file, self, TYPES).instance_eval(hook, file, 1)
|
46
|
+
end
|
47
|
+
|
39
48
|
@loaded = true
|
40
49
|
end
|
41
50
|
self
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Kafo
|
2
|
+
class MultiStageHook
|
3
|
+
def initialize(name, registry, types)
|
4
|
+
default_name = name
|
5
|
+
|
6
|
+
types.each do |hook_type|
|
7
|
+
self.class.send(:define_method, hook_type) do |name=nil, &block|
|
8
|
+
registry.send(:register, hook_type, name || default_name, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/kafo/puppet_module.rb
CHANGED
@@ -25,7 +25,7 @@ module Kafo
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def initialize(identifier, parser
|
28
|
+
def initialize(identifier, parser: nil, configuration: KafoConfigure.config)
|
29
29
|
@identifier = identifier
|
30
30
|
@configuration = configuration
|
31
31
|
@name = get_name
|
@@ -65,6 +65,7 @@ module Kafo
|
|
65
65
|
def parse(builder_klass = ParamBuilder)
|
66
66
|
@raw_data = @parser_cache.get(identifier, manifest_path) if @parser_cache
|
67
67
|
if @raw_data.nil?
|
68
|
+
@parser = self.class.find_parser if @parser.nil?
|
68
69
|
if @parser.nil? || @parser == :none
|
69
70
|
raise ParserError.new("No Puppet module parser is installed and no cache of the file #{manifest_path} is available. Please check debug logs and install optional dependencies for the parser.")
|
70
71
|
else
|
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: 6.
|
4
|
+
version: 6.4.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: 2021-
|
11
|
+
date: 2021-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -262,6 +262,7 @@ files:
|
|
262
262
|
- lib/kafo/logging.rb
|
263
263
|
- lib/kafo/migration_context.rb
|
264
264
|
- lib/kafo/migrations.rb
|
265
|
+
- lib/kafo/multi_stage_hook.rb
|
265
266
|
- lib/kafo/param.rb
|
266
267
|
- lib/kafo/param_builder.rb
|
267
268
|
- lib/kafo/param_group.rb
|
@@ -319,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
319
320
|
- !ruby/object:Gem::Version
|
320
321
|
version: '0'
|
321
322
|
requirements: []
|
322
|
-
rubygems_version: 3.1.
|
323
|
+
rubygems_version: 3.1.6
|
323
324
|
signing_key:
|
324
325
|
specification_version: 4
|
325
326
|
summary: A gem for making installations based on puppet user friendly
|