i am downloading zip files from an url, i am using with_items for list of zip files in that location, i want to do a task (extract) for only the file downloaded. Since i am new to ansible i cant think of anything other than using with_items for downloading files, but i dont know how to make use of notify here, if i use notify below with_items how it will invoke only the file it has downloaded. To summarise , i want to download zip files which are changed, extract only the files which are downloaded and install only the files which are extracted. Since with_items has all the files listed in it , how can i achieve this workflow in ansible
Why ansible forums is not so active all the time?
ansiblers any help?
use win_get_url and with_items with a list of zips you want to download, and also use ‘register’ to capture which files were downloaded into a variable with a name like download_list. Also set ‘force=no’ on win_get_url so that it only fetches each zip once.
Then you can use the results in download_list to make a new list of zips that need extracting ( changed=true) and call win_unzip with the zips that were changed.
use the debug module
- name: show contents of download list
debug
var: download_list
to see what has been downloaded
This will work fine until you have a zip file that won’t unzip. In which case you will either have to remove the (broken) zip file and re-run your playbook, or perhaps change the ‘force=no’ to ‘force=yes’.
Hope this helps.
Jon
Then you can use the results in download_list to make a new list of zips that need extracting ( changed=true) and call win_unzip with the zips that were changed
How can i do this?
Should i use “when” here?
ansiblers any help?
Hi,
These two link may help you
- http://docs.ansible.com/ansible/win_get_url_module.html
- http://docs.ansible.com/ansible/win_unzip_module.html
Thanks,