# Diff between template and copy if target directory doesn't exist

**URL:** <https://forum.ansible.com/t/diff-between-template-and-copy-if-target-directory-doesnt-exist/16132>\
**Category:** Ansible Project\
**Created:** [September 5, 2014, 9:16pm UTC](https://forum.ansible.com/t/diff-between-template-and-copy-if-target-directory-doesnt-exist/16132 "2014-09-05T21:16:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Hughes](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@Matt\_Hughes](https://forum.ansible.com/u/Matt_Hughes)\
**Post date:** [September 5, 2014, 9:16pm UTC](https://forum.ansible.com/t/diff-between-template-and-copy-if-target-directory-doesnt-exist/16132/1 "2014-09-05T21:16:52Z")

</div>

It appears the ‘template’ module doesn’t auto create the destination directory, yet ‘copy’ module does. I don’t see any way to force it to auto-create, nor any module that would work around this. Any one else experience this? I would think both modules should have the same behavior.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 5, 2014, 9:19pm UTC](https://forum.ansible.com/t/diff-between-template-and-copy-if-target-directory-doesnt-exist/16132/2 "2014-09-05T21:19:43Z")

</div>

I’m definitely open to either a feature request or a pull request to make this happen.

---

<div class="post-metadata">

**Author:** ![Matt\_Hughes](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@Matt\_Hughes](https://forum.ansible.com/u/Matt_Hughes)\
**Post date:** [September 5, 2014, 9:19pm UTC](https://forum.ansible.com/t/diff-between-template-and-copy-if-target-directory-doesnt-exist/16132/3 "2014-09-05T21:19:54Z")

</div>

Ignore me 🙂

[https://github.com/ansible/ansible/issues/3759](https://github.com/ansible/ansible/issues/3759)

I found the ‘file’ module.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 5, 2014, 9:21pm UTC](https://forum.ansible.com/t/diff-between-template-and-copy-if-target-directory-doesnt-exist/16132/4 "2014-09-05T21:21:39Z")

</div>

Yeah that’s an old ticket, but the file module will serve as a workaround.

I’m open to the improvement idea.
