diff --git a/changelogs/fragments/ansible-galaxy-role-search-rc.yml b/changelogs/fragments/ansible-galaxy-role-search-rc.yml new file mode 100644 index 00000000000..a104f94865e --- /dev/null +++ b/changelogs/fragments/ansible-galaxy-role-search-rc.yml @@ -0,0 +1,4 @@ +bugfixes: + - >- + ``ansible-galaxy search rolename`` - give a warning instead of non-zero return code when search results are empty. + This is similar to the behavior when listing roles, which gives a warning if a role cannot be found and exits with a return code of ``0``. diff --git a/docs/docsite/rst/porting_guides/porting_guide_core_2.15.rst b/docs/docsite/rst/porting_guides/porting_guide_core_2.15.rst index 782288c1d1d..8b4478cd1e4 100644 --- a/docs/docsite/rst/porting_guides/porting_guide_core_2.15.rst +++ b/docs/docsite/rst/porting_guides/porting_guide_core_2.15.rst @@ -25,7 +25,7 @@ No notable changes Command Line ============ -No notable changes +* The return code of ``ansible-galaxy search`` is now 0 instead of 1 and the stdout is empty when results are empty to align with other ``ansible-galaxy`` commands. Deprecated diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index f4148d924db..339094e035a 100755 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -1721,8 +1721,8 @@ class GalaxyCLI(CLI): tags=context.CLIARGS['galaxy_tags'], author=context.CLIARGS['author'], page_size=page_size) if response['count'] == 0: - display.display("No roles match your search.", color=C.COLOR_ERROR) - return 1 + display.warning("No roles match your search.") + return 0 data = [u'']