From baf59ccaac267a7eac5dbbea5e439229e686b012 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Fri, 18 Jan 2019 06:39:24 -0500 Subject: [PATCH] Put in documented default for gcp_compute filters (#50025) --- changelogs/fragments/50025-gcp_compute_filters_default.yml | 2 ++ docs/docsite/rst/scenario_guides/guide_gce.rst | 1 - lib/ansible/plugins/inventory/gcp_compute.py | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/50025-gcp_compute_filters_default.yml diff --git a/changelogs/fragments/50025-gcp_compute_filters_default.yml b/changelogs/fragments/50025-gcp_compute_filters_default.yml new file mode 100644 index 00000000000..3b19c1401bf --- /dev/null +++ b/changelogs/fragments/50025-gcp_compute_filters_default.yml @@ -0,0 +1,2 @@ +bugfixes: + - gcp_compute inventory plugin - apply documented default when one is not provided. diff --git a/docs/docsite/rst/scenario_guides/guide_gce.rst b/docs/docsite/rst/scenario_guides/guide_gce.rst index f42eaae4629..e49b85e02f2 100644 --- a/docs/docsite/rst/scenario_guides/guide_gce.rst +++ b/docs/docsite/rst/scenario_guides/guide_gce.rst @@ -145,7 +145,6 @@ Here's an example of a valid inventory file: plugin: gcp_compute projects: - graphite-playground - filters: auth_kind: serviceaccount service_account_file: /home/alexstephen/my_account.json diff --git a/lib/ansible/plugins/inventory/gcp_compute.py b/lib/ansible/plugins/inventory/gcp_compute.py index 3be4ca5b07a..b9d648cecb4 100644 --- a/lib/ansible/plugins/inventory/gcp_compute.py +++ b/lib/ansible/plugins/inventory/gcp_compute.py @@ -337,6 +337,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): if not isinstance(config_data['projects'], list): raise AnsibleParserError("Projects must be a list in GCP inventory YAML files") + # add in documented defaults + if 'filters' not in config_data: + config_data['filters'] = None + projects = config_data['projects'] zones = config_data.get('zones') config_data['scopes'] = ['https://www.googleapis.com/auth/compute']