kafo 0.0.12 → 0.0.13

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.

checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 541f62325d16907e10fd685ba52feef25b508de8
4
+ data.tar.gz: e28b1ff37b0e106ac9102809ba9f5ffe8844c67a
5
+ SHA512:
6
+ metadata.gz: 715a6ac0b8a5dbd3496b03e9b7898c11386ed7fbb0d64a98e1c8030e5d9bd6c6becc77bbb3e494d4e43914c5ac91272ea826e99ce8d385341fc16c830d28bba2
7
+ data.tar.gz: bbe4615a666ca4fc1e4ac3f8afabe8eddb28fe9d10890541d9816853b721f07918a2056d9dab0e530bc9937ecfe2113d9452c4dd785931529ed336fe24d1a636
data/README.md CHANGED
@@ -364,6 +364,7 @@ exit $?
364
364
  Kafo can terminate either before or after puppet is ran. Puppet is ran with
365
365
  --detailed-exitcodes and Kafo returns the same exit code as puppet does. If
366
366
  kafo terminates after puppet run exit codes are:
367
+ * '1' means there were parser/validation errors
367
368
  * '2' means there were changes,
368
369
  * '4' means there were failures during the transaction,
369
370
  * '6' means there were both changes and failures.
@@ -376,7 +377,6 @@ Other exit codes that can be returned:
376
377
  * '23' means that you have no answer file
377
378
  * '24' means that your answer file asks for puppet module that you did not provide
378
379
  * '25' means that kafo could not get default values from puppet
379
- * '26' means that you machine does not seem to have FQDN set correctly
380
380
 
381
381
 
382
382
  # License
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env ruby
2
+ require 'clamp'
3
+ require 'logging'
4
+ require 'kafo/string_helper'
5
+
6
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'kafo'))
7
+ require 'configuration'
8
+
9
+ KafoConfigure = OpenStruct.new
10
+
11
+ class KafoExportParams < Clamp::Command
12
+ TYPES = %w(md html)
13
+
14
+ option ['-c', '--config'], 'FILE', 'Config file for which should we generate params',
15
+ :required => true
16
+
17
+ option ['-f', '--format'], 'FORMAT',
18
+ 'Config file for which should we generate params', :default => 'md' do |format|
19
+ format = format.downcase
20
+ raise ArgumentError unless TYPES.include?(format)
21
+ format
22
+ end
23
+
24
+ def execute
25
+ c = Configuration.new(config, false)
26
+ KafoConfigure.config = c
27
+ KafoConfigure.root_dir = File.expand_path(c.app[:installer_dir])
28
+
29
+ exporter = self.class.const_get(format.capitalize).new(c)
30
+ exporter.print_out
31
+ end
32
+
33
+ class Html
34
+ include StringHelper
35
+
36
+ def initialize(config)
37
+ @config = config
38
+ end
39
+
40
+ def print_out
41
+ puts '<div id="installer-options">'
42
+ puts ' <table class="table table-bordered table-condensed">'
43
+ header
44
+ puts ' <tbody>'
45
+
46
+ @config.modules.each do |mod|
47
+ mod.params.each do |param|
48
+ puts ' <tr>'
49
+ puts " <td>#{parametrize(param)}</td>"
50
+ puts " <td>#{param.doc.join(' ')}</td>"
51
+ puts ' </tr>'
52
+ end
53
+ end
54
+
55
+ puts ' </tbody>'
56
+ puts ' </table>'
57
+ puts '</div>'
58
+ end
59
+
60
+ private
61
+
62
+ def header
63
+ puts ' <thead>'
64
+ puts ' <tr>'
65
+ puts ' <th>Option</th>'
66
+ puts ' <th>Description</th>'
67
+ puts ' </tr>'
68
+ puts ' </thead>'
69
+ end
70
+ end
71
+
72
+ class Md
73
+ include StringHelper
74
+
75
+ def initialize(config)
76
+ @config = config
77
+ @max = max_description_length
78
+ end
79
+
80
+ def print_out
81
+ puts "| #{('Parameter name').ljust(40)} | #{'Description'.ljust(@max)} |"
82
+ puts "| #{'-'*40} | #{'-' * @max} |"
83
+ @config.modules.each do |mod|
84
+ mod.params.each do |param|
85
+ puts "| #{parametrize(param).ljust(40)} | #{param.doc.join(' ').ljust(@max)} |"
86
+ end
87
+ end
88
+ end
89
+
90
+ private
91
+
92
+ def header
93
+ @header ||= "| #{'-'*40} | #{'-' * @max} |"
94
+ end
95
+
96
+ def max_description_length
97
+ doc_lengths = @config.modules.map { |mod| mod.params.map { |param| param.doc.join(' ').length } }.flatten
98
+ doc_lengths << 52
99
+ doc_lengths.max
100
+ end
101
+ end
102
+ end
103
+
104
+ KafoExportParams.run
@@ -5,7 +5,7 @@
5
5
  ## Installer configuration
6
6
  # Path to answer file, if the file does not exist a $pwd/config/answers.yaml is used as a fallback
7
7
  # :answer_file: /etc/kafo/kafo.yaml
8
- # Custome installer path
8
+ # Custom installer path
9
9
  # :installer_dir: /usr/share/kafo/
10
10
  # Uncomment if you want to load puppet modules from a specific path, $pwd/modules is used by default
11
11
  # :modules_dir: /usr/share/kafo/modules
@@ -19,6 +19,7 @@
19
19
 
20
20
  ## Useful for development, e.g. when you want to move log files to local directory
21
21
  # :log_dir: /var/log/kafo
22
+ # :log_name: configure.log
22
23
  # :log_level: :info
23
24
 
24
25
  # Change if you want to debug default answers for you modules, this directory holds default answers
@@ -17,8 +17,9 @@ class Configuration
17
17
  :default_values_dir => '/tmp'
18
18
  }
19
19
 
20
- def initialize(file)
20
+ def initialize(file, persist = true)
21
21
  @config_file = file
22
+ @persist = persist
22
23
  configure_application
23
24
  @logger = Logging.logger.root
24
25
 
@@ -34,6 +35,7 @@ class Configuration
34
35
  end
35
36
 
36
37
  def save_configuration(configuration)
38
+ return true unless @persist
37
39
  FileUtils.touch @config_file
38
40
  File.chmod 0600, @config_file
39
41
  File.open(@config_file, 'w') { |file| file.write(YAML.dump(configuration)) }
@@ -29,7 +29,6 @@ class KafoConfigure < Clamp::Command
29
29
  self.class.kafo_modules_dir = self.class.config.app[:kafo_modules_dir] || (self.class.gem_root + '/modules')
30
30
  Logger.setup
31
31
  @logger = Logging.logger.root
32
- check_env
33
32
  super
34
33
  set_parameters
35
34
  set_options
@@ -100,8 +99,7 @@ class KafoConfigure < Clamp::Command
100
99
  :manifest_error => 22,
101
100
  :no_answer_file => 23,
102
101
  :unknown_module => 24,
103
- :defaults_error => 25,
104
- :wrong_hostname => 26}
102
+ :defaults_error => 25}
105
103
  if error_codes.has_key? code
106
104
  return error_codes[code]
107
105
  else
@@ -232,19 +230,6 @@ class KafoConfigure < Clamp::Command
232
230
  params.select { |p| p.module.enabled? && p.value_set.nil? }
233
231
  end
234
232
 
235
- def check_env
236
- # Check that facter actually has a value that matches the hostname.
237
- # This should always be true for facter >= 1.7
238
- fqdn_exit("'facter fqdn' does not match 'hostname -f'") if Facter.fqdn != `hostname -f`.chomp
239
- # Every FQDN should have at least one dot
240
- fqdn_exit("Invalid FQDN: #{Facter.fqdn}, check your hostname") unless Facter.fqdn.include?('.')
241
- end
242
-
243
- def fqdn_exit(message)
244
- logger.error message
245
- exit(:wrong_hostname)
246
- end
247
-
248
233
  def config_file
249
234
  return CONFIG_FILE if defined?(CONFIG_FILE) && File.exists?(CONFIG_FILE)
250
235
  return '/etc/kafo/kafo.yaml' if File.exists?('/etc/kafo/kafo.yaml')
data/lib/kafo/logger.rb CHANGED
@@ -28,7 +28,7 @@ class Logger
28
28
  end
29
29
 
30
30
  logger = Logging.logger.root
31
- filename = "#{KafoConfigure.config.app[:log_dir]}/configure.log"
31
+ filename = "#{KafoConfigure.config.app[:log_dir]}/#{KafoConfigure.config.app[:log_name] || 'configure.log'}"
32
32
  begin
33
33
  logger.appenders = ::Logging.appenders.rolling_file('configure',
34
34
  :filename => filename,
data/lib/kafo/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module Kafo
3
- VERSION = "0.0.12"
3
+ VERSION = "0.0.13"
4
4
  end
@@ -2,7 +2,9 @@
2
2
  #
3
3
  module Puppet::Parser::Functions
4
4
  newfunction(:dump_values) do |args|
5
- data = Hash[args.map { |arg| [arg, lookupvar(arg)] }]
5
+ options = []
6
+ options<< false if Puppet::PUPPETVERSION.start_with?('2.6')
7
+ data = Hash[args.map { |arg| [arg, lookupvar(arg, *options)] }]
6
8
  dump_dir = YAML.load_file(lookupvar('kafo_config_file'))[:default_values_dir]
7
9
  File.open("#{dump_dir}/default_values.yaml", 'w') { |file| file.write(YAML.dump(data)) }
8
10
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kafo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
5
- prerelease:
4
+ version: 0.0.13
6
5
  platform: ruby
7
6
  authors:
8
7
  - Marek Hulan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-06 00:00:00.000000000 Z
11
+ date: 2013-09-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,23 +27,20 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: minitest
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,81 +55,71 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: puppet
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rdoc
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: 3.9.0
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: 3.9.0
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: logging
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: clamp
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: highline
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :runtime
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  description: A gem for making installations based on puppet user friendly
@@ -144,11 +127,13 @@ email:
144
127
  - ares@igloonet.cz
145
128
  executables:
146
129
  - kafo-configure
130
+ - kafo-export-params
147
131
  - kafofy
148
132
  extensions: []
149
133
  extra_rdoc_files: []
150
134
  files:
151
135
  - bin/kafo-configure
136
+ - bin/kafo-export-params
152
137
  - bin/kafofy
153
138
  - config/kafo.yaml.example
154
139
  - config/config_header.txt
@@ -199,28 +184,26 @@ files:
199
184
  homepage: https://github.com/theforeman/kafo
200
185
  licenses:
201
186
  - GPLv3+
187
+ metadata: {}
202
188
  post_install_message:
203
189
  rdoc_options: []
204
190
  require_paths:
205
191
  - lib
206
192
  required_ruby_version: !ruby/object:Gem::Requirement
207
- none: false
208
193
  requirements:
209
- - - ! '>='
194
+ - - '>='
210
195
  - !ruby/object:Gem::Version
211
196
  version: '0'
212
197
  required_rubygems_version: !ruby/object:Gem::Requirement
213
- none: false
214
198
  requirements:
215
- - - ! '>='
199
+ - - '>='
216
200
  - !ruby/object:Gem::Version
217
201
  version: '0'
218
202
  requirements: []
219
203
  rubyforge_project:
220
- rubygems_version: 1.8.23
204
+ rubygems_version: 2.0.3
221
205
  signing_key:
222
- specification_version: 3
206
+ specification_version: 4
223
207
  summary: If you write puppet modules for installing your software, you can use kafo
224
208
  to create powerful installer
225
209
  test_files: []
226
- has_rdoc: