# Cannot Publish Role, No Namespace Created

**URL:** <https://forum.ansible.com/t/cannot-publish-role-no-namespace-created/4851>\
**Category:** Get Help\
**Tags:** role, namespace, galaxy-ng\
**Created:** [April 9, 2024, 9:58pm UTC](https://forum.ansible.com/t/cannot-publish-role-no-namespace-created/4851 "2024-04-09T21:58:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![3n3a](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/3n3a/32/2850_2.png) [@3n3a](https://forum.ansible.com/u/3n3a)\
**Post date:** [April 9, 2024, 9:58pm UTC](https://forum.ansible.com/t/cannot-publish-role-no-namespace-created/4851/1 "2024-04-09T21:58:16Z")

</div>

Hello there.

I logged into Ansible Galaxy NG for the first time today and wanted to publish a role, but no namespace was created for my username “3n3a”.

What can i do?

---

<div class="post-metadata">

**Author:** ![atul\_mohan](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@atul\_mohan](https://forum.ansible.com/u/atul_mohan)\
**Post date:** [February 3, 2025, 6:14am UTC](https://forum.ansible.com/t/cannot-publish-role-no-namespace-created/4851/2 "2025-02-03T06:14:29Z")

</div>

Step 1: Deprecate Old Roles via API  
Use the Ansible Galaxy API to mark old roles as deprecated. Replace \<OLD\_ROLE\_NAMESPACE\>, \<OLD\_ROLE\_NAME\>, and \<API\_KEY\> with your details.

```auto
# Deprecate a role in the old namespace (e.g., `roles-ansible.gitea`)
curl -X PATCH \
  -H "Authorization: Token <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"deprecated": true}' \
  "https://galaxy.ansible.com/api/v3/content/<OLD_ROLE_NAMESPACE>/roles/<OLD_ROLE_NAME>/"

```

Step 2: Publish New Role to Desired Namespace  
Update your GitHub Actions workflow to publish the role to the l3d.gitea namespace. Ensure the meta/main.yml specifies the correct namespace.

```auto
galaxy_info:
  author: "l3d"
  namespace: "l3d" # Target namespace (e.g., `l3d.gitea`)
  role_name: "gitea"
  description: "Install and manage Gitea"
GitHub Actions Workflow (.github/workflows/publish.yml)

```

name: Publish Role to Galaxy

on:  
release:  
types: [published]

jobs:  
publish:  
runs-on: ubuntu-latest  
steps:  
- name: Checkout code  
uses: actions/checkout@v4

```
  - name: Publish Role to Galaxy
    uses: ansible/ansible-galaxy-import@v1
    with:
      galaxy-api-key: ${{ secrets.GALAXY_API_KEY_L3D }} # API key for `l3d` namespace
      namespace: "l3d" # Target namespace
      role-name: "gitea"

```

Step 3: Automate Deprecation of Old Roles  
Add a script to your repository to automatically deprecate old roles when a new version is published.

scripts/deprecate\_old\_roles.sh

```auto
#!/bin/bash

# Deprecate old roles in `roles-ansible` namespace
curl -X PATCH \
  -H "Authorization: Token $GALAXY_API_KEY_ROLES_ANSIBLE" \
  -H "Content-Type: application/json" \
  -d '{"deprecated": true}' \
  "https://galaxy.ansible.com/api/v3/content/roles-ansible/roles/gitea/"
Update GitHub Actions Workflow

```

- name: Deprecate Old Roles  
env:  
GALAXY\_API\_KEY\_ROLES\_ANSIBLE: ${{ secrets.GALAXY\_API\_KEY\_ROLES\_ANSIBLE }}  
run: |  
chmod +x ./scripts/deprecate\_old\_roles.sh  
./scripts/deprecate\_old\_roles.sh

```auto

Step 4: Redirect Users via Documentation
Update your README.md to inform users of the new namespace:

markdown
Copy
## :warning: Deprecation Notice

This role has moved to the [`l3d.gitea`](https://galaxy.ansible.com/l3d/gitea) namespace. 
Update your `requirements.yml`:

```

roles:

- src: [Ansible Galaxy](https://galaxy.ansible.com/l3d/gitea)

```auto

```
