From 4c7774bfefe6b4972dfd23008243862073ab5c22 Mon Sep 17 00:00:00 2001 From: nofaralfasi Date: Mon, 13 Mar 2023 13:44:20 +0200 Subject: [PATCH] Refs #36130 - Update code for compatibility with Ansible 2.12.2 Set the exit status to success only for rescued tasks. --- lib/smart_proxy_ansible/runner/ansible_runner.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/smart_proxy_ansible/runner/ansible_runner.rb b/lib/smart_proxy_ansible/runner/ansible_runner.rb index f0a3af0..d39feb6 100644 --- a/lib/smart_proxy_ansible/runner/ansible_runner.rb +++ b/lib/smart_proxy_ansible/runner/ansible_runner.rb @@ -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