kafo 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of kafo might be problematic. Click here for more details.

data/README.md CHANGED
@@ -120,12 +120,24 @@ the lower the item is the higher precedence it has:
120
120
 
121
121
  # Advanced topics
122
122
 
123
- ## Testing aka noop
123
+ ## Testing aka noop etc
124
124
 
125
125
  You'll probably want to tweak your installer before so you may find --noop
126
126
  argument handy. This will run puppet in noop so no change will be done to your
127
127
  system. Default value is false!
128
128
 
129
+ Sometimes you may want kafo not to store answers from current run. You can
130
+ disable saving by passing a --dont-save-answers argument (or -d for short).
131
+
132
+ ## Parameters prefixes
133
+
134
+ You probably noticed that every module parameter is prefixed by module name
135
+ by default. If you use just one module it's probably unnecessary and you
136
+ can disable this behavior in config/kafo.yaml. Just set option like this
137
+ ```yaml
138
+ :no_prefix: true
139
+ ```
140
+
129
141
  ## Documentation
130
142
 
131
143
  Every parameter that can be set by kafo *must* be documented. This means that
@@ -182,6 +194,30 @@ bin/foreman-installer --puppetmaster-environments=development --puppetmaster-env
182
194
  In interactive mode you'll be prompted for another value until you specify
183
195
  blank line.
184
196
 
197
+ ## Custom modules and manifest names
198
+
199
+ By default Kafo expects a common module structure. For example if you add
200
+ ```yaml
201
+ foreman: true
202
+ ```
203
+ to you answer file, Kafo expects a +foreman+ subdirectory in +modules/+. Also
204
+ it expects that there will be init.pp which it will instantiate. If you need
205
+ to change this behavior you can via +mapping+ option in +config/kafo.yaml+.
206
+
207
+ Suppose we have puppet module and we want to use puppet/server.pp as our init
208
+ file. Also we want to name our module as puppetmaster. We add following mapping
209
+ to kafo.yaml
210
+
211
+ ```yaml
212
+ :mapping
213
+ :puppetmaster: # a module name, so we'll have puppetmaster: true in answer file
214
+ :dir_name: 'puppet' # the subdirectory in modules/
215
+ :manifest_name: 'server' # manifest filename without .pp extension
216
+ ```
217
+
218
+ Note that if you add mapping you must enter both dir_name and manifest_name even
219
+ if one of them is default.
220
+
185
221
  ## Validations
186
222
 
187
223
  If you specify validations of parameters in you init.pp manifest they
@@ -1,11 +1,15 @@
1
1
  # kafo main configuration file example
2
2
  # you can rename it to kafo.yaml so it overwrite default kafo settings
3
- # useful for development, e.g. when you want to move log files to local directory
3
+ # note current configuration is written tokafo.yaml every time kafo is run
4
4
 
5
+ ## Useful for development, e.g. when you want to move log files to local directory
5
6
  # :log_dir: '/var/log/kafo'
6
7
  # :log_level: :info
7
8
 
8
- # Advanced configuration - if not set it's ignored
9
+ ## Kafo tuning, customization of core functionality
10
+ # :no_prefix: false
11
+ # :mapping: {}
12
+
13
+ ## Advanced configuration - if not set it's ignored
9
14
  # :log_owner: root
10
15
  # :log_group: root
11
-
@@ -13,6 +13,8 @@ class Configuration
13
13
  KAFO = {
14
14
  :log_dir => '/var/log/kafo',
15
15
  :log_level => :info,
16
+ :no_prefix => false,
17
+ :mapping => {}
16
18
  }.merge(default_hash || {})
17
19
 
18
20
  def initialize(file)
@@ -54,7 +54,7 @@ class KafoConfigure < Clamp::Command
54
54
  end
55
55
  end
56
56
 
57
- store_params
57
+ store_params unless dont_save_answers?
58
58
  run_installation
59
59
  end
60
60
 
@@ -77,9 +77,11 @@ class KafoConfigure < Clamp::Command
77
77
  end
78
78
 
79
79
  def set_options
80
- self.class.option ['-i', '--interactive'], :flag, 'Run in interactive mode?'
81
- self.class.option ['-v', '--verbose'], :flag, 'Display log on STDOUT instead of progressbar?'
80
+ self.class.option ['-i', '--interactive'], :flag, 'Run in interactive mode'
81
+ self.class.option ['-v', '--verbose'], :flag, 'Display log on STDOUT instead of progressbar'
82
82
  self.class.option ['-n', '--noop'], :flag, 'Run puppet in noop mode?', :default => false
83
+ self.class.option ['-d', '--dont-save-answers'], :flag, 'Skip saving answers to answers.yaml?',
84
+ :default => false
83
85
 
84
86
  config.modules.each do |mod|
85
87
  self.class.option d("--[no-]enable-#{mod.name}"),
@@ -62,24 +62,19 @@ class PuppetModule
62
62
 
63
63
  private
64
64
 
65
- # customer module directory name
65
+ # mapping from configuration with stringified keys
66
+ def mapping
67
+ @mapping ||= Hash[Configuration::KAFO[:mapping].map { |k, v| [k.to_s, v] }]
68
+ end
69
+
70
+ # custom module directory name
66
71
  def get_dir_name
67
- case name
68
- when 'puppetmaster'
69
- 'puppet'
70
- else
71
- name
72
- end
72
+ mapping[name].nil? ? name : mapping[name][:dir_name]
73
73
  end
74
74
 
75
75
  # custom manifest filename without .pp extension
76
76
  def get_manifest_name
77
- case name
78
- when 'puppetmaster'
79
- 'server'
80
- else
81
- 'init'
82
- end
77
+ mapping[name].nil? ? 'init' : mapping[name][:manifest_name]
83
78
  end
84
79
 
85
80
  def get_class_name
@@ -10,7 +10,8 @@ module StringHelper
10
10
  alias :u :underscore
11
11
 
12
12
  def with_prefix(param)
13
- "#{d(param.module_name)}-#{d(param.name)}"
13
+ prefix = Configuration::KAFO[:no_prefix] ? '' : "#{d(param.module_name)}-"
14
+ "#{prefix}#{d(param.name)}"
14
15
  end
15
16
 
16
17
  def parametrize(param)
data/lib/kafo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kafo
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kafo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-26 00:00:00.000000000 Z
12
+ date: 2013-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler