I moved my Ansible roles from GitHub to a self-hosted GitLab instance. Is there a way to specify a custom Git server when doing ansible-galaxy role import?
Thank you for your input, but I’m looking for a way to keep up-to-date what is uploaded to Ansible Galaxy, meaning as a publisher of a role, not a user.
I updated the thread topic to reflect this better.
Ah, sorry for misunderstanding, the way I plan to do this is to push mirror all role repos from GitLab to GitHub, so far I only do this for some:
And then setup GitHub actions to push to Galaxy, this part I haven’t got around to doing but I do recall seeing threads here that explain how to do this.
There is no publish option for roles, only import:
ansible-galaxy role --help
usage: ansible-galaxy role [-h] ROLE_ACTION ...
positional arguments:
ROLE_ACTION
init Initialize new role with the base structure of a role.
remove Delete roles from roles_path.
delete Removes the role from Galaxy. It does not remove or alter the actual GitHub repository.
list Show the name and version of each role installed in the roles_path.
search Search the Galaxy database by tags, platforms, author and multiple keywords.
import Import a role into a galaxy server
setup Manage the integration between Galaxy and the given source.
info View more details about a specific role.
install Install role(s) from file(s), URL(s) or Ansible Galaxy
options:
-h, --help show this help message and exit
ansible-galaxy role import --help
usage: ansible-galaxy role import [-h] [-s API_SERVER] [--token API_KEY] [-c] [--timeout TIMEOUT] [-v]
[--no-wait] [--branch REFERENCE] [--role-name ROLE_NAME] [--status]
github_user github_repo
positional arguments:
github_user GitHub username
github_repo GitHub repository
options:
-h, --help show this help message and exit
-s, --server API_SERVER
The Galaxy API server URL
--token, --api-key API_KEY
The Ansible Galaxy API key which can be found at
https://galaxy.ansible.com/me/preferences.
-c, --ignore-certs Ignore SSL certificate validation errors.
--timeout TIMEOUT The time to wait for operations against the galaxy server, defaults to 60s.
-v, --verbose Causes Ansible to print more debug messages. Adding multiple -v will increase
the verbosity, the builtin plugins currently evaluate up to -vvvvvv. A
reasonable level to start is -vvv, connection debugging might require -vvvv.
This argument may be specified multiple times.
--no-wait Don't wait for import results.
--branch REFERENCE The name of a branch to import. Defaults to the repository's default branch
(usually master)
--role-name ROLE_NAME
The name the role should have, if different than the repo name
--status Check the status of the most recent import request for given
github_user/github_repo.
As @shertel wrote you cannot import roles into Galaxy from anywhere except from GitHub. That was a design decision made a long time ago for roles (basically when Galaxy was created), and very likely won’t change.