# template/copy tasks questions

**URL:** <https://forum.ansible.com/t/template-copy-tasks-questions/12385>\
**Category:** Ansible Project\
**Created:** [February 19, 2013, 6:10pm UTC](https://forum.ansible.com/t/template-copy-tasks-questions/12385 "2013-02-19T18:10:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Anderson](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@Scott\_Anderson](https://forum.ansible.com/u/Scott_Anderson)\
**Post date:** [February 19, 2013, 6:10pm UTC](https://forum.ansible.com/t/template-copy-tasks-questions/12385/1 "2013-02-19T18:10:37Z")

</div>

I’m not sure if these can be done at the moment, and if not they’d be nice:

1. globbing and directory recursion in the template and copy tasks to do more than one file at a time

2. remote templating and copies: the use case is pulling a source code repository to the remote machine and doing some template-based configuration there from the repository without requiring its presence on the local machine running the playbook

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [February 19, 2013, 6:21pm UTC](https://forum.ansible.com/t/template-copy-tasks-questions/12385/2 "2013-02-19T18:21:46Z")

</div>

> 1) globbing and directory recursion in the template and copy tasks to do more than one file at a time

I do this with\_xxx all the time, using a fileglob or shell command as  
input (find).

> 2) remote templating and copies: the use case is pulling a source code  
> repository to the remote machine and doing some template-based configuration  
> there from the repository without requiring its presence on the local  
> machine running the playbook

I think you want something in line with ansible-pull or fireball mode  
here (with local actions).

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 19, 2013, 6:54pm UTC](https://forum.ansible.com/t/template-copy-tasks-questions/12385/3 "2013-02-19T18:54:35Z")

</div>

> > 2) remote templating and copies: the use case is pulling a source code  
> > repository to the remote machine and doing some template-based configuration  
> > there from the repository without requiring its presence on the local  
> > machine running the playbook

Can you explain the why in your use case in more depth?

It would be easy to orchestrate the local download of that repo prior  
to the remote actions.

---

<div class="post-metadata">

**Author:** ![Scott\_Anderson](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@Scott\_Anderson](https://forum.ansible.com/u/Scott_Anderson)\
**Post date:** [February 19, 2013, 8:06pm UTC](https://forum.ansible.com/t/template-copy-tasks-questions/12385/4 "2013-02-19T20:06:06Z")

</div>

That's what I will do at the start, but here's the issue:

I want the devops portion to be light and quick, and runnable from any machine with Python and ansible installed. The source code repository will contain a large number of static files and what not that I'd rather not have to download to a management machine.

The use case is Django configuration files. I don't want to keep them in the Ansible repo: they're .py files with some code and such. In my opinion they belong with the application itself, not the Ansible scripts. Also, I have dreams of creating a set of generic Django Ansible setup scripts and I don't think app-specific configuration belongs in them. nginx files are one thing; they're pretty generic and can be handled with some simple substitution for the most part, but not app config.

So the idea is to use Ansible to set up the app server, then on deploy Ansible will pull the latest repo of application code and static files onto the remote machine. There are Django settings templates in that repo (for dev, staging, and production). Ansible would then template the necessary files out of the application repo into a spot where the executing uwsgi server can see them.

It also removes a git pull (for the local machine). Going on to the remote copy, the same thing applies: if I want to move things around from the application repo into other places on the remote machine, it's best not to have to copy them over the wire if I've already pulled them elsewhere.

Make sense?

Regards,  
-scott

---

<div class="post-metadata">

**Author:** ![Scott\_Anderson](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@Scott\_Anderson](https://forum.ansible.com/u/Scott_Anderson)\
**Post date:** [February 19, 2013, 8:09pm UTC](https://forum.ansible.com/t/template-copy-tasks-questions/12385/5 "2013-02-19T20:09:23Z")

</div>

Cool, thanks. I forgot about with\_fileglob. That's exactly what I need.

Regards,  
-scott
