On Mon, 29 Oct 2012, Daniel Hokka Zakrisson wrote:
> Michael DeHaan wrote:
>> On Mon, Oct 29, 2012 at 3:56 PM, Jarrett Chisholm
>> <
jarrett...@gmail.com> wrote:
>>> Hi all,
>>>
>>> I'm trying to copy a files down from one of our hosts, and it contains a
>>> timestamp in the name. This, unfortunately, is going to be hard to
>>> change
>>> for us (if at all).
>>>
>>> Is there a way in ansible to have a source file with a wildcard?
>>>
>>> i.e.:
>>>>
>>>> action: fetch src=/data_dump_*.sql dest=/var/lib/ansible/files/fetched
>
> Yes, the way to do it is to list the files in one action, and then use
> with_items on the result. For example
> - name: list files
> action: command ls -1 /data_dump_*.sql
> register: dumpfiles
> - name: fetch files
> action: fetch src=$item dest=/var/lib/ansible/files/fetched
> with_items: ${dumpfiles.stdout_lines}
What I usually do in this case, especially if you need to recurse over
directories is:
----
- action: command mktemp -d
register: tempdir
- local_action: rsync -aH /local/path ${inventory_hostname}:${tempdir.stdout}
----
In the above case it's in a temporary directory because we start the
installation from that directory and afterwards remove it. In case you
simply want to make sure what is on the destination is exactly like on the
source, you might want to add some other options, eg. --delete
--delay-updates, etc...
Or the reverse if firewalls allow it and DNS is happy with it:
----
- local_action: command hostname -s
register: localname
- action: rsync -aH /remote/path ${localname.stdout}:/local/path
----
However I was wondering if an rsync-module using rsync over the existing
transport would be a possibility to avoid firewall/dns issues.
Kind regards,
--
-- dag wieers,
d...@wieers.com,
http://dag.wieers.com/
-- dagit linux solutions,
in...@dagit.net,
http://dagit.net/
[Any errors in spelling, tact or fact are transmission errors]