Skip to content

Commit

Permalink
Refs #36130 - Update code for compatibility with Ansible 2.12.2
Browse files Browse the repository at this point in the history
Set the exit status to success only for rescued tasks.
  • Loading branch information
nofaralfasi committed Mar 21, 2023
1 parent 6800675 commit 4c7774b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/smart_proxy_ansible/runner/ansible_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ def handle_broadcast_data(event)
if event['event'] == 'playbook_on_stats'
failures = event.dig('event_data', 'failures') || {}
unreachable = event.dig('event_data', 'dark') || {}
rescued = event.dig('event_data', 'rescued') || {}
header, *rows = event['stdout'].strip.lines.map(&:chomp)
@outputs.keys.select { |key| key.is_a? String }.each do |host|
line = rows.find { |row| row =~ /#{host}/ }
publish_data_for(host, [header, line].join("\n"), 'stdout')

# If the task has been rescued, it won't consider a failure
if @exit_statuses[host].to_i != 0 && failures[host].to_i <= 0 && unreachable[host].to_i <= 0
if @exit_statuses[host].to_i != 0 && failures[host].to_i <= 0 && unreachable[host].to_i <= 0 && rescued[host].to_i > 0
publish_exit_status_for(host, 0)
end
end
Expand Down

0 comments on commit 4c7774b

Please sign in to comment.