lib/kafo/kafo_configure.rb in kafo-6.0.0 vs lib/kafo/kafo_configure.rb in kafo-6.1.0

- old
+ new

@@ -457,53 +457,67 @@ self.class.exit_handler.register_cleanup_path(execution_env.directory) execution_env.store_answers puppetconf = execution_env.configure_puppet( 'color' => false, - 'evaltrace' => !!@progress_bar, + 'evaltrace' => true, 'noop' => !!noop?, 'profile' => !!profile?, 'show_diff' => true, ) - exit_code = 0 + self.class.exit_handler.exit_code = 0 exit_status = nil options = [ '--verbose', '--debug', '--detailed-exitcodes', ] begin command = PuppetCommand.new('include kafo_configure', options, puppetconf).command log_parser = PuppetLogParser.new logger = Logger.new('configure') - logger.notice("Starting system configuration") + 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(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.") + end + end + @progress_bar.update(line) if @progress_bar end rescue Errno::EIO # we reach end of input exit_status = PTY.check(pid, true) if PTY.respond_to?(:check) # ruby >= 1.9.2 if exit_status.nil? # process is still running or we have old ruby so we don't know begin Process.wait(pid) rescue Errno::ECHILD # process could exit meanwhile so we rescue end - exit_code = $?.exitstatus + self.class.exit_handler.exit_code = $?.exitstatus end end end rescue PTY::ChildExited => e # could be raised by Process.wait on older ruby or by PTY.check - exit_code = e.status.exitstatus + self.class.exit_handler.exit_code = e.status.exitstatus end @progress_bar.close if @progress_bar - logger.notice "Puppet has finished, bye!" + logger.notice "System configuration has finished." self.class.hooking.execute(:post) self.class.exit(exit_code) end