Skip to content

Commit 97dcbee

Browse files
authored
Merge pull request #742 from bastelfreak/combine2
(#732) puppet_agent::run: mark failed puppet runs as failed task
2 parents 7a5bedd + 71b9253 commit 97dcbee

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tasks/run.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,16 @@ def get_result_from_report(last_run_report, run_result, start_time)
9999
obj.tag = nil if obj.respond_to?(:tag=)
100100
end
101101

102+
ruby_report = report.to_ruby
103+
# check if the run is marked as failed
104+
if ruby_report['status'] == 'failed'
105+
return error_result(
106+
'puppet_agent/agent-run-error',
107+
"Puppet agent run failed: #{run_result}",
108+
)
109+
end
102110
{
103-
'report' => report.to_ruby,
111+
'report' => ruby_report,
104112
'exitcode' => run_result.exitstatus,
105113
'_output' => run_result
106114
}
@@ -155,7 +163,8 @@ def try_run(last_run_report, params)
155163
options = {
156164
failonfail: false,
157165
custom_environment: get_env_fix_up,
158-
override_locale: false
166+
override_locale: false,
167+
combine: true # combine stdout and stderr
159168
}
160169

161170
run_result = Puppet::Util::Execution.execute(command.reject(&:empty?), options)

0 commit comments

Comments
 (0)