linux - 如何将脚本的输出保存在ansible 2.0.2文件中

标签 linux shell yaml ansible

我想将命令的输出保存在文件中,我尝试使用:

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

但它给了我一个空文件。 是否有任何其他方法可以使用 ansible 2.0.2 将“script1”的输出保存在"file"中。 预先感谢您。

最佳答案

您需要替换commandshell .

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/

相关文章:

linux - 使用 wget 下载 shtml 页面上的所有 zip 文件

shell - Mac OSx 终端 : "not a valid identifier" on function definition

linux - Linux下cut命令的使用方法

kubernetes - 有没有办法在 kubernetes 中的环境变量上使用方括号?

Python re.sub 特定语法

linux - 当 var=$(... | grep "value") 为空时,脚本退出并出现错误,但当 grep 有结果时,脚本可以工作

c - 如何在 Linux 内核中使用 bio 请求读取一个扇区

bash - Shell - 表达式中的语法错误(错误标记为 "0 ")

html - 使用 Pandoc 从 HTML META 标签创建 YAML 元数据

java - 使用 Jackson 读取 yaml 来对象