# User files supplied best practice

**URL:** <https://forum.ansible.com/t/user-files-supplied-best-practice/14312>\
**Category:** Ansible Project\
**Created:** [January 10, 2014, 9:52am UTC](https://forum.ansible.com/t/user-files-supplied-best-practice/14312 "2014-01-10T09:52:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mayeu](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@Mayeu](https://forum.ansible.com/u/Mayeu)\
**Post date:** [January 10, 2014, 9:52am UTC](https://forum.ansible.com/t/user-files-supplied-best-practice/14312/1 "2014-01-10T09:52:53Z")

</div>

Hi all,

I am wondering if there is some clean way to handle files supplied by  
the user.

I have two use cases:

- a role that ask for ssl certificates[1]. Currently I ask the user to  
&nbsp;&nbsp;add them in their root `files/` folder under specific names, and I use  
&nbsp;&nbsp;copy + `with_item`. It works pretty well. Is this the "good way" of  
&nbsp;&nbsp;doing it?

&nbsp;&nbsp;[1] [https://github.com/Mayeu/ansible-playbook-rabbitmq#using-it](https://github.com/Mayeu/ansible-playbook-rabbitmq#using-it)

- a role that wait for a list of file. Currently I ask the user to set  
&nbsp;&nbsp;a variable with the list of filenames, put the files in the root  
&nbsp;&nbsp;`files/` folder of their playbooks, and I use copy with `with_item`.

&nbsp;&nbsp;I would like to make something like "copy \*.rb". But `with_fileglob`  
&nbsp;&nbsp;only use the role `files` as root. And setting a relative path like  
&nbsp;&nbsp;`../../files/` to get to the user ones is not a clean solution to me.

What do you think about those two?

What are the rationnal to limit `with_fileglob` to the role `files/`  
folder, and not making the same logic used by the copy module for  
example (checking that the path exist either in the role, or the root  
playbook)?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 10, 2014, 1:55pm UTC](https://forum.ansible.com/t/user-files-supplied-best-practice/14312/2 "2014-01-10T13:55:46Z")

</div>

with\_fileglob or with\_first\_found could be potentially very useful for generic things.

There’s also the synchronize module for copying lots of files, and the recursive=yes flag to the copy module.

Things like ‘copy’ know to look in the “files/” directory inside the role so there’s little need for relative paths.

“What are the rationnal to limit”

Lookup plugins just don’t look in multiple places for things like that, and in the case of file globbing, explicitness is good.

You could …/ here I’m pretty sure.

---

<div class="post-metadata">

**Author:** ![Mayeu](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@Mayeu](https://forum.ansible.com/u/Mayeu)\
**Post date:** [January 10, 2014, 3:55pm UTC](https://forum.ansible.com/t/user-files-supplied-best-practice/14312/3 "2014-01-10T15:55:01Z")

</div>

> You could ../ here I'm pretty sure.

How will this work with Galaxy? Moduler are in `/etc/ansible/roles/`,  
this will try to find something in `/etc`, or do ansible does some  
magic about that?
