我想将命令的输出保存在文件中,我尝试使用:
- command: ./script1 >> file.txt 2>&1
但它给了我一个空文件。 是否有任何其他方法可以使用 ansible 2.0.2 将“script1”的输出保存在"file"中。 预先感谢您。
最佳答案
您需要替换command
与 shell
.
The command module takes the command name followed by a list of space-delimited arguments. The given command will be executed on all selected nodes. It will not be processed through the shell, so variables like
$HOME
and operations like"<"
,">"
,"|"
, and"&"
will not work (use the shell module if you need these features).
来源:Ansible docs .
关于linux - 如何将脚本的输出保存在ansible 2.0.2文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36470297/