Errors with ansible-galaxy and new galaxy.ansible.com token

same issue here, no AWX though! just ansible.

Running Ansible version 2.15.3.

error:

ansible-galaxy collection install --token <token> community.general -vvvvvvvvvvv

ERROR! Error when finding available api versions from release_galaxy (xxxx://galaxy.ansible.com/) (HTTP Code: 403, Message: Forbidden)
ansible-galaxy [core 2.15.3]
config file = /home/xxxxx/.ansible.cfg
configured module search path = [‘/home/xxxxx/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3.11/site-packages/ansible
ansible collection location = /opt/data/development/git/ansible_collections:/home/xxxxx/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-galaxy
python version = 3.11.5 (main, Sep 2 2023, 14:16:33) [GCC 13.2.1 20230801] (/usr/bin/python)
jinja version = 3.1.2
libyaml = True
Using /home/xxxxx/.ansible.cfg as config file
Starting galaxy collection install process
Process install dependency map
Initial connection to galaxy_server: xxxx://galaxy.ansible.com/
Created /home/xxxxx/.ansible/galaxy_token
Calling Galaxy at xxxx://galaxy.ansible.com/api/

The file /home/xxxxx/.ansible/galaxy_token is created when not existing and is just empty. Nothing changes when I add this to that file (hope the format is correct):

token: <token>

The <token> has been taken from my NG galaxy profile page (while I see no reason to specify a token when downloading public collections…)

on a second run the output is slightly different as it reads the token file now (which is either empty or filled manually - no it makes no diff in output if one or the other):

ansible-galaxy collection install community.general -vvvvvvvvvvv

ERROR! Error when finding available api versions from release_galaxy (xxxx://galaxy.ansible.com/) (HTTP Code: 403, Message: Forbidden)
ansible-galaxy [core 2.15.3]
config file = /home/xxxxx/.ansible.cfg
configured module search path = [‘/home/xxxxx/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3.11/site-packages/ansible
ansible collection location = /opt/data/development/git/ansible_collections:/home/xxxxx/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-galaxy
python version = 3.11.5 (main, Sep 2 2023, 14:16:33) [GCC 13.2.1 20230801] (/usr/bin/python)
jinja version = 3.1.2
libyaml = True
Using /home/xxxxx/.ansible.cfg as config file
Starting galaxy collection install process
Process install dependency map
Initial connection to galaxy_server: https://galaxy.ansible.com/
Opened /home/xxxxx/.ansible/galaxy_token
Calling Galaxy at xxxx://galaxy.ansible.com/api/

I also tried to downgrade/upgrade ansible-core to:

  • v2.13.9 → same issue
  • v2.14.1 → same issue
  • v2.14.5 → same issue
  • v2.15.4 → same issue
  • v2.13.5 → python errors incl traceback (if interested I can paste it here but I dont think that matters for this issue here)
  • 2.16.0b1 → same issue
  • devel (from today, 2023-10-03) → same issue

As I can re-produce the issue on several older Ansible releases I do not think its related to ansible but more to the galaxy api…

1 Like

A post was merged into an existing topic: AWX cannot download collections / roles from the new galaxy

unfortunately not for me (Manjaro Linux)

so… after doing a lot of other tests I finally found the reason:

my ~/.ansible.cfg contained a token=<token> line which I added for publishing a collection some time ago.

I out commented the token line and all starts working again.

before (not-working):

[galaxy]
server_list = release_galaxy

[galaxy_server.release_galaxy]
url=https://galaxy.ansible.com/api/
token=<not-NG-token>

after (working):

[galaxy]
server_list = release_galaxy

[galaxy_server.release_galaxy]
url=https://galaxy.ansible.com/api/
#token=<not-NG-token>

I assume putting in the new NG token would fix that as well. My assumption was always that using the CLI (e.g. --token <token>) would have precedence over whatever is set anywhere else but it seems not.

anyways it is solved for me now and maybe that helps someone else out there :slight_smile:

2 Likes

Command-line options are supposed to override configuration files.

This might be related to this ansible-galaxy issue. It’s not exactly the same case, as that one is using an on-prem Galaxy NG deployment and uploading a collection, but you might want to comment or create a related issue.

Let’s add the Ansible @Core team here to see if they can shed some light or confirm on creating an issue about it. Also tagged with ansible-core as this is related to the ansible-galaxy command

ps. Splitting the topic as this was unrelated to the parent.

1 Like