# Templates - Create, but do NOT update

**URL:** <https://forum.ansible.com/t/templates-create-but-do-not-update/16706>\
**Category:** Ansible Project\
**Created:** [November 6, 2014, 4:44am UTC](https://forum.ansible.com/t/templates-create-but-do-not-update/16706 "2014-11-06T04:44:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akos\_Vandra](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@Akos\_Vandra](https://forum.ansible.com/u/Akos_Vandra)\
**Post date:** [November 6, 2014, 4:44am UTC](https://forum.ansible.com/t/templates-create-but-do-not-update/16706/1 "2014-11-06T04:44:04Z")

</div>

Hello,

This might be a wierd feature request at first, but would you accept a PR to add an option to the template module to create but do NOT update the generated file?

I find myself needing this when generating secrets.  
I do want to generate my secret file if it does not exists (and it needs to be generated to a form dictated by a template), but I do not want to change its contents which is usually generated by a PRNG.

Regards,  
Akos Vandra

---

<div class="post-metadata">

**Author:** ![James\_Martin1](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@James\_Martin1](https://forum.ansible.com/u/James_Martin1)\
**Post date:** [November 6, 2014, 4:48am UTC](https://forum.ansible.com/t/templates-create-but-do-not-update/16706/2 "2014-11-06T04:48:58Z")

</div>

You could stat the file using the stat module to see if it exists and register it’s result, then run your template task conditionally, only if the file does not exist.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [November 7, 2014, 3:43pm UTC](https://forum.ansible.com/t/templates-create-but-do-not-update/16706/3 "2014-11-07T15:43:33Z")

</div>

Hi Akos,

The template module (being part of the file module family), does support the use of `force=no`, meaning the file will not be replaced if it already exists. This is not documented on that modules page, which we will get updated.

Thanks!
