lib/kafo/configuration.rb in kafo-0.3.16 vs lib/kafo/configuration.rb in kafo-0.3.17
- old
+ new
@@ -1,7 +1,8 @@
# encoding: UTF-8
require 'yaml'
+require 'tmpdir'
require 'kafo/puppet_module'
require 'kafo/password_manager'
module Kafo
class Configuration
@@ -72,20 +73,23 @@
@modules ||= @data.keys.map { |mod| PuppetModule.new(mod).parse }
end
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.register_cleanup_path temp_dir
@logger.info "Parsing default values from puppet modules..."
- command = PuppetCommand.new("#{includes} dump_values(#{params})").append('2>&1').command
+ command = PuppetCommand.new("$temp_dir=\"#{temp_dir}\" #{includes} dump_values(#{params})").append('2>&1').command
@logger.debug `#{command}`
unless $?.exitstatus == 0
log = app[:log_dir] + '/' + app[:log_name]
puts "Could not get default values, check log file at #{log} for more information"
@logger.error "Could not get default values, cannot continue"
KafoConfigure.exit(:defaults_error)
end
@logger.info "... finished"
- YAML.load_file(File.join(KafoConfigure.config.app[:default_values_dir], 'default_values.yaml'))
+ YAML.load_file(File.join(temp_dir, 'default_values.yaml'))
end
end
# if a value is a true we return empty hash because we have no specific options for a
# particular puppet module