Skip to content

Commit

Permalink
Merge pull request #16578 from bzwei/fix_log_stdout
Browse files Browse the repository at this point in the history
No need to call normalized_status
  • Loading branch information
gmcculloug authored Dec 1, 2017
2 parents 10a0148 + 628f316 commit d66dbcc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/service_ansible_playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
13 changes: 13 additions & 0 deletions spec/models/service_ansible_playbook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d66dbcc

Please sign in to comment.