# Failed role import to galaxy-ng

**URL:** <https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534>\
**Category:** Get Help\
**Tags:** bug, galaxy-ng\
**Created:** [October 9, 2023, 3:11am UTC](https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534 "2023-10-09T03:11:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodsch](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bodsch/32/906_2.png) [@bodsch](https://forum.ansible.com/u/bodsch)\
**Post date:** [October 9, 2023, 3:11am UTC](https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534/1 "2023-10-09T03:11:14Z")

</div>

## Bug Report

##### SUMMARY

I want to import a new version of my role into Galaxy

##### STEPS TO REPRODUCE

```auto
ansible-galaxy role import --token $(cat ~/.ansible-token) bodsch ansible-nginx
Successfully submitted import request 2051048527698290606629078391600408671
running
bodsch.nginx 0.9.0 has already been imported
  File "/venv/lib64/python3.11/site-packages/pulpcore/tasking/tasks.py", line 66, in _execute_task
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/app/galaxy_ng/app/api/v1/tasks.py", line 145, in legacy_role_import
    raise Exception(msg)

```

The latest released Tag are `0.22.3`

##### EXPECTED RESULTS

The version I specified will be imported

##### ACTUAL RESULTS

```auto
ansible-galaxy role import -vvvvvv --token $(cat ~/.ansible-token) --branch "0.22.3" bodsch ansible-nginx
ansible-galaxy [core 2.15.4]
  config file = None
  configured module search path = ['/home/bodsch/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/bodsch/.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
No config file found; using defaults
Initial connection to galaxy_server: https://galaxy.ansible.com
Opened /home/bodsch/.ansible/galaxy_token
Calling Galaxy at https://galaxy.ansible.com/api/
Found API version 'v3, pulp-v3, v1' with Galaxy server default (https://galaxy.ansible.com/api/)
Calling Galaxy at https://galaxy.ansible.com/api/v1/imports/
Successfully submitted import request 2051048026056949700847675561756079610
Calling Galaxy at https://galaxy.ansible.com/api/v1/imports?id=2051048026056949700847675561756079610
running
Calling Galaxy at https://galaxy.ansible.com/api/v1/imports?id=2051048026056949700847675561756079610
bodsch.nginx 0.9.0 has already been imported
  File "/venv/lib64/python3.11/site-packages/pulpcore/tasking/tasks.py", line 66, in _execute_task
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/app/galaxy_ng/app/api/v1/tasks.py", line 145, in legacy_role_import
    raise Exception(msg)

```

---

<div class="post-metadata">

**Author:** ![Thulium-Drake](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/thulium-drake/32/833_2.png) [@Thulium-Drake](https://forum.ansible.com/u/Thulium-Drake)\
**Post date:** [October 9, 2023, 2:41pm UTC](https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534/2 "2023-10-09T14:41:12Z")

</div>

I see the same issue, you can import a role once, if it isn’t previously known to Galaxy. As of now you can’t update roles.

Collections work fine on the other hand, but that’s probably due to it receiving an artifact to process and import…

---

<div class="post-metadata">

**Author:** ![MonolithProjects](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/monolithprojects/32/1014_2.png) [@MonolithProjects](https://forum.ansible.com/u/MonolithProjects)\
**Post date:** [October 12, 2023, 9:24am UTC](https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534/3 "2023-10-12T09:24:22Z")

</div>

I can see the same issue. It seems like the latest version which is supposed to be imported is being resolved/sorted from the github tags “alphabetically”. Like for example “1.9.5” is higher than “1.24.3” because the third character is 9 vs. 2.

```auto
ansible-galaxy role import --api-key *** --server https://galaxy.ansible.com --branch main lablabs ansible-role-rke2
Successfully submitted import request 2051670272694773312054891301182841146
running
running
lablabs.rke2 1.9.5 has already been imported
  File "/venv/lib64/python3.11/site-packages/pulpcore/tasking/tasks.py", line 66, in _execute_task
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/app/galaxy_ng/app/api/v1/tasks.py", line 145, in legacy_role_import
    raise Exception(msg)

```

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [October 12, 2023, 2:07pm UTC](https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534/4 "2023-10-12T14:07:02Z")

</div>

These issues are being fixed in [fix role imports with mismatched github\_user by jctanner · Pull Request #1925 · ansible/galaxy\_ng · GitHub](https://github.com/ansible/galaxy_ng/pull/1925)

---

<div class="post-metadata">

**Author:** ![bodsch](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bodsch/32/906_2.png) [@bodsch](https://forum.ansible.com/u/bodsch)\
**Post date:** [October 16, 2023, 3:51am UTC](https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534/5 "2023-10-16T03:51:18Z")

</div>

Thank you for the feedback!  
Is there already a date when the fix will go live?

---

<div class="post-metadata">

**Author:** ![Thulium-Drake](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/thulium-drake/32/833_2.png) [@Thulium-Drake](https://forum.ansible.com/u/Thulium-Drake)\
**Post date:** [October 24, 2023, 9:03am UTC](https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534/6 "2023-10-24T09:03:35Z")

</div>

The errors I receive on my end have changed, I now receive this:

```auto
Successfully submitted import request 2052920556269238465263671269171824387
running
namespace thulium_drake is invalid
  File "/venv/lib64/python3.11/site-packages/pulpcore/tasking/tasks.py", line 66, in _execute_task
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/app/galaxy_ng/app/api/v1/tasks.py", line 224, in legacy_role_import
    result = import_legacy_role(checkout_path, namespace.name, importer_config, logger)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/galaxy_importer/legacy_role.py", line 51, in import_legacy_role
    return _import_legacy_role(dirname, namespace, cfg, logger)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/galaxy_importer/legacy_role.py", line 57, in _import_legacy_role
    data = LegacyRoleLoader(dirname, namespace, cfg, logger).load()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/legacy_role.py", line 39, in load
    self._validate_namespace()
  File "/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/legacy_role.py", line 61, in _validate_namespace
    raise exc.ImporterError(f"namespace {self.namespace} is invalid")

```

Is that a different form of the same problem, or does this have a different cause?

---

<div class="post-metadata">

**Author:** ![ltalirz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ltalirz/32/1439_2.png) [@ltalirz](https://forum.ansible.com/u/ltalirz)\
**Post date:** [November 6, 2023, 7:39pm UTC](https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534/7 "2023-11-06T19:39:41Z")

</div>

Looks like the original issue was fixed in [fix role imports with mismatched github\_user by jctanner · Pull Request #1925 · ansible/galaxy\_ng](https://github.com/ansible/galaxy_ng/pull/1925) but it has not yet made it into a release yet?

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [November 6, 2023, 7:42pm UTC](https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534/8 "2023-11-06T19:42:48Z")

</div>

@ltalirz [galaxy.ansible.com](http://galaxy.ansible.com) is CI/CD with the master branch on [GitHub - ansible/galaxy\_ng: Galaxy NextGen](https://github.com/ansible/galaxy_ng) so we don’t actually need to make releases for new code. The patch you are referring to went to production sometime early last week or the preceding weekend.

Did you run into a problem?

---

<div class="post-metadata">

**Author:** ![ltalirz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ltalirz/32/1439_2.png) [@ltalirz](https://forum.ansible.com/u/ltalirz)\
**Post date:** [November 6, 2023, 7:50pm UTC](https://forum.ansible.com/t/failed-role-import-to-galaxy-ng/1534/9 "2023-11-06T19:50:56Z")

</div>

Thanks for the quick reply and the clarification @tannerjc !

The [symptom I see](https://github.com/dokku/ansible-dokku/actions/runs/6771491839/job/18403025764) is the same as the one in the [issue that brought me to this thread](https://github.com/robertdebock/galaxy-action/issues/12)

However, this is only at the level of the galaxy github action and it is possible that this action now fails in a different way (I don’t have verbose logs of what happens inside the action).

I’ll try uploading the role manually and report back.
