Append shell script output on remote server

13 views
Skip to first unread message

Rahul Kolan

unread,
Apr 30, 2019, 12:57:10 PM4/30/19
to ansible...@googlegroups.com
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".

 

Thanks & Regards,

Rahul







DISCLAIMER:

This message including attachments if any intended solely for specific individual and purpose & may contain confidential material AND/OR Private Company Information. If you are not the intended recipient, any disclosure, copying or distribution of this message or any action based on it, is strictly prohibited & protected under relevant law. If you have received this communication in error, please contact the sender or delete this message immediately. Thank you for your kind cooperation.

Matthew Davis

unread,
May 7, 2019, 8:30:52 PM5/7/19
to Ansible Project
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
Reply all
Reply to author
Forward
0 new messages