# File creation from within a custom module

**URL:** <https://forum.ansible.com/t/file-creation-from-within-a-custom-module/30945>\
**Category:** Ansible Developer\
**Created:** [August 4, 2019, 7:03pm UTC](https://forum.ansible.com/t/file-creation-from-within-a-custom-module/30945 "2019-08-04T19:03:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Tillis](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@Miguel\_Tillis](https://forum.ansible.com/u/Miguel_Tillis)\
**Post date:** [August 4, 2019, 7:03pm UTC](https://forum.ansible.com/t/file-creation-from-within-a-custom-module/30945/1 "2019-08-04T19:03:47Z")

</div>

Hello!

How do you create & modify a file from within a custom module?

I created a custom module that transfers some functionality from a python3 program that I wrote. Part of the program modifies a file by using the open() method.  
This method does not seem to work when initiating the pieced of code from my ansible-playbook runs.Although, the code runs without being initiated via an ansible module.

**How do I use the open() method within a custom ansible module?**

&

**If I can’t use the open() method for files what else can I use to open, write, and modify files within a module?**
