kafo 0.0.10 → 0.0.11

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
@@ -372,6 +372,7 @@ Other exit codes that can be returned:
372
372
  * '23' means that you have no answer file
373
373
  * '24' means that your answer file asks for puppet module that you did not provide
374
374
  * '25' means that kafo could not get default values from puppet
375
+ * '26' means that you machine does not seem to have FQDN set correctly
375
376
 
376
377
 
377
378
  # License
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
+ require 'rake/testtask'
1
2
  require "bundler/gem_tasks"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'lib' << 'test'
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ t.verbose = true
8
+ end
9
+
data/bin/kafofy CHANGED
File without changes
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ require 'facter'
2
3
  require 'pty'
3
4
  require 'clamp'
4
5
  require 'kafo/exceptions'
@@ -14,17 +15,19 @@ class KafoConfigure < Clamp::Command
14
15
  attr_reader :logger
15
16
 
16
17
  class << self
17
- attr_accessor :config, :root_dir, :config_file, :gem_root, :temp_config_file
18
+ attr_accessor :config, :root_dir, :config_file, :gem_root, :temp_config_file, :modules_dir
18
19
  end
19
20
 
20
21
  def initialize(*args)
21
22
  self.class.config_file = config_file
22
23
  self.class.config = Configuration.new(self.class.config_file)
23
24
  self.class.root_dir = File.expand_path(self.class.config.app[:installer_dir])
25
+ modules_dir = self.class.config.app[:module_dir] || (self.class.config.app[:installer_dir] + '/modules')
26
+ self.class.modules_dir = File.expand_path(modules_dir)
24
27
  self.class.gem_root = File.join(File.dirname(__FILE__), '../../')
25
28
  Logger.setup
26
29
  @logger = Logging.logger.root
27
- set_env
30
+ check_env
28
31
  super
29
32
  set_parameters
30
33
  set_options
@@ -95,7 +98,8 @@ class KafoConfigure < Clamp::Command
95
98
  :manifest_error => 22,
96
99
  :no_answer_file => 23,
97
100
  :unknown_module => 24,
98
- :defaults_error => 25 }
101
+ :defaults_error => 25,
102
+ :wrong_hostname => 26}
99
103
  if error_codes.has_key? code
100
104
  return error_codes[code]
101
105
  else
@@ -208,11 +212,9 @@ class KafoConfigure < Clamp::Command
208
212
 
209
213
  def puppet_log(line)
210
214
  method, message = case
211
- when line =~ /^Error:(.*)/i
215
+ when line =~ /^Error:(.*)/i || line =~ /^Err:(.*)/i
212
216
  [:error, $1]
213
- when line =~ /^Warning:(.*)/i
214
- [:warn, $1]
215
- when line =~ /^Notice:(.*)/i
217
+ when line =~ /^Warning:(.*)/i || line =~ /^Notice:(.*)/i
216
218
  [:warn, $1]
217
219
  when line =~ /^Info:(.*)/i
218
220
  [:info, $1]
@@ -228,10 +230,17 @@ class KafoConfigure < Clamp::Command
228
230
  params.select { |p| p.module.enabled? && p.value_set.nil? }
229
231
  end
230
232
 
231
- def set_env
232
- # Puppet tries to determine FQDN from /etc/resolv.conf and we do NOT want this behavior
233
- facter_hostname = Socket.gethostname
234
- ENV['FACTER_fqdn'] = facter_hostname
233
+ def check_env
234
+ # Check that facter actually has a value that matches the hostname.
235
+ # This should always be true for facter >= 1.7
236
+ fqdn_exit("'facter fqdn' does not match 'hostname -f'") if Facter.fqdn != `hostname -f`.chomp
237
+ # Every FQDN should have at least one dot
238
+ fqdn_exit("Invalid FQDN: #{Facter.fqdn}, check your hostname") unless Facter.fqdn.include?('.')
239
+ end
240
+
241
+ def fqdn_exit(message)
242
+ logger.error message
243
+ exit(:wrong_hostname)
235
244
  end
236
245
 
237
246
  def config_file
@@ -7,15 +7,14 @@ module Params
7
7
  class Password < Param
8
8
  def value=(value)
9
9
  super
10
+ if @value.nil? || @value.empty?
11
+ @value = password_manager.password
12
+ end
10
13
  setup_password if @value.is_a?(::String)
11
14
  @value
12
15
  end
13
16
 
14
- # if value was not specified and default is nil we generate a random password
15
- # also we make sure that we have encrypted version that is to be outputted
16
17
  def value
17
- @value = @value_set ? @value : (default || password_manager.password)
18
- encrypt if @value.is_a?(::String)
19
18
  @encrypted
20
19
  end
21
20
 
@@ -30,10 +30,8 @@ class PuppetCommand
30
30
  private
31
31
 
32
32
  def modules_path
33
- installer_modules = KafoConfigure.config.app[:modules_dir] ||
34
- (KafoConfigure.config.app[:installer_dir] + '/modules')
35
33
  [
36
- installer_modules,
34
+ KafoConfigure.config.app[:modules_dir],
37
35
  File.join(KafoConfigure.gem_root, 'modules')
38
36
  ].join(':')
39
37
  end
@@ -1,6 +1,9 @@
1
1
  # encoding: UTF-8
2
2
  require 'puppet'
3
3
  require 'rdoc'
4
+ require 'rdoc/markup' # required for RDoc < 0.9.5
5
+ require 'rdoc/markup/parser' # required for RDoc < 0.9.5
6
+
4
7
  # Based on ideas from puppet-parse by Johan van den Dorpe
5
8
  class PuppetModuleParser
6
9
  def self.parse(file)
@@ -49,7 +52,11 @@ class PuppetModuleParser
49
52
  def docs
50
53
  docs = {}
51
54
  if !@object.doc.nil?
52
- rdoc = RDoc::Markup.parse(@object.doc)
55
+ if RDoc::Markup.respond_to?(:parse)
56
+ rdoc = RDoc::Markup.parse(@object.doc)
57
+ else # RDoc < 3.10.0
58
+ rdoc = RDoc::Markup::Parser.parse(@object.doc)
59
+ end
53
60
  items = rdoc.parts.select { |part| part.respond_to?(:items) }.map(&:items).flatten
54
61
  items.each do |item|
55
62
  # Skip rdoc items that aren't paragraphs
@@ -2,7 +2,7 @@
2
2
  class Validator
3
3
 
4
4
  def initialize(params)
5
- files = KafoConfigure.root_dir + '/modules/stdlib/lib/puppet/parser/functions/validate_*.rb'
5
+ files = KafoConfigure.modules_dir + '/*/lib/puppet/parser/functions/validate_*.rb'
6
6
  Dir.glob(files).each do |file|
7
7
  require file
8
8
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module Kafo
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
@@ -1,5 +1,10 @@
1
1
  # Loads a kafo master password from kafo.yaml
2
2
  #
3
+
4
+ # Loading the decrypt function explicitly so that is always available in templates
5
+ # when calling scope.function_decrypt([@password])
6
+ require File.expand_path('../decrypt', __FILE__)
7
+
3
8
  module Puppet::Parser::Functions
4
9
  newfunction(:load_kafo_password, :type => :rvalue) do |args|
5
10
  YAML.load_file(lookupvar('kafo_config_file'))[:password]
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.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: minitest
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 4.7.5
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 4.7.5
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: puppet
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -64,17 +80,17 @@ dependencies:
64
80
  requirement: !ruby/object:Gem::Requirement
65
81
  none: false
66
82
  requirements:
67
- - - ~>
83
+ - - ! '>='
68
84
  - !ruby/object:Gem::Version
69
- version: '3.0'
85
+ version: 3.9.0
70
86
  type: :runtime
71
87
  prerelease: false
72
88
  version_requirements: !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
- - - ~>
91
+ - - ! '>='
76
92
  - !ruby/object:Gem::Version
77
- version: '3.0'
93
+ version: 3.9.0
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: logging
80
96
  requirement: !ruby/object:Gem::Requirement