Ansible Galaxy’s role import enhancements and fixes for the new year.
Import logging …
Remember when you could see a nice formatted list of messages when your roles were imported? We’ve brought that back (see Role import logging by jctanner · Pull Request #1959 · ansible/galaxy_ng · GitHub)! You may have already noticed, but when you run “ansible-galaxy role import” it displays colorized messages about what the backend is doing with the role (where it’s cloning from, what lint tests pass or fail, etc). These logs are also displayed in the UI when you visit any role and click on “import log”. We implemented this back in November, but it took a little longer to get the UI changes rolled out.
Defining a role’s namespace and name …
Role import “magic”:
For those of you who had roles in the old galaxy with namespaces and names that differ from their related github user and github repo, we implementented some “magic” to route the import to the most “correct” role by namespace and name. While this feature made it possible to keep importing new versions of those roles, it still didn’t address the underlying issue that authors had no way to specify which namespace and name they wanted.
New standard keys in the meta/main.yml file:
role_name in meta/main.yml: You can now specify these keys in your meta/main.yml. This means when you’re importing a role, Galaxy will try to slot it into the namespace you’ve mentioned with the role_name you’ve specified. This makes the role less “portable” in terms of being able to import it into multiple different namespace.name configurations, but it does make the import much more predicatable for those who have namespaces or role names that are different from the github user and github repo. This feature is live in production now and ready to use. Please send us feedback if you have any!
We’ll still keep the “magic” finder code for a while, but it’s only going to trigger if the author hasn’t defined any overrides to the namespace and name.
New API changes for namespace and name:
Remember when we could use alternate-role-name in the Galaxy API? It was a nifty feature, but it got dropped a while back (see ansible/galaxy@1d1519f). Since then, the Galaxy gang has been busy bees, adding namespace support in the galaxy-importer schema (ansible/galaxy-importer@98e0931) and slipping in role_name into the legacy role schema (ansible/galaxy-importer@1927cd6).
As part of support legacy role import overrides for namespace and name. by jctanner · Pull Request #2011 · ansible/galaxy_ng · GitHub, we’ve added support in the API for alternate_namespace_name and alternate_role_name in the POST data for importing a role. If provided, the backend will use these values as the highest order of precedence for determining the namespace+name for the role, regardless of the github user or github repo the role lives in. We don’t suspect many people will use the API directly for importing roles, but the option is avaible. We do plan to use these new parameters to support future enhancements to the UI that allow role authors to import directly into a namespace and or a specific role name. That feature should get us very close to satisfying one of the biggest requests from the community so far.
We’ve built and deployed role upload components to the galaxy UI. You can now import roles from the UI and take advantage of the namespace and name override fields …