# delegate\_to, templates and roles. Files are not being created in /tmp

**URL:** <https://forum.ansible.com/t/delegate-to-templates-and-roles-files-are-not-being-created-in-tmp/22663>\
**Category:** Ansible Project\
**Created:** [September 28, 2016, 11:15am UTC](https://forum.ansible.com/t/delegate-to-templates-and-roles-files-are-not-being-created-in-tmp/22663 "2016-09-28T11:15:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chethan\_S](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chethan\_S](https://forum.ansible.com/u/Chethan_S)\
**Post date:** [September 28, 2016, 11:15am UTC](https://forum.ansible.com/t/delegate-to-templates-and-roles-files-are-not-being-created-in-tmp/22663/1 "2016-09-28T11:15:27Z")

</div>

I have an Ansible role (resides in …/roles/rolename/tasks) which goes like this -

`

- name: Creating the PowerShell Scripts necessary  
template: src=script.ps1 dest=/tmp/{{item}}.ps1  
with\_items: “{{ names }}”  
delegate\_to: localhost  
`

The script.ps1 shown under src resides in …/roles/rolename/templates/. After running the playbook if I check the Ansible Controller VMs /tmp folder, I don’t see the files that are supposed to be created. The _names_ are machine1, machine2 etc. I have tried changing localhost to 127.0.0.1 but that didn’t help me.

The debug log reports success -

`changed: [machine1 -> localhost] => (item=machine1) => {"changed": true, ......"dest": "/tmp/machine1.ps1"....} changed: [machine2 -> localhost] => (item=machine1) => {"changed": true, ......"dest": "/tmp/machine2.ps1"....}`

Actually, the next step in my role is expected to copy the files generated in /tmp/ to a specified location in machine1, machine2 etc.

What is wrong in my way of doing things?

---

<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:** [September 28, 2016, 2:07pm UTC](https://forum.ansible.com/t/delegate-to-templates-and-roles-files-are-not-being-created-in-tmp/22663/2 "2016-09-28T14:07:25Z")

</div>

Nothing, the code is correct.  
Are you sure the files is not in /tmp on the control machine.

---

<div class="post-metadata">

**Author:** ![Chethan\_S](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chethan\_S](https://forum.ansible.com/u/Chethan_S)\
**Post date:** [September 28, 2016, 2:22pm UTC](https://forum.ansible.com/t/delegate-to-templates-and-roles-files-are-not-being-created-in-tmp/22663/3 "2016-09-28T14:22:00Z")

</div>

I am sure that the files aren’t being created since there’s hardly anything inside my /tmp and these files are not present either.

---

<div class="post-metadata">

**Author:** ![Chethan\_S](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chethan\_S](https://forum.ansible.com/u/Chethan_S)\
**Post date:** [September 29, 2016, 6:27am UTC](https://forum.ansible.com/t/delegate-to-templates-and-roles-files-are-not-being-created-in-tmp/22663/4 "2016-09-29T06:27:58Z")

</div>

I could figure out the solution. It turned out that the files, even though they were being created inside /tmp/ (I couldn’t verify this, though) were being deleted instantly for whatever reason. Once I changed the destination to /var/tmp, I could see the files and even use them.
