Append shell script output on remote server

In Ansible is there any way i can append the shell script out to in one file.
basically I have script which does some validation like services status up after the OS upgrade.
I want to execute the script on remote machine & append the output in remote system somewhere under “/tmp/file”.

Yes, the easiest way would be to just direct it in the shell command.

`
shell: ./myBinary > /tmp/file

`

Or if you want Ansible to still see the stdout, do:

`
shell: ./myBinary | tee /tmp/file

`

This only deals with stdout. Let me know if you want to capture stderr too. (There are equivilent ways of capturing both.)

The alternative is registering the output and saving the content in the next step.

`

  • shell: ./myBinary
    register: shellTask

  • copy:
    content: shellTask.stdout
    path: /tmp/file

`

Regards,
Matt