How to enable force_basic_auth in Ansible Galaxy when installing roles?

364 views Asked by At

I have Ansible roles packed and uploaded in JFrog Artifactory. Username and password or username and identity token (passed as password) need to be provided to download files. When I download any files from Artifactory, I need to set force_basic_auth: true in the module ansible.builtin.get_url (username and password are also provided), otherwise Artifactory returns 404 error.

My problem is when I try to install the above mentioned role with ansible-galaxy, I can specify the credentials as part of the URL, but cannot set force_basic_auth: true.

My command is:

ansible-galaxy install -r requirements.yml

requirements.yml:

- src: https://<username>:<password>@artifactory.mycompany.com/artifactory/repo/namespace/component/version/component-version.tar.gz
  name: component

How could I install the role hosted in Artifactory?

I edited ansible/module_utils/urls.py to set force_basic_auth=True before making the request. That made the installation work.

Download with cUrl also works using the same URL.

curl https://<username>:<password>@artifactory.mycompany.com/artifactory/repo/namespace/component/version/component-version.tar.gz -o role.tar.gz
0

There are 0 answers