将变量写入Ansible中的文件 [英] Write variable to a file in Ansible

查看:92
本文介绍了将变量写入Ansible中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过URI模块提取JSON,并希望将接收到的内容写到文件中.我能够获取内容并将其输出到调试器,因此我知道已经收到了内容,但是我不知道编写文件的最佳实践.

I am pulling JSON via the URI module and want to write the received content out to a file. I am able to get the content and output it to the debugger so I know the content has been received, but I do not know the best practice for writing files.

推荐答案

您可以将copy模块与content参数一起使用:

You could use the copy module, with the content parameter:

- copy: content="{{ your_json_feed }}" dest=/path/to/destination/file

此处的文档:复制模块

这篇关于将变量写入Ansible中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆