I am wondering if a remote fileglob mechanism has been added for fetch. If not, I'll use Daniel's solution from above.
Thanks! Joanna On Monday, October 29, 2012 at 7:26:50 PM UTC-5, Michael DeHaan wrote: > > I prefer Daniel's approach in this case, but I think we can also make > syntax easier if using fetch by building a "with_remote_fileglob" if we > wanted to. > > -- Michael > > On Oct 29, 2012, at 7:51 PM, Dag Wieers <[email protected] <javascript:>> > wrote: > > > On Mon, 29 Oct 2012, Daniel Hokka Zakrisson wrote: > > > >> Michael DeHaan wrote: > >>> On Mon, Oct 29, 2012 at 3:56 PM, Jarrett Chisholm > >>> <[email protected] <javascript:>> 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, [email protected] <javascript:>, http://dag.wieers.com/ > > -- dagit linux solutions, [email protected] <javascript:>, > http://dagit.net/ > > > > [Any errors in spelling, tact or fact are transmission errors] > > > > -- > > > > > -- 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]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/827e0f2b-9405-4d7c-94e2-a6ea53a03231%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
