From 118825f4ae1c173b6f99d2cb549a38e4a1f4e031 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 17 Oct 2019 08:59:14 -0700 Subject: [PATCH] [stable-2.9] Fix ansible-galaxy --version (#63636) * [stable-2.9] Added changelog fragment (cherry picked from commit 7da37e5) Co-authored-by: Andrea Tartaglia * Fixes --version in ansible-galaxy cli (cherry picked from commit 202ad4f89ae56c63c8e29e4d45c78b648e27cfd8) --- changelogs/fragments/63628-ansible-galaxy-fix-version.yml | 2 ++ lib/ansible/cli/galaxy.py | 2 +- test/integration/targets/ansible-galaxy/runme.sh | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/63628-ansible-galaxy-fix-version.yml diff --git a/changelogs/fragments/63628-ansible-galaxy-fix-version.yml b/changelogs/fragments/63628-ansible-galaxy-fix-version.yml new file mode 100644 index 00000000000..f0353e6c6be --- /dev/null +++ b/changelogs/fragments/63628-ansible-galaxy-fix-version.yml @@ -0,0 +1,2 @@ +bugfixes: +- "ansible-galaxy cli - fixed ``--version`` argument" diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index 4963b6e7e59..ffe2074093f 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -44,7 +44,7 @@ class GalaxyCLI(CLI): def __init__(self, args): # 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: + if len(args) > 1 and args[1] not in ['-h', '--help', '--version'] 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 # 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 diff --git a/test/integration/targets/ansible-galaxy/runme.sh b/test/integration/targets/ansible-galaxy/runme.sh index 63dc2e9917a..1082bd22f40 100755 --- a/test/integration/targets/ansible-galaxy/runme.sh +++ b/test/integration/targets/ansible-galaxy/runme.sh @@ -6,6 +6,9 @@ ansible-playbook setup.yml "$@" trap 'ansible-playbook cleanup.yml' EXIT +# Very simple version test +ansible-galaxy --version + # Need a relative custom roles path for testing various scenarios of -p galaxy_relative_rolespath="my/custom/roles/path"