diff --git a/app/models/service_ansible_playbook.rb b/app/models/service_ansible_playbook.rb index 8620c8fff2f..0ca6ec069f7 100644 --- a/app/models/service_ansible_playbook.rb +++ b/app/models/service_ansible_playbook.rb @@ -169,7 +169,7 @@ def log_stdout(action) log_option = options.fetch_path(:config_info, action.downcase.to_sym, :log_output) || 'on_error' return unless %(on_error always).include?(log_option) job = job(action) - return if log_option == 'on_error' && job.raw_status.normalized_status.succeeded? + return if log_option == 'on_error' && job.raw_status.succeeded? _log.info("Stdout from ansible job #{job.name}: #{job.raw_stdout('txt_download')}") rescue => err _log.error("Failed to get stdout from ansible job #{job.name}") diff --git a/spec/models/service_ansible_playbook_spec.rb b/spec/models/service_ansible_playbook_spec.rb index 8a231d72bef..c3de9bbd498 100644 --- a/spec/models/service_ansible_playbook_spec.rb +++ b/spec/models/service_ansible_playbook_spec.rb @@ -227,6 +227,19 @@ executed_service.postprocess(action) end end + + context 'require log stdout when job failed' do + before do + status = ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Job::Status.new('failed', nil) + allow(tower_job).to receive(:raw_status).and_return(status) + end + + it 'writes stdout to log' do + expect(tower_job).to receive(:raw_stdout).with('txt_download') + expect(executed_service).to receive(:delete_inventory) + executed_service.postprocess(action) + end + end end describe '#on_error' do