# How to Import ansible role on galaxy.ansible.com

**URL:** <https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248>\
**Category:** Get Help\
**Tags:** role, namespace, galaxy-ng\
**Created:** [October 2, 2023, 11:25am UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248 "2023-10-02T11:25:35Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![L3D](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/l3d/32/911_2.png) [@L3D](https://forum.ansible.com/u/L3D)\
**Post date:** [October 2, 2023, 11:25am UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/1 "2023-10-02T11:25:35Z")

</div>

Hi everyone.

Since ansible galaxy somehow morphed into galaxy-ng, I can’t figure out how to update my ansible content there or upload new roles. It feels like ansible roles are no longer wanted or supported.

Most of the time I have been using robertdebock’s gh action from [https://github.com/marketplace/actions/publish-ansible-role-to-galaxy](https://github.com/marketplace/actions/publish-ansible-role-to-galaxy). This uses the ansible-galaxy tool.

```bash
 ansible-galaxy role import \
   --api-key ${galaxy_api_key} \
   --branch ${git_branch} \
   $(echo $GITHUB_REPOSITORY | cut -d/ -f1) \
   $(echo $GITHUB_REPOSITORY | cut -d/ -f2)

```

Unfortunately, this no longer works. I tried doing it manually via the CLI, but I cannot figure out how to work with the ``ansible-galaxy role import’’ command.

I tried updating the l3d.gopass role from [https://github.com/roles-ansible/ansible\_role\_gopass](https://github.com/roles-ansible/ansible_role_gopass.git)

```auto
ansible-galaxy role import --token (redacted) --verbose --branch main --role-name gopass roles-ansible ansible_role_gopass
No config file found; using defaults
ERROR! None (HTTP Code: 403, Message: Forbidden)

```

Does anyone have any more information on this? Do I have to put each role into a collection to get it into galaxy-ng? How do I manage the roles from my namespaces l3d (galaxy /ui/standalone/namespaces/9259/), do1jlr (galaxy /ui/standalone/namespaces/8798/) and DO1JLR (galaxy /ui/standalone/namespaces/10239/).

And why are some namespaces case sensitive and others not?

---

<div class="post-metadata">

**Author:** ![L3D](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/l3d/32/911_2.png) [@L3D](https://forum.ansible.com/u/L3D)\
**Post date:** [October 2, 2023, 12:43pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/2 "2023-10-02T12:43:23Z")

</div>

Another thought I had:

Are there different tokens for API V1 (used for ansible roles) and API V3 (used for collections). Because I am currently using the API token from [Galaxy NG](https://galaxy.ansible.com/ui/token/).

---

<div class="post-metadata">

**Author:** ![combssm](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/combssm/32/902_2.png) [@combssm](https://forum.ansible.com/u/combssm)\
**Post date:** [October 2, 2023, 2:16pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/3 "2023-10-02T14:16:03Z")

</div>

Yeah, I’m running into similar issues. I will let you know if I figure it out with the related solution.

---

<div class="post-metadata">

**Author:** ![L3D](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/l3d/32/911_2.png) [@L3D](https://forum.ansible.com/u/L3D)\
**Post date:** [October 2, 2023, 2:21pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/4 "2023-10-02T14:21:58Z")

</div>

I looked in the API and it looks like there are some options to managed roles. See  
[https://galaxy.ansible.com/api/v3/swagger-ui/#/Roles](https://galaxy.ansible.com/api/v3/swagger-ui/#/Roles)

But I did not test it, I just saw it and got distracted by other tasks…

---

<div class="post-metadata">

**Author:** ![combssm](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/combssm/32/902_2.png) [@combssm](https://forum.ansible.com/u/combssm)\
**Post date:** [October 2, 2023, 2:34pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/5 "2023-10-02T14:34:25Z")

</div>

I was able to successfully import.

Had to generate a token and create a local ansible.cfg [User Guide - Galaxy NG](https://ansible.readthedocs.io/projects/galaxy-ng/en/latest/community/userguide/#generating-an-api-token)

$ ansible-galaxy role import -vv --branch master github\_user github\_repo

---

<div class="post-metadata">

**Author:** ![L3D](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/l3d/32/911_2.png) [@L3D](https://forum.ansible.com/u/L3D)\
**Post date:** [October 2, 2023, 2:44pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/6 "2023-10-02T14:44:39Z")

</div>

Nice it worked for you.

Sadly it is still not working form me.

```auto
 $ ansible-galaxy role import -vv --branch main roles-ansible ansible_role_gopass
ansible-galaxy [core 2.15.4]
  config file = /tmp/ansible/ansible.cfg
  configured module search path = ['/home/l3d/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /tmp/ansible/venv/lib/python3.11/site-packages/ansible
  ansible collection location = /home/l3d/.ansible/collections:/usr/share/ansible/collections
  executable location = /tmp/ansible/venv/bin/ansible-galaxy
  python version = 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] (/tmp/ansible/venv/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True
Using /tmp/ansible/ansible.cfg as config file
ERROR! None (HTTP Code: 403, Message: Forbidden)

```

Maybe because my ansible roles are in a organisation and not in a user repo. 🫤

---

<div class="post-metadata">

**Author:** ![btravouillon](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/btravouillon/32/931_2.png) [@btravouillon](https://forum.ansible.com/u/btravouillon)\
**Post date:** [October 2, 2023, 6:31pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/7 "2023-10-02T18:31:49Z")

</div>

I hit a similar issue when two namespaces appeared for our roles after the migration to NG.

When I try an import, I either hit a 403 or an ugly Python exception.

I filed issue [Roles namespace has changed with the new Galaxy website · Issue #3253 · ansible/galaxy · GitHub](https://github.com/ansible/galaxy/issues/3253).

---

<div class="post-metadata">

**Author:** ![jlmitch5](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jlmitch5/32/578_2.png) [@jlmitch5](https://forum.ansible.com/u/jlmitch5)\
**Post date:** [October 2, 2023, 6:46pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/8 "2023-10-02T18:46:26Z")

</div>

Thanks for cross-posting here. We are investigating some strangeness with namespace migration right now. This report is helpful.

Investigating the import issues too @L3D, thanks for the detailed notes.

Also apologies about the issues you all are experiencing.

---

<div class="post-metadata">

**Author:** ![ryhennessy](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ryhennessy/32/978_2.png) [@ryhennessy](https://forum.ansible.com/u/ryhennessy)\
**Post date:** [October 3, 2023, 6:10pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/9 "2023-10-03T18:10:09Z")

</div>

+1 here on this issue. I am also getting the 403 Forbidden error message.

Getting the error that the token is malformed in the config file but I also get the same 403 when I specify the token as a command line option.

ansible-galaxy [core 2.13.3]  
config file = /etc/ansible/ansible.cfg  
python version = 3.9.18 (main, Aug 24 2023, 18:16:58) [Clang 15.0.0 (clang-1500.0.40.1)]  
jinja version = 3.1.2  
libyaml = True  
Using /etc/ansible/ansible.cfg as config file  
Opened /Users/ryanhennessy/.ansible/galaxy\_token  
Galaxy token file /Users/ryanhennessy/.ansible/galaxy\_token malformed, unable to read it  
ERROR! None (HTTP Code: 403, Message: Forbidden)

---

<div class="post-metadata">

**Author:** ![geoffreyvanwyk](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/geoffreyvanwyk/32/995_2.png) [@geoffreyvanwyk](https://forum.ansible.com/u/geoffreyvanwyk)\
**Post date:** [October 4, 2023, 3:34pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/10 "2023-10-04T15:34:19Z")

</div>

Did you have anything inside the ansible.cfg file?

---

<div class="post-metadata">

**Author:** ![combssm](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/combssm/32/902_2.png) [@combssm](https://forum.ansible.com/u/combssm)\
**Post date:** [October 4, 2023, 6:23pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/11 "2023-10-04T18:23:56Z")

</div>

This is what I used, but definitely copy it at your own discretion. Not 100% sure on the correctness.

```auto
$ cat ~/.ansible.cfg
[galaxy]
server_list = beta

[galaxy_server.beta]
url = https://galaxy.ansible.com/api/
token = my_token

```

---

<div class="post-metadata">

**Author:** ![ryhennessy](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ryhennessy/32/978_2.png) [@ryhennessy](https://forum.ansible.com/u/ryhennessy)\
**Post date:** [October 4, 2023, 6:40pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/12 "2023-10-04T18:40:09Z")

</div>

I had what Sean Combs suggested below in the ansible.cfg file and it did not work. I also tried with all that content commented out and that provided the same error message.

---

<div class="post-metadata">

**Author:** ![ryhennessy](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ryhennessy/32/978_2.png) [@ryhennessy](https://forum.ansible.com/u/ryhennessy)\
**Post date:** [October 5, 2023, 12:45pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/13 "2023-10-05T12:45:23Z")

</div>

Sean thanks for the update. I tried setting up everything again and now it works!

---

<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 6, 2023, 3:26am UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/14 "2023-10-06T03:26:42Z")

</div>

@L3D I believe I have fixed the problem. Assuming your github login is “DO1JLR” and the github org|user your roles are hosted in is “roles-ansible”, you should now be able to publish in the the “roles-ansible” legacy namespace.

```auto
[jtanner@corsair ~]$ curl -s https://galaxy.ansible.com/api/v1/namespaces/?name=roles-ansible | jq .
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 1858,
      "url": "",
      "summary_fields": {
        "owners": [
          {
            "id": 1884,
            "username": "DO1JLR"
          }
        ],
        "provider_namespaces": [
          {
            "id": 20264,
            "name": "roles_ansible",
            "pulp_href": "/api/pulp/api/v3/pulp_ansible/namespaces/20264/"
          }
        ]
      },
      "created": "2023-05-08T20:42:25.091016Z",
      "modified": "2023-10-06T03:22:23.211444Z",
      "name": "roles-ansible",
      "avatar_url": "https://github.com/roles-ansible.png",
      "related": {
        "provider_namespaces": null,
        "content": null,
        "owners": "/api/v1/namespaces/1858/owners/"
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![L3D](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/l3d/32/911_2.png) [@L3D](https://forum.ansible.com/u/L3D)\
**Post date:** [October 18, 2023, 4:01pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/15 "2023-10-18T16:01:20Z")

</div>

Thanks @tannerjc

Is there a way to use the “l3d” namespace instead of the “roles-ansible” namespace?

Other thing I found out: Ansible role legacy imports fails, when there is no new tag/release. It’s okay, I can work with taht. but is was different in the old galaxy.

---

<div class="post-metadata">

**Author:** ![L3D](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/l3d/32/911_2.png) [@L3D](https://forum.ansible.com/u/L3D)\
**Post date:** [October 21, 2023, 12:46am UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/16 "2023-10-21T00:46:44Z")

</div>

It still is weird with these ansible roles.

Just now I released a new version of the l3d.gitea role. See [Release v3.3.2 · roles-ansible/ansible\_role\_gitea · GitHub](https://github.com/roles-ansible/ansible_role_gitea/releases/tag/v3.3.2)

The Github Action uploaded it to ansible galaxy. At least the log is telling so:

```auto
ansible-galaxy role import --api-key *** --branch main roles-ansible ansible_role_gitea
Successfully submitted import request 2052571993052632521410160482269259626
running
role imported successfully

```

On galaxy-ng, i found two versions of this role:

```auto
https://galaxy.ansible.com/ui/standalone/roles/l3d/gitea/
https://galaxy.ansible.com/ui/standalone/roles/roles-ansible/gitea/

```

both have Version `v3.3.0` instead of `v3.3.2`.

And the UI is a little bit broken too, see:

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/c/c678f96d3768cee2bded16dfe1b1cad95b6def69.png)

If anyone has any clue what really is happening here and if my release `v3.3.2` is on galaxy-ng, please contact me. 😘

---

<div class="post-metadata">

**Author:** ![geerlingguy](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/geerlingguy/32/11288_2.png) [@geerlingguy](https://forum.ansible.com/u/geerlingguy)\
**Post date:** [October 22, 2023, 4:32am UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/17 "2023-10-22T04:32:36Z")

</div>

FYI it seems like something is a bit broken currently — I created a new / separate topic for that issue:

> [@Role import from GitHub results in "master" release, not the tag release, breaking installs](http://forum.ansible.com/t/role-import-from-github-results-in-master-release-not-the-tag-release-breaking-installs/1856/3):
>
> Some similar issues were mentioned in: Just posting for reference.

---

<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 22, 2023, 8:35pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/18 "2023-10-22T20:35:47Z")

</div>

The 404 modal shown when clicking on “versions” should be resolved by [Remove duplicate trailing slash on fetching legacy role versions and content by jctanner · Pull Request #4424 · ansible/ansible-hub-ui · GitHub](https://github.com/ansible/ansible-hub-ui/pull/4424) once merged and deployed.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 21, 2023, 8:36pm UTC](https://forum.ansible.com/t/how-to-import-ansible-role-on-galaxy-ansible-com/1248/19 "2023-11-21T20:36:19Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
