Ansible URI and GET_URL does not work for downloading

1,202 views
Skip to first unread message

Xinhuan Zheng

unread,
Apr 2, 2020, 5:21:35 PM4/2/20
to Ansible Project
Hello,

I need to use Ansible URI and GET_URL to download a piece of software called amanda backup server. I'm getting trouble with downloading. This is my playbook:

- name: Create cookie for later request
  uri:
    url: "https://cdn.zmanda.com/downloads/community/Amanda/3.5.1/Redhat_Enterprise_7.0/amanda-backup_server-3.5.1-1.rhel7.x86_64.rpm"
    follow_redirects: all
  register: stuff_list

- name: Debug
  debug:
    msg: "{{ stuff_list }}"

- name:  Download amanda software
  get_url:
    url: "https://cdn.zmanda.com/downloads/community/Amanda/3.5.1/Redhat_Enterprise_7.0/amanda-backup_server-3.5.1-1.rhel7.x86_64.rpm"
    headers:
      Cookie: "{{ stuff_list.cookies }}"
    dest: /mytest
 
I'm getting below errors:

TASK [amanda : Create cookie for later request] **************************************************************************************************************************
fatal: [myserver]: FAILED! => {"changed": false, "connection": "close", "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>13AAEE01DDC4B1B6</RequestId><HostId>nc/VbplLWPwS8Z43nTSicEBc+0I7cZcdnSC7XZHUp9zV1bV6ivJhN56nqtTGNOPG95iV5yKnO1Q=</HostId></Error>", "content_type": "application/xml", "date": "Thu, 02 Apr 2020 21:18:00 GMT", "elapsed": 0, "msg": "Status code was 403 and not [200]: HTTP Error 403: Forbidden", "redirected": false, "server": "AmazonS3", "status": 403, "transfer_encoding": "chunked", "url": "https://cdn.zmanda.com/downloads/community/Amanda/3.5.1/Redhat_Enterprise_7/amanda-backup_server-3.5.1-1.rhel7.x86_64.rpm", "via": "1.1 b7d10369ae737ec35cf8d7faced56ef0.cloudfront.net (CloudFront)", "x_amz_cf_id": "iOQFt0a3nEBiQp23AZEtTJVDF1WYWqCHSqxPQJjihj02ccKxvlhUNQ==", "x_amz_cf_pop": "EWR53-C2", "x_cache": "Error from cloudfront"}

Has anyone used URI and GET_URL to successfully download any software from CloudFront?

Thanks,

- Xinhuan

Kai Stian Olstad

unread,
Apr 2, 2020, 5:56:16 PM4/2/20
to ansible...@googlegroups.com
On Thu, Apr 02, 2020 at 02:21:35PM -0700, Xinhuan Zheng wrote:
> Hello,
>
> I need to use Ansible URI and GET_URL to download a piece of software
> called amanda backup server. I'm getting trouble with downloading. This is
> my playbook:
>
> - name: Create cookie for later request
> uri:
> url:
> "https://cdn.zmanda.com/downloads/community/Amanda/3.5.1/Redhat_Enterprise_7.0/amanda-backup_server-3.5.1-1.rhel7.x86_64.rpm"
> follow_redirects: all
> register: stuff_list
>
> - name: Debug
> debug:
> msg: "{{ stuff_list }}"
>
> - name: Download amanda software
> get_url:
> url:
> "https://cdn.zmanda.com/downloads/community/Amanda/3.5.1/Redhat_Enterprise_7.0/amanda-backup_server-3.5.1-1.rhel7.x86_64.rpm"
> headers:
> Cookie: "{{ stuff_list.cookies }}"
> dest: /mytest
>

<snip />

> Has anyone used URI and GET_URL to successfully download any software from
> CloudFront?

get_url without the headers work for me.

$ cat test.yml
---
- hosts: localhost
tasks:
- get_url:
url: "https://cdn.zmanda.com/downloads/community/Amanda/3.5.1/Redhat_Enterprise_7.0/amanda-backup_server-3.5.1-1.rhel7.x86_64.rpm"
dest: /tmp

$ ansible-playbook test.yml

PLAY [localhost] ************************************************************************

TASK [get_url] **************************************************************************
changed: [localhost]

PLAY RECAP ******************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0 skipped=0

$ file /tmp/amanda-backup_server-3.5.1-1.rhel7.x86_64.rpm
/tmp/amanda-backup_server-3.5.1-1.rhel7.x86_64.rpm: RPM v3.0 bin i386/x86_64


--
Kai Stian Olstad

Xinhuan Zheng

unread,
Apr 3, 2020, 7:57:17 AM4/3/20
to Ansible Project
This morning I just found my URL is missing .0 in /Redhat_Enterprise_7.0 part. Now it is working for me too. Thanks!

- Xinhuan
Reply all
Reply to author
Forward
0 new messages