From dd07bdf22dee5d7a86559334fa7a71ff623898c9 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Tue, 23 Jun 2020 16:57:25 -0400 Subject: [PATCH] Fix galaxy role info bug to support multiple roles (#70148) * Add changelog fragment * Update changelog --- changelogs/fragments/70148-galaxy-role-info.yaml | 2 ++ lib/ansible/cli/galaxy.py | 4 +++- test/integration/targets/ansible-galaxy/runme.sh | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/70148-galaxy-role-info.yaml diff --git a/changelogs/fragments/70148-galaxy-role-info.yaml b/changelogs/fragments/70148-galaxy-role-info.yaml new file mode 100644 index 00000000000..602443657cb --- /dev/null +++ b/changelogs/fragments/70148-galaxy-role-info.yaml @@ -0,0 +1,2 @@ +bugfixes: + - Fixes ``ansible-galaxy role info`` to support multiple roles on the command line (https://github.com/ansible/ansible/pull/70148) diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index ba2a1a129e6..0a22298f8d2 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -653,6 +653,8 @@ class GalaxyCLI(CLI): else: text.append(u"\t%s: %s" % (k, role_info[k])) + # make sure we have a trailing newline returned + text.append(u"") return u'\n'.join(text) @staticmethod @@ -970,7 +972,7 @@ class GalaxyCLI(CLI): if role_spec: role_info.update(role_spec) - data = self._display_role_info(role_info) + data += self._display_role_info(role_info) self.pager(data) diff --git a/test/integration/targets/ansible-galaxy/runme.sh b/test/integration/targets/ansible-galaxy/runme.sh index 2cd59825bf9..b41cdbdf8fa 100755 --- a/test/integration/targets/ansible-galaxy/runme.sh +++ b/test/integration/targets/ansible-galaxy/runme.sh @@ -273,6 +273,13 @@ f_ansible_galaxy_status \ ansible-galaxy role info -p ./testroles --offline testdesc | tee out.txt grep 'description: Top level' out.txt + # test multiple role listing + ansible-galaxy role init otherrole --init-path ./testroles + ansible-galaxy role info -p ./testroles --offline testdesc otherrole | tee out.txt + grep 'Role: testdesc' out.txt + grep 'Role: otherrole' out.txt + + popd # ${role_testdir} rm -fr "${role_testdir}"