Ansible collection and ansible-galaxy

Problem:
Error trying to download a collection through ansible-galaxy linked to foreman repository.
It miss “https://” in the url used by api.
Used the same command on a direct internet access without problem
I modified the “collection.py” file to add https:// at the beginning of url, and it works.
Don’t know if the problem is on my foreman configuration, a bug or another problem

Expected outcome:
Download and installation of collection

Foreman and Proxy versions:
Foreman 3.3.0

Foreman and Proxy plugin versions:

Distribution and version:
Foreman 3.3.0
Katello 4.5.0
RockyLinux 8.6

Other relevant data:
`[root@MyServer tmp]# ansible-galaxy collection install -r requirements.yml -vvv
ansible-galaxy 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = [’/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible-galaxy
python version = 3.6.8 (default, Apr 12 2022, 06:55:39) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]
Using /etc/ansible/ansible.cfg as config file
Reading requirement file at ‘/tmp/requirements.yml’
Process install dependency map
Processing requirement collection ‘ovirt.ovirt’
Collection ‘ovirt.ovirt’ obtained from server explicit_requirement_ovirt.ovirt https://MyServer.mydomain.com/pulp_ansible/galaxy/DGDDI/Library/custom/Ansible_Collection/ovirt/api
Starting collection install process
Installing ‘ovirt.ovirt:2.2.3’ to ‘/root/.ansible/collections/ansible_collections/ovirt/ovirt’
Downloading MyServer.mydomain.com/pulp_ansible/galaxy/default/api/v3/plugin/ansible/content/DGDDI/Library/custom/Ansible_Collection/ovirt/collections/artifacts/ovirt-ovirt-2.2.3.tar.gz to /root/.ansible/tmp/ansible-local-491082kz6spy92/tmpo4uu0e5p
ERROR! Unexpected Exception, this is probably a bug: unknown url type: ‘MyServer.mydomain.com/pulp_ansible/galaxy/default/api/v3/plugin/ansible/content/DGDDI/Library/custom/Ansible_Collection/ovirt/collections/artifacts/ovirt-ovirt-2.2.3.tar.gz
the full traceback was:

Traceback (most recent call last):
File “/usr/bin/ansible-galaxy”, line 123, in
exit_code = cli.run()
File “/usr/lib/python3.6/site-packages/ansible/cli/galaxy.py”, line 374, in run
context.CLIARGS’func’
File “/usr/lib/python3.6/site-packages/ansible/cli/galaxy.py”, line 850, in execute_install
no_deps, force, force_deps)
File “/usr/lib/python3.6/site-packages/ansible/galaxy/collection.py”, line 470, in install_collections
collection.install(output_path, b_temp_path)
File “/usr/lib/python3.6/site-packages/ansible/galaxy/collection.py”, line 166, in install
headers=headers)
File “/usr/lib/python3.6/site-packages/ansible/galaxy/collection.py”, line 923, in _download_file
unredirected_headers=[‘Authorization’], http_agent=user_agent())
File “/usr/lib/python3.6/site-packages/ansible/module_utils/urls.py”, line 1390, in open_url
unredirected_headers=unredirected_headers)
File “/usr/lib/python3.6/site-packages/ansible/module_utils/urls.py”, line 1264, in open
request = RequestWithMethod(url, method, data)
File “/usr/lib/python3.6/site-packages/ansible/module_utils/urls.py”, line 643, in init
urllib_request.Request.init(self, url, data, headers, origin_req_host, unverifiable)
File “/usr/lib64/python3.6/urllib/request.py”, line 329, in init
self.full_url = url
File “/usr/lib64/python3.6/urllib/request.py”, line 355, in full_url
self._parse()
File “/usr/lib64/python3.6/urllib/request.py”, line 384, in _parse
raise ValueError(“unknown url type: %r” % self.full_url)
ValueError: unknown url type: ‘MyServer.mydomain.com/pulp_ansible/galaxy/default/api/v3/plugin/ansible/content/DGDDI/Library/custom/Ansible_Collection/ovirt/collections/artifacts/ovirt-ovirt-2.2.3.tar.gz
[root@MyServer tmp]#`

Thanks for the report!

I can reproduce it here on my system.

$ curl -k --silent 'https://centos8-stream-katello-4-5.tanso.example.com/pulp_ansible/galaxy/Default_Organization/Library/custom/lol/ansible/api/v3/plugin/ansible/content/Default_Organization/Library/custom/lol/ansible/collections/index/theforeman/foreman/versions/3.4.0/' | python -m json.tool  | grep download_url
    "download_url": "centos8-stream-katello-4-5.tanso.example.com/pulp_ansible/galaxy/default/api/v3/plugin/ansible/content/Default_Organization/Library/custom/lol/ansible/collections/artifacts/theforeman-foreman-3.4.0.tar.gz",

I see!

The problem is that /etc/pulp/settings.py is missing https:// in front of ANSIBLE_API_HOSTNAME. Once I changed that (in my case it now reads: ANSIBLE_API_HOSTNAME = "https://centos8-stream-katello-4-5.tanso.example.com") and restarted the pulpcore-api service, things started to work as expected.

I’ve opened Bug #35390: pulp_ansible API is wrongly configured, leading to uninstallable content - Installer - Foreman and https://github.com/theforeman/puppet-pulpcore/pull/262 to fix it properly in the installer.

2 Likes

Thanks @evgeni

I applied your modification and restarted the service.
Work perfectly now.
So wait for the correction in the future release.
Have a good day and weekend.

Regards