# Capture return values to file

**URL:** <https://forum.ansible.com/t/capture-return-values-to-file/24762>\
**Category:** Ansible Project\
**Created:** [June 19, 2017, 1:23pm UTC](https://forum.ansible.com/t/capture-return-values-to-file/24762 "2017-06-19T13:23:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Rose](https://avatars.discourse-cdn.com/v4/letter/d/cdc98d/32.png) [@David\_Rose](https://forum.ansible.com/u/David_Rose)\
**Post date:** [June 19, 2017, 1:23pm UTC](https://forum.ansible.com/t/capture-return-values-to-file/24762/1 "2017-06-19T13:23:38Z")

</div>

Hello all!  
I have a questions regarding capturing return values and writing them to a file. Specifically, my use-case is in cloud provisioning … I am standing up any number of VMs. When the VM is created, and only when it is created, a return value held by .password is available. I can print the instance variable in a debug message. But my question is, how can I capture it automatically for future connections to this server without writing to paper? How can I automate, if the variable .password exists, so that it is written (maybe to vault?) and then used for subsequent plays for use in, I believe, ‘ansible\_become\_pass’?

Thank you!  
-dave

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [June 19, 2017, 8:09pm UTC](https://forum.ansible.com/t/capture-return-values-to-file/24762/2 "2017-06-19T20:09:18Z")

</div>

For simple strings, you can write them to disk by using the ‘content’ option of the copy module [http://docs.ansible.com/ansible/copy\_module.html](http://docs.ansible.com/ansible/copy_module.html) (which you can delegate to localhost to copy to your ansible controller machine).

Hope this helps,

Jon
