diff --git a/changelogs/fragments/fix-default-ansible-galaxy-role-import-name.yml b/changelogs/fragments/fix-default-ansible-galaxy-role-import-name.yml new file mode 100644 index 00000000000..d8ef1264d97 --- /dev/null +++ b/changelogs/fragments/fix-default-ansible-galaxy-role-import-name.yml @@ -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. diff --git a/lib/ansible/galaxy/api.py b/lib/ansible/galaxy/api.py index d4508c04123..ad340415867 100644 --- a/lib/ansible/galaxy/api.py +++ b/lib/ansible/galaxy/api.py @@ -482,8 +482,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']