From c08f536260bfb48fe6df17ef2a9f10f47b6ff1c9 Mon Sep 17 00:00:00 2001 From: Maxime Guyot Date: Thu, 21 Nov 2019 16:35:44 +0100 Subject: [PATCH] Add support for all_projects in OpenStack inventory module (#55965) --- ...65-add-allow-projects-in-openstack-inventory.yml | 2 ++ lib/ansible/plugins/inventory/openstack.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/55965-add-allow-projects-in-openstack-inventory.yml diff --git a/changelogs/fragments/55965-add-allow-projects-in-openstack-inventory.yml b/changelogs/fragments/55965-add-allow-projects-in-openstack-inventory.yml new file mode 100644 index 00000000000..94812067ed8 --- /dev/null +++ b/changelogs/fragments/55965-add-allow-projects-in-openstack-inventory.yml @@ -0,0 +1,2 @@ +minor_changes: + - openstack inventory plugin - add all_projects option diff --git a/lib/ansible/plugins/inventory/openstack.py b/lib/ansible/plugins/inventory/openstack.py index c7fb82327eb..0dbbbeaa10e 100644 --- a/lib/ansible/plugins/inventory/openstack.py +++ b/lib/ansible/plugins/inventory/openstack.py @@ -16,7 +16,7 @@ DOCUMENTATION = ''' - Jesse Keating short_description: OpenStack inventory source requirements: - - openstacksdk + - "openstacksdk >= 0.28" extends_documentation_fragment: - inventory_cache - constructed @@ -81,6 +81,12 @@ DOCUMENTATION = ''' inventory script's option fail_on_errors) type: bool default: 'no' + all_projects: + description: | + Lists servers from all projects + type: bool + default: 'no' + version_added: 2.10 clouds_yaml_path: description: | Override path to clouds.yaml file. If this value is given it @@ -107,6 +113,7 @@ EXAMPLES = ''' plugin: openstack expand_hostvars: yes fail_on_errors: yes +all_projects: yes ''' import collections @@ -202,9 +209,11 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): expand_hostvars = self._config_data.get('expand_hostvars', False) fail_on_errors = self._config_data.get('fail_on_errors', False) + all_projects = self._config_data.get('all_projects', False) source_data = cloud_inventory.list_hosts( - expand=expand_hostvars, fail_on_cloud_config=fail_on_errors) + expand=expand_hostvars, fail_on_cloud_config=fail_on_errors, + all_projects=all_projects) if cache_needs_update: self._cache[cache_key] = source_data