lib/kafo/kafo_configure.rb in kafo-1.0.5 vs lib/kafo/kafo_configure.rb in kafo-1.0.6
- old
+ new
@@ -25,10 +25,11 @@
require 'kafo/progress_bar'
require 'kafo/hooking'
require 'kafo/exit_handler'
require 'kafo/scenario_manager'
require 'kafo/hiera_configurer'
+require 'kafo/puppet_configurer'
module Kafo
class KafoConfigure < Clamp::Command
include StringHelper
@@ -232,10 +233,16 @@
private
def setup_config(conf_file)
self.class.config_file = conf_file
self.class.config = Configuration.new(self.class.config_file)
+
+ if self.class.config.parser_cache
+ self.class.config.parser_cache.force = true if ARGV.include?('--parser-cache')
+ self.class.config.parser_cache.force = false if ARGV.include?('--no-parser-cache')
+ end
+
self.class.root_dir = self.class.config.root_dir
self.class.check_dirs = self.class.config.check_dirs
self.class.module_dirs = self.class.config.module_dirs
self.class.gem_root = self.class.config.gem_root
self.class.kafo_modules_dir = self.class.config.kafo_modules_dir
@@ -301,10 +308,11 @@
self.class.app_option ['--enable-scenario'], 'SCENARIO', 'Enable installation scenario'
self.class.app_option ['--list-scenarios'], :flag, 'List available installation scenaraios'
self.class.app_option ['--force'], :flag, 'Force change of installation scenaraio'
self.class.app_option ['--compare-scenarios'], :flag, 'Show changes between last used scenario and the scenario specified with -S or --scenario argument'
self.class.app_option ['--migrations-only'], :flag, 'Apply migrations to a selected scenario and exit'
+ self.class.app_option ['--[no-]parser-cache'], :flag, 'Force use or bypass of Puppet module parser cache'
end
def set_options
self.class.option '--full-help', :flag, "print complete help" do
@full_help = true
@@ -318,14 +326,14 @@
:default => mod.enabled?
end
params.sort.each do |param|
doc = param.doc.nil? ? 'UNDOCUMENTED' : param.doc.join("\n")
- self.class.option parametrize(param), '', doc,
- :default => param.value, :multivalued => param.multivalued?
+ self.class.option parametrize(param), '', doc + " (current: #{param.value_to_s})",
+ :multivalued => param.multivalued?
self.class.option parametrize(param, 'reset-'), :flag,
- "Reset #{param.name} to the default value"
+ "Reset #{param.name} to the default value (#{param.default_to_s})"
end
end
# ARGV can contain values for attributes e.g. ['-l', 'info']
# so we accept either allowed args or those that does not start with '-' and are right after
@@ -409,26 +417,29 @@
hiera = HieraConfigurer.new(config.app[:hiera_config], config.modules, config.app[:order])
hiera.write_configs
self.class.exit_handler.register_cleanup_path(hiera.temp_dir)
+ puppetconf = PuppetConfigurer.new(
+ 'color' => false,
+ 'evaltrace' => !!@progress_bar,
+ 'hiera_config' => hiera.config_path,
+ 'noop' => !!noop?,
+ 'profile' => !!profile?,
+ 'show_diff' => false
+ )
+ self.class.exit_handler.register_cleanup_path(puppetconf.config_path)
+
exit_code = 0
exit_status = nil
options = [
'--verbose',
'--debug',
'--trace',
- '--color=false',
- '--show_diff',
'--detailed-exitcodes',
- '--reports=',
- "--hiera_config=#{hiera.config_path}",
]
- options.push '--evaltrace' if @progress_bar
- options.push '--noop' if noop?
- options.push '--profile' if profile?
begin
- command = PuppetCommand.new('include kafo_configure', options).command
+ command = PuppetCommand.new('include kafo_configure', options, puppetconf).command
log_parser = PuppetLogParser.new
PTY.spawn(command) do |stdin, stdout, pid|
begin
stdin.each do |line|
progress_log(*log_parser.parse(line))