lib/kafo/configuration.rb in kafo-1.0.5 vs lib/kafo/configuration.rb in kafo-1.0.6
- old
+ new
@@ -3,10 +3,11 @@
require 'tmpdir'
require 'kafo/puppet_module'
require 'kafo/password_manager'
require 'kafo/color_scheme'
require 'kafo/data_type_parser'
+require 'kafo/puppet_configurer'
module Kafo
class Configuration
attr_reader :config_file, :answer_file
@@ -145,12 +146,16 @@
def params_default_values
@params_default_values ||= begin
@logger.debug "Creating tmp dir within #{app[:default_values_dir]}..."
temp_dir = Dir.mktmpdir(nil, app[:default_values_dir])
KafoConfigure.exit_handler.register_cleanup_path temp_dir
+
+ puppetconf = PuppetConfigurer.new('noop' => true)
+ KafoConfigure.exit_handler.register_cleanup_path puppetconf.config_path
+
@logger.info 'Loading default values from puppet modules...'
- command = PuppetCommand.new("$temp_dir=\"#{temp_dir}\" #{includes} dump_values(#{params_to_dump})", ['--noop', '--reports='], self).append('2>&1').command
+ command = PuppetCommand.new("$temp_dir=\"#{temp_dir}\" #{includes} dump_values(#{params_to_dump})", [], puppetconf, self).append('2>&1').command
result = `#{command}`
@logger.debug result
unless $?.exitstatus == 0
log = app[:log_dir] + '/' + app[:log_name]
puts "Could not get default values, check log file at #{log} for more information"
@@ -199,11 +204,11 @@
end
def preset_defaults_from_puppet
# set values based on default_values
params.each do |param|
- param.set_default(params_default_values)
+ param.set_default_from_dump(params_default_values)
end
end
def preset_defaults_from_yaml
# set values based on YAML
@@ -294,11 +299,10 @@
module_dir ? "include #{mod.dir_name}::#{mod.params_class_name}" : nil
end.uniq.compact.join(' ')
end
def params_to_dump
- parameters = params.select { |p| p.default != 'UNSET' }
- parameters.map { |param| "#{param.dump_default}" }.join(',')
+ params.select(&:dump_default_needed?).map(&:dump_default).join(',')
end
def format(data)
data.gsub('!ruby/sym ', ':')
end