Skip to content

Commit

Permalink
[ansible-galaxy] Remove role name conversion when the repo startswith…
Browse files Browse the repository at this point in the history
… '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 d7be382)
  • Loading branch information
s-hertel committed Jan 18, 2024
1 parent 78db3a3 commit 30fa4ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 0 additions & 2 deletions lib/ansible/galaxy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,6 @@ def create_import_task(self, github_user, github_repo, reference=None, role_name
}
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']
Expand Down

0 comments on commit 30fa4ad

Please sign in to comment.