{{ path | basename }}

http://ansibleworks.com/docs/playbooks_variables.html#jinja2-filters




On Wed, Nov 20, 2013 at 12:08 PM, Colin Coombs <[email protected]> wrote:

> I need to install configuration files for an application on multiple
> hosts, where
>
> (1) each host needs a different collection of files, and
> (2) each file may have different content for each host.
>
> I have the following file layout:
>
> ./roles/myapp/files/host01/foo.conf
> ./roles/myapp/files/host02/foo.conf
> ./roles/myapp/files/host02/bar.conf
>
> etc etc.
>
> In ./roles/myapp/tasks/main.yml, I want something like the following task:
>
>   - name: install config files
>     copy: dest=/etc/myapp/{{ item }} src={{ ansible_hostname }}/{{ item }}
>     with_fileglob:
>       - "{{ ansible_hostname }}/*.conf"
>
> The problem is that the "with_fileglob" line sets {{ item }} to an
> absolute filename like
>
>   /path/to/my/dir/roles/files/host01/foo.conf
>
> which must be copied to /etc/myapp/foo.conf on the host01 system.
>
> Is there some way I can extract just the 'foo.conf' part of the full name,
> or does ansible have
> a different way to perform such a task?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Michael DeHaan <[email protected]>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to