haw to save the output of a script in a file ansible 2.0.2

36 views
Skip to first unread message

mondher khas

unread,
Apr 7, 2016, 4:10:56 AM4/7/16
to Ansible Project

i want to save the output of a command in a file , i tried to use :

- command: ./script1 >> file.txt 2>&1 

but it's give me an empty file. Is there any other method to save the output of my "script1" in a "file" using ansible 2.0.2 . thank you in advance .

J Hawkesworth

unread,
Apr 7, 2016, 5:58:34 AM4/7/16
to Ansible Project
Hi, 

You probably need to use the shell module instead of the command module - command runs commands without a shell. To use >> and 2>&1, which are thing that your shell gives you, you need to use the shell module.

Hope this helps,

Jon

mondher khas

unread,
Apr 7, 2016, 6:31:09 AM4/7/16
to Ansible Project
thank you Jon , it's really helpful
Reply all
Reply to author
Forward
0 new messages