1

I have a task in my ansible playbook, that downloads a java archive from a github url. The task is here:

- name: Download Jar Plugin
  get_url:
    url: https://GitHub-URL/plugins-1.0.5.jar
    dest: /app/plugins/

There's no mention of checksum, yet it gives this error:

fatal: [host]: FAILED! => {"changed": false, "msg": "attempted to take checksum of directory: /app/plugins/plugins-1.0.5.jar"}

anyone has any idea about this? Is there any workaround to make it download this java archive?

SS-eth0
  • 45
  • 7

2 Answers2

0

First of all GitHub is not the right location to keep binaries. Github does not allow us to store a single file greater than 100 MB in most cases. You you should have binaries kept in either a physical server or any cloud storage and pull it from there.

Now, if you are really inclined to follow this bad practise I suggest you to create an equivalent unix curl first to do that. If you have an existing curl command to do that share that with us or simply use ansible shell module as a starting point. You can also try increasing timeouts as default is 10 secs only. Here's a snippet where timeout is set to 200 seconds.

- name: Download Jar Plugin
  get_url:
    url: https://GitHub-URL/plugins-1.0.5.jar
    dest: /app/plugins/
    timeout: 200
bosari
  • 1,922
  • 1
  • 19
  • 38
  • `curl -o /app/plugins/plugins-1.0.5.jar --create-dir https://github.com/app/plugins/plugins-1.0.5.jar` **OK** here's a sample this works with correct URL.. – SS-eth0 Feb 17 '20 at 11:50
  • 1
    @SS-eth0 try increasing the timeout as default is only 10 secs. https://docs.ansible.com/ansible/latest/modules/get_url_module.html#parameter-timeout – bosari Feb 17 '20 at 12:01
  • surprisingly setting high timeout in playbook worked, but I'm confused and can't relate to its reason. any pointer? – SS-eth0 Feb 18 '20 at 08:09
  • 1
    @SS-eth0 timeout is the period that Ansible waits to get a response from a requests. Your request's response is heasully takes more than 10 secs even from curl request, hence, increasing timeout will work. – bosari Feb 18 '20 at 10:09
0

Try adding checksum argument as below:

- name: Download Jar Plugin
  get_url:
   url: https://GitHub-URL/plugins-1.0.5.jar
   dest: /app/plugins/
   timeout: 200
   checksum: <yourchecksum>

Hope this helps as per your error.

Santosh Garole
  • 1,419
  • 13
  • 23
  • ty @Santosh for contribution, but in my case I had no checksum, just needed to download the file. – SS-eth0 Feb 18 '20 at 08:10