[ansible-galaxy] Remove role name conversion when the repo startswith 'ansible-role' (#82508) (#82533)

* Remove role name conversion based on whether the repo name starts with
ansible-role

This was added in 2.3 to match the Galaxy ui behavior of truncating the
'ansible-role-' prefix automatically, but the new backend requires an
alternate name to be provided or defined in the ``galaxy_info``
metadata.

Roles that were imported using the ansible-role-$name convention will
need to use ``--role-name`` or add ``role_name`` to the ``galaxy_info``
dictionary in ``meta/main.yml``.

changelog

* Update changelogs/fragments/fix-default-ansible-galaxy-role-import-name.yml

* Update changelogs/fragments/fix-default-ansible-galaxy-role-import-name.yml

Co-authored-by: flowerysong <junk+github@flowerysong.com>

---------

Co-authored-by: flowerysong <junk+github@flowerysong.com>
(cherry picked from commit d7be3824fe)
pull/82582/head
Sloane Hertel 11 months ago committed by GitHub
parent 78db3a3de6
commit 30fa4adcdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,8 @@
bugfixes:
- >-
``ansible-galaxy role import`` - fix using the ``role_name`` in a standalone role's
``galaxy_info`` metadata by disabling automatic removal of the ``ansible-role-`` prefix.
This matches the behavior of the Galaxy UI which also no longer implicitly removes the
``ansible-role-`` prefix.
Use the ``--role-name`` option or add a ``role_name`` to the ``galaxy_info`` dictionary
in the role's ``meta/main.yml`` to use an alternate role name.

@ -483,8 +483,6 @@ class GalaxyAPI:
}
if role_name:
args['alternate_role_name'] = role_name
elif github_repo.startswith('ansible-role'):
args['alternate_role_name'] = github_repo[len('ansible-role') + 1:]
data = self._call_galaxy(url, args=urlencode(args), method="POST")
if data.get('results', None):
return data['results']

Loading…
Cancel
Save