Question:
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.
Answer:
1 2 3 4 5 |
As of Ansible 2.10, The documentation for ansible.builtin.copy says: If you need variable interpolation in copied files, use the ansible.builtin.template module. Using a variable in the content field will result in unpredictable output. |
For more details see this and an explanation
You could use the copy
module, with the content
parameter:
1 2 |
- copy: content="{{ your_json_feed }}" dest=/path/to/destination/file |
The docs here: copy module