Write variable to a file in Ansible

前端 未结 4 738
感动是毒
感动是毒 2020-12-24 04:34

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

4条回答
  •  星月不相逢
    2020-12-24 04:55

    Based on Ramon's answer I run into an error. The problem where spaces in the JSON I tried to write I got it fixed by changing the task in the playbook to look like:

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

    As of now I am not sure why this was needed. My best guess is that it had something to do with how variables are replaced in Ansible and the resulting file is parsed.

提交回复
热议问题