Score:0

I cannot download MySQL ConnectorJ with ansible anymore

us flag

I have a task that looks like this:

- name: Download {{ mysql_connector_download_url }}
  ansible.builtin.get_url:
    url: '{{ mysql_connector_download_url }}'
    dest: '{{ mysql_connector_download_dir }}/{{ mysql_connector_download_file }}'
  register: jdbc_driver

where mysql_connector_download_url expands to https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-8.0.31.tar.gz

This has worked for quite a while but for some reason it does not anymore and the error I get is this:

    "msg": "Request failed",
    "response": "HTTP Error 403: Forbidden",
    "status_code": 403,
    "url": "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-8.0.31.tar.gz"

The odd thing is that I can type wget and the same URL on the target machine and that works fine, it is only through ansible this download fails.

I was thinking that perhaps cookies are involved but if that was the case, should not the wget fail as well?

A. Darwin avatar
my flag
It's probably a matter of user agent. What if you try wget with User-Agent ansible-httpget?
us flag
So I tried `wget -U "ansible-httpget" https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-8.0.31.tar.gz` on the target and that worked just fine. :-(
Zeitounator avatar
fr flag
This is probably related to the 302 redirection. Pointing to the redirected url (i.e. https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-j-8.0.31.tar.gz) fixes the issue. It should work with the redirection though...
us flag
I was thinking about that possibility but I had no idea as to how to get the redirected URL. Thank you for that suggestion -- I will try it out presently
Zeitounator avatar
fr flag
`I had no idea as to how to get the redirected URL` <= one solution is to just read the wget output when you download manually from the original uri.
us flag
Ah, I've never payed much attention to that output. Bad choice. Live and learn. Thank you!
Score:1
us flag

Since the file is available but hidden behind a a redirection it turned out that the easiest way is to look at the output from wget to get the file's real location and download it from there.

In this case redirects https://dev.mysql.com/get/Downloads… to https://cdn.mysql.com/Downloads… and passing that last URL to Ansible was successful.

This might of course change in the future but this solution solved the problem for me.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.