# Save a variable to a File

**URL:** <https://forum.ansible.com/t/save-a-variable-to-a-file/22135>\
**Category:** Ansible Project\
**Created:** [July 27, 2016, 12:15pm UTC](https://forum.ansible.com/t/save-a-variable-to-a-file/22135 "2016-07-27T12:15:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Lewis](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@John\_Lewis](https://forum.ansible.com/u/John_Lewis)\
**Post date:** [July 27, 2016, 12:15pm UTC](https://forum.ansible.com/t/save-a-variable-to-a-file/22135/1 "2016-07-27T12:15:45Z")

</div>

How do I save a variable to a file if it contained contents of a file on a host that couldn’t support anything but the raw module?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 27, 2016, 5:14pm UTC](https://forum.ansible.com/t/save-a-variable-to-a-file/22135/2 "2016-07-27T17:14:42Z")

</div>

It depends, but if the content in the variable isn't to big this should work.

- raw: echo '{{ variable }}' \>/path/to/file
