Download all files from a url

670 views
Skip to first unread message

Suporter

unread,
Mar 24, 2017, 1:08:52 PM3/24/17
to Ansible Project
win_get_url has options to download all files from an url with uid and pwd and save it locally? i tried with one file but it needs file extensions and exact file names for destination

Dick Visser

unread,
Mar 25, 2017, 2:18:24 AM3/25/17
to ansible...@googlegroups.com
I'm not sure what you mean by 'download all files from an url with uid
and pwd', but it sounds like you're trying to mirror a website using
some sort of pattern containing wildcards.
If that is the case, win_get_url won't work as it only handles
(explicitly named) single files.

You'd have to loop through a list of items - provided you know them beforehand.
The concept of file extensions is irrelevant to HTTP so yes you need
full filenames (i.e. including the extension).

If you don't know the filenames beforehand (the wildcard pattern
scenario such as "http://example.com/files/*.txt"), then you have to
resort to tools like curl and wget.
This in turn relies on the web server serving directory indexes etc.


Dick
> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4a41b50e-852f-48e3-9ef1-e66d84e8008b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Dick Visser
Sr. System & Network Engineer
GÉANT

Want to join us? We're hiring: https://www.geant.org/jobs

Suporter

unread,
Mar 27, 2017, 4:36:49 AM3/27/17
to Ansible Project
right now, i am downloading with exact link of the files and added those to with_items...is there a way to check if the file is new or not..download only if it is new?

J Hawkesworth

unread,
Mar 27, 2017, 7:38:14 AM3/27/17
to Ansible Project
Yes.  Just use the 'force: no' parameter - see http://docs.ansible.com/ansible/win_get_url_module.html
Reply all
Reply to author
Forward
0 new messages