From 7ae34cef157a5e4adfbbe1d2b7f4a1edeb6068a2 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 14 Feb 2020 19:51:48 -0500 Subject: [PATCH] Fix role list regression (#67436) Add the roles_path parent to the role_parser object, so paths are passed to the list function Add basic role list tests to prevent future regressions --- changelogs/fragments/galaxy-role-list-fix.yml | 2 ++ lib/ansible/cli/galaxy.py | 2 +- test/integration/targets/ansible-galaxy/runme.sh | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/galaxy-role-list-fix.yml diff --git a/changelogs/fragments/galaxy-role-list-fix.yml b/changelogs/fragments/galaxy-role-list-fix.yml new file mode 100644 index 00000000000..1543a2b7f62 --- /dev/null +++ b/changelogs/fragments/galaxy-role-list-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-galaxy - fix regression that prenented roles from being listed diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index de3a29e24a1..a5558e27845 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -176,7 +176,7 @@ class GalaxyCLI(CLI): self.add_init_options(role_parser, parents=[common, force, offline]) self.add_remove_options(role_parser, parents=[common, roles_path]) self.add_delete_options(role_parser, parents=[common, github]) - self.add_list_options(role_parser, parents=[common]) + self.add_list_options(role_parser, parents=[common, roles_path]) self.add_search_options(role_parser, parents=[common]) self.add_import_options(role_parser, parents=[common, github]) self.add_setup_options(role_parser, parents=[common, roles_path]) diff --git a/test/integration/targets/ansible-galaxy/runme.sh b/test/integration/targets/ansible-galaxy/runme.sh index 97b04234f65..7eff3fd6b7e 100755 --- a/test/integration/targets/ansible-galaxy/runme.sh +++ b/test/integration/targets/ansible-galaxy/runme.sh @@ -107,6 +107,20 @@ EOF popd # ${galaxy_testdir} rm -fr "${galaxy_testdir}" + +# Galaxy role list test case +# +# Basic tests to ensure listing roles works + +f_ansible_galaxy_status \ + "role list" + + ansible-galaxy role list | tee out.txt + ansible-galaxy role list test-role | tee -a out.txt + + [[ $(grep -c '^- test-role' out.txt ) -eq 2 ]] + + ################################# # ansible-galaxy collection tests #################################