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?
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?
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.
# 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.
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
#!/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
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: