# Template File Transfer

**URL:** <https://forum.ansible.com/t/template-file-transfer/29062>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [November 19, 2018, 8:25am UTC](https://forum.ansible.com/t/template-file-transfer/29062 "2018-11-19T08:25:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_Burrows](https://avatars.discourse-cdn.com/v4/letter/i/a698b9/32.png) [@Ian\_Burrows](https://forum.ansible.com/u/Ian_Burrows)\
**Post date:** [November 19, 2018, 8:25am UTC](https://forum.ansible.com/t/template-file-transfer/29062/1 "2018-11-19T08:25:47Z")

</div>

Hi, I am very new to Ansible and I have a question regarding the template module.

I am receiving an error running a playbook where ansible cannot find or access the j2 file.

If I transfer the file manually into /tmp/kitchen/ where it says it is looking, then it runs fine. I am using Test Kitchen with kitchen-ansible, Vagrant and Inspec on Windows. Is the template file not supposed to be sent to the host with kitchen? Maybe this is a Test Kitchen issue of not generating the files on the target?

Thank you for any guidance.

---

<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:** [November 19, 2018, 8:50am UTC](https://forum.ansible.com/t/template-file-transfer/29062/2 "2018-11-19T08:50:57Z")

</div>

Hard to guess what’s going on here without seeing your playbook and template file, but my guess would be the template (.j2) file isn’t in one of the places that ansible expects to find it.

If your template is in a role (best place for it) then there are some rules about where ansible will look for templates (and other files) described here:  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_reuse\_roles.html#using-roles](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#using-roles)

I can’t speak for ‘kitchen’ as I haven’t used for it, but the `template` module should copy (templated) files to the destination that is specified - but if it can’t find the template then it wont of course.

Hope this helps,  
Jon

---

<div class="post-metadata">

**Author:** ![Ian\_Burrows](https://avatars.discourse-cdn.com/v4/letter/i/a698b9/32.png) [@Ian\_Burrows](https://forum.ansible.com/u/Ian_Burrows)\
**Post date:** [November 19, 2018, 10:58am UTC](https://forum.ansible.com/t/template-file-transfer/29062/3 "2018-11-19T10:58:47Z")

</div>

Thanks, my directory structure is as follows:

/  
.kitchen.yml  
roles/common/  
–/tasks/playbook.yml  
–/templates/create\_motd.j2  
test/

`

//.kitchen.yml

---

<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:** [November 19, 2018, 2:00pm UTC](https://forum.ansible.com/t/template-file-transfer/29062/4 "2018-11-19T14:00:05Z")

</div>

Hmm, as I say I don’t know what kitchen expects, however it strikes me as unusual to have your playbook stored in the tasks folder of your role. Generally playbooks list one or more roles that should be applied to the hosts in the current play, so it seems odd to have the playbook stored in with the role.

Can you try just using ‘bare’ ansible without it being wrapped in kitchen?

Might be worth running ansible-playbook with -vvvvv to get debugging information including the paths where it is looking for things.

Hope this helps,

Jon
