Skip to content

Commit 71b9253

Browse files
committed
(#732) puppet_agent::run: mark failed puppet runs as failed task
without this change: ``` Started on localhost... Finished on localhost: Info: Refreshing CA certificate Info: CA certificate is unmodified, using existing CA certificate Info: Using environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Notice: Requesting catalog from puppet.bastel:8140 (127.0.0.1) Notice: Catalog compiled by puppet.local Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Failed when searching for node puppet.bastel: Exception while executing '/etc/puppetlabs/puppet/node.rb': Cannot run program "/etc/puppetlabs/puppet/node.rb" (in directory "."): error=0, Failed to exec spawn helper: pid: 2133925, exit value: 1 Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run { *long json* }, "exitcode": 1 } Successful on 1 target: localhost Ran on 1 target in 11.19 sec ``` With this change: ``` Started on localhost... Failed on localhost: Puppet agent run failed: Info: Refreshing CA certificate Info: CA certificate is unmodified, using existing CA certificate Info: Using environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Notice: Requesting catalog from puppet.bastel:8140 (127.0.0.1) Notice: Catalog compiled by puppet.local Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Failed when searching for node puppet.bastel: Exception while executing '/etc/puppetlabs/puppet/node.rb': Cannot run program "/etc/puppetlabs/puppet/node.rb" (in directory "."): error=0, Failed to exec spawn helper: pid: 2133837, exit value: 1 Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run Failed on 1 target: localhost Ran on 1 target in 11.35 sec ``` The task is now properly marked as failed, when the puppet agent run failed itself.
1 parent b233bcd commit 71b9253

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tasks/run.rb

Lines changed: 9 additions & 1 deletion
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
}

0 commit comments

Comments
 (0)