kafo 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00f2eeecb2ef8b1d26ecfeda03acd948a3c946bd
4
- data.tar.gz: dbee5095cd640977d5139371b57b810729ced588
3
+ metadata.gz: 6c90ef90e7f725d167df9f4cf981149fbf73ec80
4
+ data.tar.gz: 1fe6598e413848a5e3e20959e8d40b85d4a54265
5
5
  SHA512:
6
- metadata.gz: 4ee3fa73336db84c868839389bea60ed5e4733b5bc86672e4636fc330520a4c6a6e33d499ed3a2f2871c565c99f5d83fcebc31eb1fd35bcc2542cd4767a3ad9a
7
- data.tar.gz: 6bb72c9b683c57d07f7c0cb7ec3367e08f1fb7fbf55ec5598e0a1e328fd42f20c574bf65ba53e657c33ecd1e2a462b7b754ce4b6b3477cba558afee1c6b09136
6
+ metadata.gz: ae156929be2c13cff6cb3224cc484a47b28dfdbe371415abfe60f1a9e80fa7e04f0a65d2ffa8bafe7bfd84805286adc4c462bcca05325a9f15da23dd95324c65
7
+ data.tar.gz: 694b8a569838d3f7ce01c9cbacb3233a386aa13a493ebcb6d4d4865837b321e1bcb9f3a6d0120b69e60ce8ccbb21347392633198dfaecae12276ee1de7c03458
data/README.md CHANGED
@@ -171,6 +171,8 @@ false!
171
171
  Sometimes you may want kafo not to store answers from current run. You can
172
172
  disable saving by passing a ```--dont-save-answers``` argument (or -d for short).
173
173
 
174
+ Note that running ```--noop``` implies ```--dont-save-answers```.
175
+
174
176
  ## Parameters prefixes
175
177
 
176
178
  You probably noticed that every module parameter is prefixed by module name
@@ -507,6 +509,10 @@ bin/foreman-installer --foreman-db-password=UNDEF
507
509
 
508
510
  It also works in interactive mode.
509
511
 
512
+ You may also need to override array parameter with empty array value. For this
513
+ purpose you can use `EMPTY_ARRAY` string as a value. Similarly you can use
514
+ `EMPTY_HASH` for hash parameters.
515
+
510
516
  ## Hooks
511
517
 
512
518
  You may need to add new features to the installer. Kafo provides simple hook
@@ -690,6 +696,25 @@ order:
690
696
  If you have other modules in your answer file they will be executed after
691
697
  those that have explicit order. Their order is not be specified.
692
698
 
699
+ ## Changing the order of module appearance in interactive mode
700
+
701
+ We sort our module alphabetically. Sometimes you may want to reorder
702
+ module, e.g. display plugin modules last. For this you can use ```low_priority_modules```
703
+ configuration option. It accepts an array of patterns considering the
704
+ first to have the lowest priority. So in follwing example
705
+
706
+ ```yaml
707
+ low_priority_modules:
708
+ - compute
709
+ - plugin
710
+ ```
711
+
712
+ all modules containing a word compute in their name would be listed
713
+ at the end. If there are two modules containing compute, their order
714
+ is alphabetical on suffix after compute word. If there are some modules
715
+ containing word plugin, they will be above compute modules as they
716
+ were mentioned later.
717
+
693
718
  ## Changing of log directory and user/group
694
719
 
695
720
  By default kafo logs every run to a separate file in /var/log/kafo.
@@ -710,8 +735,9 @@ but you want the logs to be readable by specific users.
710
735
 
711
736
  When you want to make sure that user has some software installed or has the
712
737
  right version you can write a simple script and put it into checks directory.
713
- All files found there will be ran and if any has non-zero exit code, kafo
714
- wont execute puppet.
738
+ All files found there will be executed and if any of these exits with an non-zero
739
+ exit code, kafo won't execute puppet but print an error message
740
+ `Your system does not meet configuration criteria.`
715
741
 
716
742
  Everything on STDOUT and STDERR is logged in error level.
717
743
 
@@ -723,6 +749,11 @@ java -version 2>&1 | grep OpenJDK
723
749
  exit $?
724
750
  ```
725
751
 
752
+ If you want to ignore results of check scripts, you can use the builtin
753
+ parameter `--skip-checks-i-know-better` (or `-s`). This will completely
754
+ disable running all system check scripts. Note that this option is
755
+ not persisted between runs.
756
+
726
757
  ## Exit code
727
758
 
728
759
  Kafo can terminate either before or after puppet is ran. Puppet is ran with
@@ -741,7 +772,7 @@ Other exit codes that can be returned:
741
772
  * '23' means that you have no answer file
742
773
  * '24' means that your answer file asks for puppet module that you did not provide
743
774
  * '25' means that kafo could not get default values from puppet
744
-
775
+ * '130' user interrupt (^C)
745
776
 
746
777
  # License
747
778
 
@@ -22,6 +22,7 @@
22
22
  # :no_prefix: false
23
23
  # :mapping: {}
24
24
  # :order:
25
+ # :low_priority_modules:
25
26
 
26
27
  ## Useful for development, e.g. when you want to move log files to local directory
27
28
  # :log_dir: /var/log/kafo
@@ -13,19 +13,20 @@ module Kafo
13
13
  end
14
14
 
15
15
  DEFAULT = {
16
- :log_dir => '/var/log/kafo',
17
- :log_name => 'configuration.log',
18
- :log_level => 'info',
19
- :no_prefix => false,
20
- :mapping => {},
21
- :answer_file => './config/answers.yaml',
22
- :installer_dir => '.',
23
- :modules_dir => './modules',
24
- :default_values_dir => '/tmp',
25
- :colors => Configuration.colors_possible?,
26
- :color_of_background => :dark,
27
- :hook_dirs => [],
28
- :custom => {}
16
+ :log_dir => '/var/log/kafo',
17
+ :log_name => 'configuration.log',
18
+ :log_level => 'info',
19
+ :no_prefix => false,
20
+ :mapping => {},
21
+ :answer_file => './config/answers.yaml',
22
+ :installer_dir => '.',
23
+ :modules_dir => './modules',
24
+ :default_values_dir => '/tmp',
25
+ :colors => Configuration.colors_possible?,
26
+ :color_of_background => :dark,
27
+ :hook_dirs => [],
28
+ :custom => {},
29
+ :low_priority_modules => [],
29
30
  }
30
31
 
31
32
  def initialize(file, persist = true)
@@ -81,7 +82,7 @@ module Kafo
81
82
  end
82
83
 
83
84
  def modules
84
- @modules ||= @data.keys.map { |mod| PuppetModule.new(mod).parse }
85
+ @modules ||= @data.keys.map { |mod| PuppetModule.new(mod).parse }.sort
85
86
  end
86
87
 
87
88
  def add_module(name)
@@ -102,13 +103,16 @@ module Kafo
102
103
  @logger.debug "Creating tmp dir within #{app[:default_values_dir]}..."
103
104
  temp_dir = Dir.mktmpdir(nil, app[:default_values_dir])
104
105
  KafoConfigure.exit_handler.register_cleanup_path temp_dir
105
- @logger.info "Parsing default values from puppet modules..."
106
+ @logger.info 'Loading default values from puppet modules...'
106
107
  command = PuppetCommand.new("$temp_dir=\"#{temp_dir}\" #{includes} dump_values(#{params})").append('2>&1').command
107
- @logger.debug `#{command}`
108
+ result = `#{command}`
109
+ @logger.debug result
108
110
  unless $?.exitstatus == 0
109
111
  log = app[:log_dir] + '/' + app[:log_name]
110
112
  puts "Could not get default values, check log file at #{log} for more information"
111
- @logger.error "Could not get default values, cannot continue"
113
+ @logger.error command
114
+ @logger.error result
115
+ @logger.error 'Could not get default values, cannot continue'
112
116
  KafoConfigure.exit(:defaults_error)
113
117
  end
114
118
  @logger.info "... finished"
@@ -84,9 +84,11 @@ module Kafo
84
84
  @progress_bar = self.class.config.app[:colors] ? ProgressBars::Colored.new : ProgressBars::BlackWhite.new
85
85
  end
86
86
 
87
- unless SystemChecker.check
88
- puts "Your system does not meet configuration criteria"
89
- self.class.exit(:invalid_system)
87
+ unless skip_checks_i_know_better?
88
+ unless SystemChecker.check
89
+ puts "Your system does not meet configuration criteria"
90
+ self.class.exit(:invalid_system)
91
+ end
90
92
  end
91
93
 
92
94
  self.class.hooking.execute(:pre_validations)
@@ -100,7 +102,7 @@ module Kafo
100
102
  end
101
103
  end
102
104
 
103
- if dont_save_answers?
105
+ if dont_save_answers? || noop?
104
106
  self.class.temp_config_file = temp_config_file
105
107
  store_params(temp_config_file)
106
108
  else
@@ -207,6 +209,7 @@ module Kafo
207
209
  :default => config.app[:log_level]
208
210
  self.class.app_option ['-n', '--noop'], :flag, 'Run puppet in noop mode?',
209
211
  :default => false
212
+ self.class.app_option ['-s', '--skip-checks-i-know-better'], :flag, 'Skip all system checks', :default => false
210
213
  self.class.app_option ['-v', '--verbose'], :flag, 'Display log on STDOUT instead of progressbar'
211
214
  self.class.app_option ['-l', '--verbose-log-level'], 'LEVEL', 'Log level for verbose mode output',
212
215
  :default => 'info'
@@ -3,7 +3,11 @@ module Kafo
3
3
  class Array < Param
4
4
  def value=(value)
5
5
  super
6
- @value = typecast(@value)
6
+ if @value == ['EMPTY_ARRAY']
7
+ @value = []
8
+ else
9
+ @value = typecast(@value)
10
+ end
7
11
  end
8
12
 
9
13
  def multivalued?
@@ -3,7 +3,11 @@ module Kafo
3
3
  class Hash < Param
4
4
  def value=(value)
5
5
  super
6
- @value = typecast(@value)
6
+ if @value == ['EMPTY_HASH']
7
+ @value = {}
8
+ else
9
+ @value = typecast(@value)
10
+ end
7
11
  end
8
12
 
9
13
  def multivalued?
@@ -78,6 +78,14 @@ module Kafo
78
78
  end
79
79
 
80
80
  def <=> o
81
+ KafoConfigure.config.app[:low_priority_modules].each do |module_name|
82
+ return 1 if self.name.include?(module_name) && !o.name.include?(module_name)
83
+ return -1 if !self.name.include?(module_name) && o.name.include?(module_name)
84
+ if self.name.include?(module_name) && o.name.include?(module_name)
85
+ return self.name.sub(/.*#{module_name}/, '') <=> o.name.sub(/.*#{module_name}/, '')
86
+ end
87
+ end
88
+
81
89
  self.name <=> o.name
82
90
  end
83
91
 
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module Kafo
3
- VERSION = "0.6.5"
3
+ VERSION = "0.6.6"
4
4
  end
@@ -34,7 +34,7 @@ END
34
34
  main_menu
35
35
  rescue Interrupt
36
36
  puts "Got interrupt, exiting"
37
- KafoConfigure.exit(0)
37
+ KafoConfigure.exit(130)
38
38
  end
39
39
 
40
40
  private
@@ -84,7 +84,7 @@ END
84
84
  if mod.enabled?
85
85
  render_params(mod.primary_parameter_group.params, menu)
86
86
 
87
- others = mod.primary_parameter_group.children + mod.other_parameter_groups
87
+ others = (mod.primary_parameter_group.children + mod.other_parameter_groups).uniq
88
88
  others.each do |group|
89
89
  menu.choice("Configure #{group.formatted_name}") { configure_group(group) }
90
90
  end
@@ -40,7 +40,7 @@ module Puppet::Parser::Functions
40
40
  alias_method :report, :report_with_wrapper
41
41
  end
42
42
  else
43
- ::Puppet.err 'Your puppet version does not support progress bar'
43
+ ::Puppet.warning 'Your puppet version does not support progress bar'
44
44
  end
45
45
  end
46
46
  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: 0.6.5
4
+ version: 0.6.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: 2014-09-09 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,6 +143,9 @@ dependencies:
143
143
  - - '>='
144
144
  - !ruby/object:Gem::Version
145
145
  version: 1.6.21
146
+ - - <
147
+ - !ruby/object:Gem::Version
148
+ version: '1.7'
146
149
  type: :runtime
147
150
  prerelease: false
148
151
  version_requirements: !ruby/object:Gem::Requirement
@@ -150,6 +153,9 @@ dependencies:
150
153
  - - '>='
151
154
  - !ruby/object:Gem::Version
152
155
  version: 1.6.21
156
+ - - <
157
+ - !ruby/object:Gem::Version
158
+ version: '1.7'
153
159
  - !ruby/object:Gem::Dependency
154
160
  name: powerbar
155
161
  requirement: !ruby/object:Gem::Requirement