Skip to content

Commit

Permalink
Fixes #36130 - show correct exit code for multi-host job execution
Browse files Browse the repository at this point in the history
Override per-host exit status only if the run ends early due to an error
  • Loading branch information
nofaralfasi committed Mar 7, 2023
1 parent aea8d7b commit a9c9ab2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/smart_proxy_ansible/runner/ansible_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def close
def publish_exit_status(status)
process_artifacts
super
@targets.each_key { |host| publish_exit_status_for(host, status) } if status != 0
@targets.each_key { |host| publish_exit_status_for(host, @exit_statuses[host]) } if status != 0
end

def initialize_command(*command)
Expand Down Expand Up @@ -156,6 +156,13 @@ def handle_broadcast_data(event)
else
broadcast_data(event['stdout'] + "\n", 'stdout')
end

# If the run ends early due to an error - fail all other tasks
if event['event'] == 'error'
@outputs.keys.select { |key| key.is_a? String }.each do |host|
@exit_statuses[host] = 4 if @exit_statuses[host].to_i == 0
end
end
end

def write_inventory
Expand Down

0 comments on commit a9c9ab2

Please sign in to comment.