here's an easy thing to try: ansible localhost -m get_url -c local -a "url=http://google.com dest=/tmp/path force=no" Observe /tmp/path edit /tmp/path to say "changeme this is a file that needs to be replaced" Run ansible command again observe /tmp/path is now replaced
On Fri, Aug 29, 2014 at 8:47 AM, Levi Notik <[email protected]> wrote: > Version is 1.7.1 > > I'm probably missing something basic here (very new to ansible), but after > running the playbook, I checked the directory on the host and the file > hasn't been modified. Similarly, the notify step of restarting the service > doesn't run (I know this by tailing logs). > > > On Friday, August 29, 2014 8:41:14 AM UTC-4, Michael DeHaan wrote: > >> (A) please confirm what version of ansible you are using (ansible >> --version) >> >> (B) when you say "didn't work", can you describe what did not work means? >> How did you ascertain it did not work? >> >> >> >> >> On Fri, Aug 29, 2014 at 8:36 AM, Levi Notik <[email protected]> wrote: >> >>> I've tried with force: yes with everything else the same as above and >>> that didn't work. >>> >>> >>> On Friday, August 29, 2014 8:33:26 AM UTC-4, Michael DeHaan wrote: >>> >>>> Hi Levi, >>>> >>>> It looks like you need to use the "force" parameter, which is >>>> documented as follows: >>>> >>>> If yes and dest is not a directory, will download the file every time >>>> and replace the file if the contents change. If no, the file will only >>>> be downloaded if the destination does not exist. Generally should be >>>> yesonly for small local files. Prior to 0.6, this module behaved as if >>>> yes was the default. (added in Ansible 0.7) >>>> >>>> (We can really remove all the special notes about 0.6 and 0.7, as >>>> that's some very old stuff and everyone has upgraded at this point) >>>> >>>> Also, usual disclaimer about get_url: If you have more than one >>>> server, a good tip can be to use a local step in a preceeding play to >>>> download a file and then the copy module to move it out. This prevents >>>> using your server farm to unintentionally DDOS a particular website or >>>> service. 500 or 1000 machines downloading a tarball would be rather >>>> abusive, especially if using force=yes or deploying them all at the same >>>> time. >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Fri, Aug 29, 2014 at 8:12 AM, Levi Notik <[email protected]> wrote: >>>> >>>>> I'm trying to use get_url to download a file to a group of hosts. My >>>>> play looks like this: >>>>> >>>>> --- >>>>> - hosts: webservers >>>>> remote_user: ec2-user >>>>> tasks: >>>>> - name: download jar >>>>> get_url: >>>>> url: https://s3-us-west-2.amazonaws.com/bucket/some.jar >>>>> dest: /home/ec2-user/management/jars/some.jar >>>>> notify: restart_service >>>>> - name: start_service >>>>> service: name=gw-management state=started >>>>> sudo: yes >>>>> handlers: >>>>> - name: restart_service >>>>> service: name=gw-management state=restarted >>>>> sudo: yes >>>>> >>>>> The file does not seem to be downloaded if it already exists in the >>>>> dest directory. If I delete the file first, everything works as expected. >>>>> The docs for get_url are slightly confusing and I'm not sure how dest >>>>> being >>>>> a directory affects things. I've also tried using force. >>>>> >>>>> Do I simply need to set the destination to >>>>> /home/ec2-user/management/jars without the file name and then, as the docs >>>>> state, "If dest is a directory, the file will always be downloaded >>>>> (regardless of the force option), but replaced only if the contents >>>>> changed."? Also, how does ansible determine contents have changed, is >>>>> it hashing the contents? >>>>> >>>>> -- >>>>> 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/8eb9da33-a72f-4638-9c6d-ab01549b7fc7% >>>>> 40googlegroups.com >>>>> <https://groups.google.com/d/msgid/ansible-project/8eb9da33-a72f-4638-9c6d-ab01549b7fc7%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>> 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/eba8d552-4416-4a27-bf33- >>> 59323c747e80%40googlegroups.com >>> <https://groups.google.com/d/msgid/ansible-project/eba8d552-4416-4a27-bf33-59323c747e80%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > 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/f54c0c45-873c-4f44-b205-5e8c39a9bfc7%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/f54c0c45-873c-4f44-b205-5e8c39a9bfc7%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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/CA%2BnsWgy6renN%3DaFvpKMwm5D2%3DNuFyYuGM3GHbDAXMJrHTexW-A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
