From d7be3824fee7858d187b6b1933f5a25f65576578 Mon Sep 17 00:00:00 2001 From: Sloane Hertel <19572925+s-hertel@users.noreply.github.com> Date: Thu, 11 Jan 2024 14:11:56 -0500 Subject: [PATCH] [ansible-galaxy] Remove role name conversion when the repo startswith 'ansible-role' (#82508) * 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 --------- Co-authored-by: flowerysong --- .../fix-default-ansible-galaxy-role-import-name.yml | 8 ++++++++ lib/ansible/galaxy/api.py | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/fix-default-ansible-galaxy-role-import-name.yml 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']