Recursive templates in roles?

Would be convenient to do this in a role:

`

  • template: src=some_templates dest=/path/to/remote/folder recurse=true
    `

And for it to pass the entire folder structure over while passing every file through jinja2. Is there anything in the way of this being implemented?

Hi, thanks for the suggestion.

Right now, this is pretty much what the assemble module does, however each file in the assembled list is not templated. It would make more sense to me to add a template=yes option to that module, which would run the files through the template engine (if and only if the src files were not remote).

Could you please open a github issue for this feature request so that we can keep track of it?

Thanks!

I do this:

  • template: src={{item}} dest=/path/sdf/sdf/{{item}}with_pipe: find /local/path/to/templates -type f

Brian, that’s clever! I’ll give that a shot. Is it idempotent?

I went ahead and added the feature request to do this in more of a pure ansible fashion. https://github.com/ansible/ansible/issues/8497

Yes, that would not replace templates that had not changed. Also, I believe the with_fileglob would generally be a better solution there:

http://docs.ansible.com/playbooks_loops.html#looping-over-fileglobs

Regarding your question on the ticket you opened, the assemble module only builds single files. So if you’re looking for more of a recursive copy function then the above is the way to do it. I would still like to keep that feature request open, as I believe it would be a useful option.

Thanks!

Looks like it does not work for me, for some reason with_pipe does nto return a list. Please help if you have any idea …