lib/kafo/kafo_configure.rb in kafo-6.2.1 vs lib/kafo/kafo_configure.rb in kafo-6.3.0
- old
+ new
@@ -141,11 +141,18 @@
set_app_options # define args for installer
# we need to parse app config params using clamp even before run method does it
# so we limit parsing only to app config options (because of --help and later defined params)
parse clamp_app_arguments
parse_app_arguments # set values from ARGS to config.app
- Logging.setup(verbose: config.app[:verbose]) unless ARGV.any? { |option| ['--help', '--full-help'].include? option }
+
+ if ARGV.any? { |option| ['--help', '--full-help'].include? option }
+ Logging.setup_verbose(level: :error)
+ else
+ Logging.setup(verbose: config.app[:verbose])
+ end
+
+ logger.notice("Loading installer configuration. This will take some time.")
self.class.set_color_scheme
self.class.hooking.execute(:init)
set_parameters # here the params gets parsed and we need app config populated
set_options
@@ -164,10 +171,14 @@
end
def run(*args)
started_at = Time.now
logger.debug("Running installer with args #{args.inspect}")
+ if config.app[:verbose]
+ logger.notice("Running installer with log based terminal output at level #{config.app[:verbose_log_level].upcase}.")
+ logger.notice("Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.")
+ end
super
ensure
logger.debug("Installer finished in #{Time.now - started_at} seconds")
end
@@ -309,10 +320,29 @@
def app_option(*args, &block)
self.class.app_option(*args, &block)
end
+ def terminal_log_levels_message
+ if ARGV.include?('--full-help')
+ <<~HEREDOC.chomp
+ Log level for log based terminal output.
+ The available levels are
+ ERROR - Only show errors which prevented the installer from completing successfully.
+ WARN - Deprecation warnings and other information users may want to be aware of.
+ NOTICE - High level information about installer execution and progress.
+ INFO - More detailed information about execution and progress. Also shows when the installer makes a change to system configuration.
+ DEBUG - Show all information about execution, including configuration items where no change was needed.
+ HEREDOC
+ else
+ <<~HEREDOC.chomp
+ Log level for log based terminal output.
+ The available levels are ERROR, WARN, NOTICE, INFO, DEBUG. See --full-help for definitions.
+ HEREDOC
+ end
+ end
+
def set_app_options
app_option ['--[no-]colors'], :flag, 'Use color output on STDOUT',
:default => config.app[:colors], :advanced => true
app_option ['--color-of-background'], 'COLOR', 'Your terminal background is :bright or :dark',
:default => config.app[:color_of_background], :advanced => true
@@ -331,11 +361,11 @@
:default => false
app_option ['--skip-puppet-version-check'], :flag, 'Skip check for compatible Puppet versions',
:default => false, :advanced => true
app_option ['-v', '--[no-]verbose'], :flag, 'Display log on STDOUT instead of progressbar',
:default => config.app[:verbose]
- app_option ['-l', '--verbose-log-level'], 'LEVEL', 'Log level for verbose mode output',
+ app_option ['-l', '--verbose-log-level'], 'LEVEL', terminal_log_levels_message,
:default => 'notice'
app_option ['-S', '--scenario'], 'SCENARIO', 'Use installation scenario'
app_option ['--disable-scenario'], 'SCENARIO', 'Disable installation scenario',
:advanced => true
app_option ['--enable-scenario'], 'SCENARIO', 'Enable installation scenario',
@@ -438,11 +468,11 @@
data = Hash[config.modules.map { |mod| [mod.identifier, mod.enabled? ? mod.params_hash : false] }]
config.store(data, file)
end
def validate_all(logging = true)
- logger.notice 'Running validation checks'
+ logger.info "Running validation checks."
results = enabled_params.map do |param|
result = param.valid?
errors = param.validation_errors.join(', ')
progress_log(:error, "Parameter #{with_prefix(param)} invalid: #{errors}", logger) if logging && !result
result
@@ -475,27 +505,21 @@
begin
command = PuppetCommand.new('include kafo_configure', options, puppetconf).command
log_parser = PuppetLogParser.new
logger = Logger.new('configure')
- start_message = <<-HEREDOC
-Starting system configuration.
- The total number of configuration tasks may increase during the run.
- Observe logs or specify --verbose-log-level to see individual configuration tasks.
-HEREDOC
+ logger.notice("Starting system configuration.")
- logger.notice(start_message.chomp)
-
PTY.spawn(*PuppetCommand.format_command(command)) do |stdin, stdout, pid|
begin
stdin.each do |line|
line = normalize_encoding(line)
method, message = log_parser.parse(line)
progress_log(method, message, logger)
- if (output = line.match(%r{(.+\]): Starting to evaluate the resource( \((?<count>\d+) of (?<total>\d+)\))?}))
- if (output[:count].to_i % 100) == 1 && output[:count].to_i != 1
- logger.notice("#{output[:count].to_i - 1} out of #{output[:total]} done.")
+ if (output = line.match(/(.+\]): Starting to evaluate the resource( \((?<count>\d+) of (?<total>\d+)\))?/))
+ if (output[:count].to_i % 250) == 1 && output[:count].to_i != 1
+ logger.notice("#{output[:count].to_i - 1} configuration steps out of #{output[:total]} steps complete.")
end
end
@progress_bar.update(line) if @progress_bar
end