# Mix Tasks and roles: files folder

**URL:** <https://forum.ansible.com/t/mix-tasks-and-roles-files-folder/15156>\
**Category:** Ansible Project\
**Created:** [May 5, 2014, 8:14am UTC](https://forum.ansible.com/t/mix-tasks-and-roles-files-folder/15156 "2014-05-05T08:14:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![profhase85](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@profhase85](https://forum.ansible.com/u/profhase85)\
**Post date:** [May 5, 2014, 8:14am UTC](https://forum.ansible.com/t/mix-tasks-and-roles-files-folder/15156/1 "2014-05-05T08:14:25Z")

</div>

having this playbook (where i’d like to copy the private key to some users):

`

- hosts: my\_special\_hosts

tasks:

- name: Copy Private Key  
copy:  
src={{item.name ~ “\_key” }}  
dest=“/home/{{item.name}}/.ssh/id\_rsa”  
owner=“{{item.name}}”  
mode=“0500”  
with\_items: admin\_users  
sudo: true

roles:

- admin\_users

`

I am wondering:  
The with\_items statement works perfectly (the variable admin\_users is defined in roles/admin\_users/vars/main.yml).  
On the other hand ‘copy’ does look up the ‘roles/admin\_users/files’ folder. (The error message is: ‘could not find src=/ansibledir/user\_key’)

It seems inconsistant to me. Does anyone know more?

Thanks

---

<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:** [May 6, 2014, 3:48am UTC](https://forum.ansible.com/t/mix-tasks-and-roles-files-folder/15156/2 "2014-05-06T03:48:19Z")

</div>

“It seems inconsistant to me.”

What specifically seems inconsistent?

Can you share output and the ansible version you are using?

Thanks!

---

<div class="post-metadata">

**Author:** ![profhase85](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@profhase85](https://forum.ansible.com/u/profhase85)\
**Post date:** [May 6, 2014, 11:17am UTC](https://forum.ansible.com/t/mix-tasks-and-roles-files-folder/15156/3 "2014-05-06T11:17:03Z")

</div>

I am using ansible 1.5 .

It seems inconsistent to me that the variable defined in the role (i.e. defined in roles/admin\_users/vars/main.  
yml)  
is also available in the task while the files in the role file folder (i.e. roles/admin\_users/files) are not found by the copy module

Thanks

---

<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:** [May 6, 2014, 12:58pm UTC](https://forum.ansible.com/t/mix-tasks-and-roles-files-folder/15156/4 "2014-05-06T12:58:29Z")

</div>

This is working as designed.

When you define a variable in a role, that role might be something like “common” and package variables that other roles might like to use.

For instance a role could define “production” vs “staging” environment behavior, and a value like “ntp\_server” could be used in subsequent roles.

When roles look for files, they look for files relative to them first, then at playbook level.

However, we don’t comb all file paths, as it would be difficult to source where files were drawing from – as it’s not improbable two different files might share the same name and different paths. The files are only searched in two places – the files (or templates) dir, and the level up.
