diff --git a/internal/common/ansible/runner.go b/internal/common/ansible/runner.go index 6b57e05b..d1207e94 100644 --- a/internal/common/ansible/runner.go +++ b/internal/common/ansible/runner.go @@ -39,6 +39,9 @@ func GetStdout(events []messageModel.PlaybookRunResponseMessageYamlEventsElem, h if event.Stdout != nil { result += *event.Stdout + if event.EndLine > event.StartLine { + result += "\n" + } } } diff --git a/internal/common/ansible/runner_test.go b/internal/common/ansible/runner_test.go index f6e974ef..3ee83c81 100644 --- a/internal/common/ansible/runner_test.go +++ b/internal/common/ansible/runner_test.go @@ -73,19 +73,19 @@ var _ = Describe("Ansible", func() { It("determines stdout from a successful run", func() { events := loadFile("./test-events1.jsonl") stdout := GetStdout(events, nil) - Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\r\nTASK [ping] ********************************************************************\x1b[0;32mok: [localhost]\x1b[0m\r\nPLAY RECAP *********************************************************************\r\n\x1b[0;32mlocalhost\x1b[0m : \x1b[0;32mok=1 \x1b[0m changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \r\n")) + Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\n\r\nTASK [ping] ********************************************************************\n\x1b[0;32mok: [localhost]\x1b[0m\n\r\nPLAY RECAP *********************************************************************\r\n\x1b[0;32mlocalhost\x1b[0m : \x1b[0;32mok=1 \x1b[0m changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 \r\n\n")) }) It("determines stdout from a failed run", func() { events := loadFile("./test-events2.jsonl") stdout := GetStdout(events, nil) - Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\r\nTASK [fail] ********************************************************************\x1b[0;31mfatal: [localhost]: FAILED! => {\"changed\": false, \"msg\": \"Always fail\"}\x1b[0m\r\nPLAY RECAP *********************************************************************\r\n\x1b[0;31mlocalhost\x1b[0m : ok=0 changed=0 unreachable=0 \x1b[0;31mfailed=1 \x1b[0m skipped=0 rescued=0 ignored=0 \r\n")) + Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\n\r\nTASK [fail] ********************************************************************\n\x1b[0;31mfatal: [localhost]: FAILED! => {\"changed\": false, \"msg\": \"Always fail\"}\x1b[0m\n\r\nPLAY RECAP *********************************************************************\r\n\x1b[0;31mlocalhost\x1b[0m : ok=0 changed=0 unreachable=0 \x1b[0;31mfailed=1 \x1b[0m skipped=0 rescued=0 ignored=0 \r\n\n")) }) It("determines stdout from an incomplete run", func() { events := loadFile("./test-events3.jsonl") stdout := GetStdout(events, nil) - Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\r\nTASK [ping] ********************************************************************")) + Expect(stdout).To(Equal("\r\nPLAY [ping] ********************************************************************\n\r\nTASK [ping] ********************************************************************\n")) }) It("determines stdout from an incomplete run (2)", func() {