I am downloading the file with wget
from ansible.
- name: Download Solr
shell: chdir={{project_root}}/solr wget http://mirror.mel.bkb.net.au/pub/apache/lucene/solr/4.7.0/solr-4.7.0.zip
but I only want to do that if zip file does not exist in that location. Currently the system is downloading it every time.
Unless you have a reason to use
wget
why not useget_url
module. It will check if the file needs to be downloaded.NOTE: If you put the directory and not the full path in the
dest
ansible will still download the file to a temporary dir but do an md5 check to decide whether to copy to the dest dir.And if you need to save state of download you can use:
my favourite is to only download the file if it is newer than the local file (which includes when the local file does not exist)
the
-N
option with wget does this: https://www.gnu.org/software/wget/manual/html_node/Time_002dStamping-Usage.html .sadly, i don't think there is an equivalent feature in
get_url
so a very small change:
- name: Download Solr shell: chdir={{project_root}}/solr wget -N http://<SNIPPED>/solr-4.7.0.zip