From 30ee6b652f468e59615778b50cdd245cfef6dc66 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 21 Nov 2024 14:16:09 +0100 Subject: [PATCH] (#732) run.rb: Combine stderr and stdout By default, `Puppet::Util::Execution.execute` only returns stdout. Puppet writes errors to stderr. When the run task fails, it only shows the successful output: ``` $ bolt task run puppet_agent::run --targets puppet Started on puppet... Finished on puppet: Info: Using environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Notice: Requesting catalog from puppet.local:8140 (10.0.1.1) Notice: Catalog compiled by puppet.local *long json here* ``` With the patch: ``` $ bolt task run puppet_agent::run --targets puppet Started on puppet... Finished on puppet: Info: Using environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Notice: Requesting catalog from puppet.local:8140 (10.0.1.1) Notice: Catalog compiled by puppet.spirit-int.betadots.training Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Failed to execute '/pdb/query/v4' on at least 1 of the following 'server_urls': https://puppetdb:8081 (file: /opt/puppetlabs/puppet/modules/infrastructure/manifests/puppet/puppetserver.pp, line: 11, column: 14) on node puppet.local Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run *long json here* `` --- tasks/run.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/run.rb b/tasks/run.rb index bdf429cf..60775b9d 100755 --- a/tasks/run.rb +++ b/tasks/run.rb @@ -155,7 +155,8 @@ def try_run(last_run_report, params) options = { failonfail: false, custom_environment: get_env_fix_up, - override_locale: false + override_locale: false, + combine: true # combine stdout and stderr } run_result = Puppet::Util::Execution.execute(command.reject(&:empty?), options)