How to use notify with with_items

76 views
Skip to first unread message

Suporter

unread,
Apr 4, 2017, 9:01:19 AM4/4/17
to Ansible Project
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

Suporter

unread,
Apr 4, 2017, 11:52:52 AM4/4/17
to Ansible Project
Why ansible forums is not so active all the time? 

Suporter

unread,
Apr 5, 2017, 2:13:18 PM4/5/17
to Ansible Project
ansiblers any help?


On Tuesday, April 4, 2017 at 6:31:19 PM UTC+5:30, Suporter wrote:

J Hawkesworth

unread,
Apr 5, 2017, 6:19:05 PM4/5/17
to Ansible Project
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

Suporter

unread,
Apr 17, 2017, 1:51:13 AM4/17/17
to Ansible Project
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? 

On Tuesday, April 4, 2017 at 6:31:19 PM UTC+5:30, Suporter wrote:

Suporter

unread,
Apr 17, 2017, 1:51:59 AM4/17/17
to Ansible Project
Should i use "when" here?

Suporter

unread,
Apr 18, 2017, 10:03:04 AM4/18/17
to Ansible Project
ansiblers any help?


On Tuesday, April 4, 2017 at 6:31:19 PM UTC+5:30, Suporter wrote:

acharya tejaswi indurthi

unread,
Apr 18, 2017, 12:09:13 PM4/18/17
to Ansible Project
Reply all
Reply to author
Forward
0 new messages