From 86298b7a47bc7d6f030ca503afa74c896686ab46 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 11 Aug 2022 14:30:00 -0500 Subject: [PATCH] Fix --role-file arg detection (#78475) * Fix --role-file arg detection. Fixes #78204 * Do not traceback, give better error * Add coverage for compound shortopts to match -r. Fixes #78491 --- .../78204-galaxy-role-file-detection.yml | 3 +++ lib/ansible/cli/galaxy.py | 18 ++++++++++++++++-- .../tasks/install.yml | 9 +++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/78204-galaxy-role-file-detection.yml diff --git a/changelogs/fragments/78204-galaxy-role-file-detection.yml b/changelogs/fragments/78204-galaxy-role-file-detection.yml new file mode 100644 index 00000000000..3659285f940 --- /dev/null +++ b/changelogs/fragments/78204-galaxy-role-file-detection.yml @@ -0,0 +1,3 @@ +bugfixes: +- ansible-galaxy - Fix detection of ``--role-file`` in arguments for implicit role invocation + (https://github.com/ansible/ansible/issues/78204) diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index b2998eab699..f11150f834d 100755 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -501,7 +501,12 @@ class GalaxyCLI(CLI): else: install_parser.add_argument('-r', '--role-file', dest='requirements', help='A file containing a list of roles to be installed.') - if self._implicit_role and ('-r' in self._raw_args or '--role-file' in self._raw_args): + + r_re = re.compile(r'^(?