且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Ansible-将注册变量保存到文件

更新时间:2023-01-16 14:29:23

您可以使用带有参数content=copy模块.

You can use the copy module, with the parameter content=.

我在这里给出了完全相同的答案:将变量写入Ansible中的文件

I gave the exact same answer here: Write variable to a file in Ansible

在您的情况下,您似乎希望将此变量写入本地日志文件,因此可以将其与local_action表示法组合:

In your case, it looks like you want this variable written to a local logfile, so you could combine it with the local_action notation:

- local_action: copy content={{ foo_result }} dest=/path/to/destination/file