I want the output of the script that is executed in remote server to be saved in a text document in the remote server. I tried many ways but nothing seems to be work out.
---
- name: Transfer and execute a script.
hosts: slave
remote_user: root
sudo: yes
tasks:
- name: Transfer the script
copy: src=uptime.sh dest=/home/ mode=0777
- name: Execute the script
command: sh /home/uptime.sh >> /home/output