From c13fa503a171601a01cfd4681c38124590cba54a Mon Sep 17 00:00:00 2001 From: James Cassell Date: Thu, 8 Nov 2018 17:05:12 -0500 Subject: [PATCH] os_server_facts: support all_projects (#44800) * os_server_facts: support all_projects * os_server_facts: openstacksdk expects True or False, not None --- .../fragments/os-server-facts-all-projects.yaml | 4 ++++ .../modules/cloud/openstack/os_server_facts.py | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/os-server-facts-all-projects.yaml diff --git a/changelogs/fragments/os-server-facts-all-projects.yaml b/changelogs/fragments/os-server-facts-all-projects.yaml new file mode 100644 index 0000000000..4d4e81b894 --- /dev/null +++ b/changelogs/fragments/os-server-facts-all-projects.yaml @@ -0,0 +1,4 @@ +--- +minor_changes: +- os_server_facts - added all_projects option to gather server facts from all + available projects diff --git a/lib/ansible/modules/cloud/openstack/os_server_facts.py b/lib/ansible/modules/cloud/openstack/os_server_facts.py index e2a1c6988f..388a1edc9f 100644 --- a/lib/ansible/modules/cloud/openstack/os_server_facts.py +++ b/lib/ansible/modules/cloud/openstack/os_server_facts.py @@ -45,6 +45,13 @@ options: availability_zone: description: - Ignored. Present for backwards compatibility + all_projects: + description: + - Whether to list servers from all projects or just the current auth + scoped project. + type: bool + default: 'no' + version_added: "2.8" extends_documentation_fragment: openstack ''' @@ -69,8 +76,9 @@ def main(): argument_spec = openstack_full_argument_spec( server=dict(required=False), - detailed=dict(required=False, type='bool'), - filters=dict(required=False, type='dict', default=None) + detailed=dict(required=False, type='bool', default=False), + filters=dict(required=False, type='dict', default=None), + all_projects=dict(required=False, type='bool', default=False), ) module_kwargs = openstack_module_kwargs() module = AnsibleModule(argument_spec, **module_kwargs) @@ -78,7 +86,8 @@ def main(): sdk, cloud = openstack_cloud_from_module(module) try: openstack_servers = cloud.search_servers( - detailed=module.params['detailed'], filters=module.params['filters']) + detailed=module.params['detailed'], filters=module.params['filters'], + all_projects=module.params['all_projects']) if module.params['server']: # filter servers by name