From 3df0490c9dbc59e27869e09864177536400a5ae3 Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Thu, 5 Aug 2010 11:09:25 -0700 Subject: [#4298] Puppet apply prints an error if the file to apply doesn't exist Also warns you it's skipping files if you pass it more than one file to apply. Reviewed-by: Nick Lewis Signed-off-by: Matt Robinson --- lib/puppet/application/apply.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/puppet/application/apply.rb') diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index bb4186dbd..152b75442 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -78,7 +78,10 @@ class Puppet::Application::Apply < Puppet::Application if options[:code] or command_line.args.length == 0 Puppet[:code] = options[:code] || STDIN.read else - Puppet[:manifest] = command_line.args.shift + manifest = command_line.args.shift + raise "Could not find file #{manifest}" unless File.exist?(manifest) + Puppet.warning("Only one file can be applied per run. Skipping #{command_line.args.join(', ')}") if command_line.args.size > 0 + Puppet[:manifest] = manifest end # Collect our facts. -- cgit From 302d657658db068c0c593545e92923659608c5a3 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sat, 21 Aug 2010 14:35:05 -0700 Subject: Fix for #4501 -- reports not generated in standalone The refactors for 2.6.x stopped "puppet apply" from saving reports; this fix adds report saving back to puppet apply but leaves a number of related issues (code path consolidation, report contents, etc.) unresolved for future patches in the 2.6.x series or more significant refactoring in 2.7.x. --- lib/puppet/application/apply.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'lib/puppet/application/apply.rb') diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 152b75442..59a95d35a 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -126,17 +126,22 @@ class Puppet::Application::Apply < Puppet::Application configurer.execute_prerun_command # And apply it + if Puppet[:report] + report = configurer.initialize_report + Puppet::Util::Log.newdestination(report) + end transaction = catalog.apply configurer.execute_postrun_command - status = 0 - if not Puppet[:noop] and options[:detailed_exitcodes] - transaction.generate_report - exit(transaction.report.exit_status) + if Puppet[:report] + Puppet::Util::Log.close(report) + configurer.send_report(report, transaction) else - exit(0) + transaction.generate_report end + + exit( Puppet[:noop] ? 0 : options[:detailed_exitcodes] ? transaction.report.exit_status : 0 ) rescue => detail puts detail.backtrace if Puppet[:trace] $stderr.puts detail.message -- cgit