diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index 0c3d9ed33a0..2c253f91713 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -44,7 +44,9 @@ class GalaxyCLI(CLI): # Inject role into sys.argv[1] as a backwards compatibility step if len(args) > 1 and args[1] not in ['-h', '--help'] and 'role' not in args and 'collection' not in args: # TODO: Should we add a warning here and eventually deprecate the implicit role subcommand choice - args.insert(1, 'role') + # Remove this in Ansible 2.13 when we also remove -v as an option on the root parser for ansible-galaxy. + idx = 2 if args[1].startswith('-v') else 1 + args.insert(idx, 'role') self.api = None self.galaxy = None diff --git a/test/units/cli/test_galaxy.py b/test/units/cli/test_galaxy.py index 3a3da02140a..bf1a334cc15 100644 --- a/test/units/cli/test_galaxy.py +++ b/test/units/cli/test_galaxy.py @@ -469,6 +469,8 @@ class TestGalaxyInitSkeleton(unittest.TestCase, ValidRoleTests): # deprecated and tests should be removed when the code that handles it is removed (['ansible-galaxy', '-vv', 'collection', 'init', 'abc.def', '-v'], 1), (['ansible-galaxy', '-vv', 'collection', 'init', 'abc.def', '-vvvv'], 4), + (['ansible-galaxy', '-vvv', 'init', 'name'], 3), + (['ansible-galaxy', '-vvvvv', 'init', '-v', 'name'], 1), ]) def test_verbosity_arguments(cli_args, expected, monkeypatch): # Mock out the functions so we don't actually execute anything