From 9db0fb785d7be59101d9cb6ef28d08fa5e2ac467 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 31 Jan 2020 15:27:54 -0500 Subject: [PATCH] Add collections path option to ansible-galaxy (#66969) Some common code needed for 'collection list' and 'collection validate' --- .../galaxy-cli-add-collection-path-parser-arg.yaml | 2 ++ lib/ansible/cli/galaxy.py | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 changelogs/fragments/galaxy-cli-add-collection-path-parser-arg.yaml diff --git a/changelogs/fragments/galaxy-cli-add-collection-path-parser-arg.yaml b/changelogs/fragments/galaxy-cli-add-collection-path-parser-arg.yaml new file mode 100644 index 00000000000..398fb52f64b --- /dev/null +++ b/changelogs/fragments/galaxy-cli-add-collection-path-parser-arg.yaml @@ -0,0 +1,2 @@ +minor_changes: + - ansible-galaxy - add collections path argument diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index f16616d32e2..0d8ebac3d0f 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -98,6 +98,13 @@ class GalaxyCLI(CLI): help='The path to the directory containing your roles. The default is the first ' 'writable one configured via DEFAULT_ROLES_PATH: %s ' % default_roles_path) + default_collections_path = C.config.get_configuration_definition('COLLECTIONS_PATHS').get('default', '') + collections_path = opt_help.argparse.ArgumentParser(add_help=False) + collections_path.add_argument('-p', '--collections-path', dest='collections_path', type=opt_help.unfrack_path(pathsep=True), + default=C.COLLECTIONS_PATHS, action=opt_help.PrependListAction, + help='The path to the directory containing your collections. The default is the first ' + 'writable one configured via COLLECTIONS_PATHS: %s ' % default_collections_path) + # Add sub parser for the Galaxy role type (role or collection) type_parser = self.parser.add_subparsers(metavar='TYPE', dest='type') type_parser.required = True