OpenStack: rename _facts -> _info (#61197)

* Rename openstack _facts -> _info

* Add new module names to module_defaults.yml.
This commit is contained in:
Felix Fontein 2019-08-27 17:50:14 +02:00 committed by Sloane Hertel
parent 5e4e32b45e
commit c91929b2b3
22 changed files with 338 additions and 158 deletions

View file

@ -0,0 +1,19 @@
minor_changes:
- The ``os_flavor_facts`` module has been renamed to ``os_flavor_info``.
When called with the new name, the module no longer returns ``ansible_facts``.
- The ``os_image_facts`` module has been renamed to ``os_image_info``.
When called with the new name, the module no longer returns ``ansible_facts``.
- The ``os_keystone_domain_facts`` module has been renamed to ``os_keystone_domain_info``.
When called with the new name, the module no longer returns ``ansible_facts``.
- The ``os_networks_facts`` module has been renamed to ``os_networks_info``.
When called with the new name, the module no longer returns ``ansible_facts``.
- The ``os_port_facts`` module has been renamed to ``os_port_info``.
When called with the new name, the module no longer returns ``ansible_facts``.
- The ``os_project_facts`` module has been renamed to ``os_project_info``.
When called with the new name, the module no longer returns ``ansible_facts``.
- The ``os_server_facts`` module has been renamed to ``os_server_info``.
When called with the new name, the module no longer returns ``ansible_facts``.
- The ``os_subnets_facts`` module has been renamed to ``os_subnets_info``.
When called with the new name, the module no longer returns ``ansible_facts``.
- The ``os_user_facts`` module has been renamed to ``os_user_info``.
When called with the new name, the module no longer returns ``ansible_facts``.

View file

@ -400,6 +400,33 @@ be removed in Ansible 2.13. Please update update your playbooks accordingly.
* The ``one_image_facts`` module was renamed to :ref:`one_image_info <one_image_info_module>`.
* The ``onepassword_facts`` module was renamed to :ref:`onepassword_info <onepassword_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
* The ``os_flavor_facts`` module was renamed to :ref:`os_flavor_info <os_flavor_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`.
* The ``os_image_facts`` module was renamed to :ref:`os_image_info <os_image_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`.
* The ``os_keystone_domain_facts`` module was renamed to :ref:`os_keystone_domain_info <os_keystone_domain_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`.
* The ``os_networks_facts`` module was renamed to :ref:`os_networks_info <os_networks_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`.
* The ``os_port_facts`` module was renamed to :ref:`os_port_info <os_port_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`.
* The ``os_project_facts`` module was renamed to :ref:`os_project_info <os_project_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`.
* The ``os_server_facts`` module was renamed to :ref:`os_server_info <os_server_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`.
* The ``os_subnets_facts`` module was renamed to :ref:`os_subnets_info <os_subnets_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`.
* The ``os_user_facts`` module was renamed to :ref:`os_user_info <os_user_info_module>`.
When called with the new name, the module no longer returns ``ansible_facts``.
To access return values, :ref:`register a variable <registered_variables>`.
* The ``python_requirements_facts`` module was renamed to :ref:`python_requirements_info <python_requirements_info_module>`.
* The ``rds_instance_facts`` module was renamed to :ref:`rds_instance_info <rds_instance_info_module>`.
* The ``rds_snapshot_facts`` module was renamed to :ref:`rds_snapshot_info <rds_snapshot_info_module>`.

View file

@ -772,6 +772,8 @@ groupings:
- os
os_flavor_facts:
- os
os_flavor_info:
- os
os_floating_ip:
- os
os_group:
@ -780,6 +782,8 @@ groupings:
- os
os_image_facts:
- os
os_image_info:
- os
os_ironic:
- os
os_ironic_inspect:
@ -792,6 +796,8 @@ groupings:
- os
os_keystone_domain_facts:
- os
os_keystone_domain_info:
- os
os_keystone_endpoint:
- os
os_keystone_role:
@ -808,6 +814,8 @@ groupings:
- os
os_networks_facts:
- os
os_networks_info:
- os
os_nova_flavor:
- os
os_nova_host_aggregate:
@ -820,12 +828,16 @@ groupings:
- os
os_port_facts:
- os
os_port_info:
- os
os_project:
- os
os_project_access:
- os
os_project_facts:
- os
os_project_info:
- os
os_quota:
- os
os_recordset:
@ -842,6 +854,8 @@ groupings:
- os
os_server_facts:
- os
os_server_info:
- os
os_server_group:
- os
os_server_metadata:
@ -854,10 +868,14 @@ groupings:
- os
os_subnets_facts:
- os
os_subnets_info:
- os
os_user:
- os
os_user_facts:
- os
os_user_info:
- os
os_user_group:
- os
os_user_role:

View file

@ -0,0 +1 @@
os_flavor_info.py

View file

@ -0,0 +1 @@
os_image_info.py

View file

@ -0,0 +1 @@
os_keystone_domain_info.py

View file

@ -0,0 +1 @@
os_networks_info.py

View file

@ -0,0 +1 @@
os_port_info.py

View file

@ -0,0 +1 @@
os_project_info.py

View file

@ -0,0 +1 @@
os_server_info.py

View file

@ -0,0 +1 @@
os_subnets_info.py

View file

@ -0,0 +1 @@
os_user_info.py

View file

@ -13,21 +13,22 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
---
module: os_flavor_facts
short_description: Retrieve facts about one or more flavors
module: os_flavor_info
short_description: Retrieve information about one or more flavors
author: "David Shrewsbury (@Shrews)"
version_added: "2.1"
description:
- Retrieve facts about available OpenStack instance flavors. By default,
facts about ALL flavors are retrieved. Filters can be applied to get
facts for only matching flavors. For example, you can filter on the
- Retrieve information about available OpenStack instance flavors. By default,
information about ALL flavors are retrieved. Filters can be applied to get
information for only matching flavors. For example, you can filter on the
amount of RAM available to the flavor, or the number of virtual CPUs
available to the flavor, or both. When specifying multiple filters,
*ALL* filters must match on a flavor before that flavor is returned as
a fact.
- This module was called C(os_flavor_facts) before Ansible 2.9, returning C(ansible_facts).
Note that the M(os_flavor_info) module no longer returns C(ansible_facts)!
notes:
- This module creates a new top-level C(openstack_flavors) fact, which
contains a list of unsorted flavors.
- The result contains a list of unsorted flavors.
requirements:
- "python >= 2.7"
- "openstacksdk"
@ -75,41 +76,45 @@ extends_documentation_fragment: openstack
'''
EXAMPLES = '''
# Gather facts about all available flavors
- os_flavor_facts:
# Gather information about all available flavors
- os_flavor_info:
cloud: mycloud
register: result
# Gather facts for the flavor named "xlarge-flavor"
- os_flavor_facts:
- debug:
msg: "{{ result.openstack_flavors }}"
# Gather information for the flavor named "xlarge-flavor"
- os_flavor_info:
cloud: mycloud
name: "xlarge-flavor"
# Get all flavors that have exactly 512 MB of RAM.
- os_flavor_facts:
- os_flavor_info:
cloud: mycloud
ram: "512"
# Get all flavors that have 1024 MB or more of RAM.
- os_flavor_facts:
- os_flavor_info:
cloud: mycloud
ram: ">=1024"
# Get a single flavor that has the minimum amount of RAM. Using the 'limit'
# option will guarantee only a single flavor is returned.
- os_flavor_facts:
- os_flavor_info:
cloud: mycloud
ram: "MIN"
limit: 1
# Get all flavors with 1024 MB of RAM or more, AND exactly 2 virtual CPUs.
- os_flavor_facts:
- os_flavor_info:
cloud: mycloud
ram: ">=1024"
vcpus: "2"
# Get all flavors with 1024 MB of RAM or more, exactly 2 virtual CPUs, and
# less than 30gb of ephemeral storage.
- os_flavor_facts:
- os_flavor_info:
cloud: mycloud
ram: ">=1024"
vcpus: "2"
@ -186,6 +191,10 @@ def main():
]
)
module = AnsibleModule(argument_spec, **module_kwargs)
is_old_facts = module._name == 'os_flavor_facts'
if is_old_facts:
module.deprecate("The 'os_flavor_facts' module has been renamed to 'os_flavor_info', "
"and the renamed one no longer returns ansible_facts", version='2.13')
name = module.params['name']
vcpus = module.params['vcpus']
@ -214,8 +223,12 @@ def main():
if limit is not None:
flavors = flavors[:limit]
module.exit_json(changed=False,
ansible_facts=dict(openstack_flavors=flavors))
if is_old_facts:
module.exit_json(changed=False,
ansible_facts=dict(openstack_flavors=flavors))
else:
module.exit_json(changed=False,
openstack_flavors=flavors)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))

View file

@ -13,14 +13,14 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
module: os_image_facts
short_description: Retrieve facts about an image within OpenStack.
module: os_image_info
short_description: Retrieve information about an image within OpenStack.
version_added: "2.0"
author: "Davide Agnello (@dagnello)"
description:
- Retrieve facts about a image image from OpenStack.
notes:
- Facts are placed in the C(openstack_image) variable.
- Retrieve information about a image image from OpenStack.
- This module was called C(os_image_facts) before Ansible 2.9, returning C(ansible_facts).
Note that the M(os_image_info) module no longer returns C(ansible_facts)!
requirements:
- "python >= 2.7"
- "openstacksdk"
@ -37,31 +37,33 @@ extends_documentation_fragment: openstack
'''
EXAMPLES = '''
- name: Gather facts about a previously created image named image1
os_image_facts:
- name: Gather information about a previously created image named image1
os_image_info:
auth:
auth_url: https://identity.example.com
username: user
password: password
project_name: someproject
image: image1
register: result
- name: Show openstack facts
- name: Show openstack information
debug:
var: openstack_image
msg: "{{ result.openstack_image }}"
# Show all available Openstack images
- name: Retrieve all available Openstack images
os_image_facts:
os_image_info:
register: result
- name: Show images
debug:
var: openstack_image
msg: "{{ result.openstack_image }}"
'''
RETURN = '''
openstack_image:
description: has all the openstack facts about the image
description: has all the openstack information about the image
returned: always, but can be null
type: complex
contains:
@ -146,17 +148,27 @@ def main():
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec, **module_kwargs)
is_old_facts = module._name == 'os_image_facts'
if is_old_facts:
module.deprecate("The 'os_image_facts' module has been renamed to 'os_image_info', "
"and the renamed one no longer returns ansible_facts", version='2.13')
sdk, cloud = openstack_cloud_from_module(module)
try:
if module.params['image']:
image = cloud.get_image(module.params['image'])
module.exit_json(changed=False, ansible_facts=dict(
openstack_image=image))
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_image=image))
else:
module.exit_json(changed=False, openstack_image=image)
else:
images = cloud.list_images()
module.exit_json(changed=False, ansible_facts=dict(
openstack_image=images))
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_image=images))
else:
module.exit_json(changed=False, openstack_image=images)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))

View file

@ -13,13 +13,15 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
---
module: os_keystone_domain_facts
short_description: Retrieve facts about one or more OpenStack domains
module: os_keystone_domain_info
short_description: Retrieve information about one or more OpenStack domains
extends_documentation_fragment: openstack
version_added: "2.1"
author: "Ricardo Carrillo Cruz (@rcarrillocruz)"
description:
- Retrieve facts about a one or more OpenStack domains
- Retrieve information about a one or more OpenStack domains
- This module was called C(os_keystone_domain_facts) before Ansible 2.9, returning C(ansible_facts).
Note that the M(os_keystone_domain_info) module no longer returns C(ansible_facts)!
requirements:
- "python >= 2.7"
- "sdk"
@ -37,33 +39,36 @@ options:
'''
EXAMPLES = '''
# Gather facts about previously created domain
- os_keystone_domain_facts:
# Gather information about previously created domain
- os_keystone_domain_info:
cloud: awesomecloud
register: result
- debug:
var: openstack_domains
msg: "{{ result.openstack_domains }}"
# Gather facts about a previously created domain by name
- os_keystone_domain_facts:
# Gather information about a previously created domain by name
- os_keystone_domain_info:
cloud: awesomecloud
name: demodomain
register: result
- debug:
var: openstack_domains
msg: "{{ result.openstack_domains }}"
# Gather facts about a previously created domain with filter
- os_keystone_domain_facts:
# Gather information about a previously created domain with filter
- os_keystone_domain_info:
cloud: awesomecloud
name: demodomain
filters:
enabled: False
enabled: false
register: result
- debug:
var: openstack_domains
msg: "{{ result.openstack_domains }}"
'''
RETURN = '''
openstack_domains:
description: has all the OpenStack facts about domains
description: has all the OpenStack information about domains
returned: always, but can be null
type: complex
contains:
@ -101,6 +106,10 @@ def main():
]
)
module = AnsibleModule(argument_spec, **module_kwargs)
is_old_facts = module._name == 'os_keystone_domain_facts'
if is_old_facts:
module.deprecate("The 'os_keystone_domain_facts' module has been renamed to 'os_keystone_domain_info', "
"and the renamed one no longer returns ansible_facts", version='2.13')
sdk, opcloud = openstack_cloud_from_module(module)
try:
@ -117,8 +126,11 @@ def main():
else:
domains = opcloud.search_domains(filters)
module.exit_json(changed=False, ansible_facts=dict(
openstack_domains=domains))
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_domains=domains))
else:
module.exit_json(changed=False, openstack_domains=domains)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))

View file

@ -14,12 +14,14 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
---
module: os_networks_facts
short_description: Retrieve facts about one or more OpenStack networks.
module: os_networks_info
short_description: Retrieve information about one or more OpenStack networks.
version_added: "2.0"
author: "Davide Agnello (@dagnello)"
description:
- Retrieve facts about one or more networks from OpenStack.
- Retrieve information about one or more networks from OpenStack.
- This module was called C(os_networks_facts) before Ansible 2.9, returning C(ansible_facts).
Note that the M(os_networks_info) module no longer returns C(ansible_facts)!
requirements:
- "python >= 2.7"
- "sdk"
@ -41,34 +43,36 @@ extends_documentation_fragment: openstack
'''
EXAMPLES = '''
- name: Gather facts about previously created networks
os_networks_facts:
- name: Gather information about previously created networks
os_networks_info:
auth:
auth_url: https://identity.example.com
username: user
password: password
project_name: someproject
register: result
- name: Show openstack networks
debug:
var: openstack_networks
msg: "{{ result.openstack_networks }}"
- name: Gather facts about a previously created network by name
os_networks_facts:
- name: Gather information about a previously created network by name
os_networks_info:
auth:
auth_url: https://identity.example.com
username: user
password: password
project_name: someproject
name: network1
register: result
- name: Show openstack networks
debug:
var: openstack_networks
msg: "{{ result.openstack_networks }}"
- name: Gather facts about a previously created network with filter
- name: Gather information about a previously created network with filter
# Note: name and filters parameters are Not mutually exclusive
os_networks_facts:
os_networks_info:
auth:
auth_url: https://identity.example.com
username: user
@ -79,15 +83,16 @@ EXAMPLES = '''
subnets:
- 057d4bdf-6d4d-4728-bb0f-5ac45a6f7400
- 443d4dc0-91d4-4998-b21c-357d10433483
register: result
- name: Show openstack networks
debug:
var: openstack_networks
msg: "{{ result.openstack_networks }}"
'''
RETURN = '''
openstack_networks:
description: has all the openstack facts about the networks
description: has all the openstack information about the networks
returned: always, but can be null
type: complex
contains:
@ -128,13 +133,20 @@ def main():
filters=dict(required=False, type='dict', default=None)
)
module = AnsibleModule(argument_spec)
is_old_facts = module._name == 'os_networks_facts'
if is_old_facts:
module.deprecate("The 'os_networks_facts' module has been renamed to 'os_networks_info', "
"and the renamed one no longer returns ansible_facts", version='2.13')
sdk, cloud = openstack_cloud_from_module(module)
try:
networks = cloud.search_networks(module.params['name'],
module.params['filters'])
module.exit_json(changed=False, ansible_facts=dict(
openstack_networks=networks))
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_networks=networks))
else:
module.exit_json(changed=False, openstack_networks=networks)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))

View file

@ -13,14 +13,14 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
module: os_port_facts
short_description: Retrieve facts about ports within OpenStack.
module: os_port_info
short_description: Retrieve information about ports within OpenStack.
version_added: "2.1"
author: "David Shrewsbury (@Shrews)"
description:
- Retrieve facts about ports from OpenStack.
notes:
- Facts are placed in the C(openstack_ports) variable.
- Retrieve information about ports from OpenStack.
- This module was called C(os_port_facts) before Ansible 2.9, returning C(ansible_facts).
Note that the M(os_port_info) module no longer returns C(ansible_facts)!
requirements:
- "python >= 2.7"
- "openstacksdk"
@ -41,18 +41,22 @@ extends_documentation_fragment: openstack
'''
EXAMPLES = '''
# Gather facts about all ports
- os_port_facts:
# Gather information about all ports
- os_port_info:
cloud: mycloud
register: result
# Gather facts about a single port
- os_port_facts:
- debug:
msg: "{{ result.openstack_ports }}"
# Gather information about a single port
- os_port_info:
cloud: mycloud
port: 6140317d-e676-31e1-8a4a-b1913814a471
# Gather facts about all ports that have device_id set to a specific value
# Gather information about all ports that have device_id set to a specific value
# and with a status of ACTIVE.
- os_port_facts:
- os_port_info:
cloud: mycloud
filters:
device_id: 1038a010-3a37-4a9d-82ea-652f1da36597
@ -195,6 +199,10 @@ def main():
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec, **module_kwargs)
is_old_facts = module._name == 'os_port_facts'
if is_old_facts:
module.deprecate("The 'os_port_facts' module has been renamed to 'os_port_info', "
"and the renamed one no longer returns ansible_facts", version='2.13')
port = module.params.get('port')
filters = module.params.get('filters')
@ -202,8 +210,11 @@ def main():
sdk, cloud = openstack_cloud_from_module(module)
try:
ports = cloud.search_ports(port, filters)
module.exit_json(changed=False, ansible_facts=dict(
openstack_ports=ports))
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_ports=ports))
else:
module.exit_json(changed=False, openstack_ports=ports)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))

View file

@ -13,13 +13,15 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
---
module: os_project_facts
short_description: Retrieve facts about one or more OpenStack projects
module: os_project_info
short_description: Retrieve information about one or more OpenStack projects
extends_documentation_fragment: openstack
version_added: "2.1"
author: "Ricardo Carrillo Cruz (@rcarrillocruz)"
description:
- Retrieve facts about a one or more OpenStack projects
- Retrieve information about a one or more OpenStack projects
- This module was called C(os_project_facts) before Ansible 2.9, returning C(ansible_facts).
Note that the M(os_project_info) module no longer returns C(ansible_facts)!
requirements:
- "python >= 2.7"
- "openstacksdk"
@ -41,42 +43,46 @@ options:
'''
EXAMPLES = '''
# Gather facts about previously created projects
- os_project_facts:
# Gather information about previously created projects
- os_project_info:
cloud: awesomecloud
register: result
- debug:
var: openstack_projects
msg: "{{ result.openstack_projects }}"
# Gather facts about a previously created project by name
- os_project_facts:
# Gather information about a previously created project by name
- os_project_info:
cloud: awesomecloud
name: demoproject
register: result
- debug:
var: openstack_projects
msg: "{{ result.openstack_projects }}"
# Gather facts about a previously created project in a specific domain
- os_project_facts:
# Gather information about a previously created project in a specific domain
- os_project_info:
cloud: awesomecloud
name: demoproject
domain: admindomain
register: result
- debug:
var: openstack_projects
msg: "{{ result.openstack_projects }}"
# Gather facts about a previously created project in a specific domain with filter
- os_project_facts:
# Gather information about a previously created project in a specific domain with filter
- os_project_info:
cloud: awesomecloud
name: demoproject
domain: admindomain
filters:
enabled: False
register: result
- debug:
var: openstack_projects
msg: "{{ result.openstack_projects }}"
'''
RETURN = '''
openstack_projects:
description: has all the OpenStack facts about projects
description: has all the OpenStack information about projects
returned: always, but can be null
type: complex
contains:
@ -115,6 +121,10 @@ def main():
)
module = AnsibleModule(argument_spec)
is_old_facts = module._name == 'os_project_facts'
if is_old_facts:
module.deprecate("The 'os_project_facts' module has been renamed to 'os_project_info', "
"and the renamed one no longer returns ansible_facts", version='2.13')
sdk, opcloud = openstack_cloud_from_module(module)
try:
@ -142,8 +152,11 @@ def main():
filters['domain_id'] = domain
projects = opcloud.search_projects(name, filters)
module.exit_json(changed=False, ansible_facts=dict(
openstack_projects=projects))
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_projects=projects))
else:
module.exit_json(changed=False, openstack_projects=projects)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))

View file

@ -14,15 +14,16 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
---
module: os_server_facts
short_description: Retrieve facts about one or more compute instances
module: os_server_info
short_description: Retrieve information about one or more compute instances
author: Monty (@emonty)
version_added: "2.0"
description:
- Retrieve facts about server instances from OpenStack.
- Retrieve information about server instances from OpenStack.
- This module was called C(os_server_facts) before Ansible 2.9, returning C(ansible_facts).
Note that the M(os_server_info) module no longer returns C(ansible_facts)!
notes:
- This module creates a new top-level C(openstack_servers) fact, which
contains a list of servers.
- The result contains a list of servers.
requirements:
- "python >= 2.7"
- "openstacksdk"
@ -56,14 +57,15 @@ extends_documentation_fragment: openstack
'''
EXAMPLES = '''
# Gather facts about all servers named <web*> that are in an active state:
- os_server_facts:
# Gather information about all servers named <web*> that are in an active state:
- os_server_info:
cloud: rax-dfw
server: web*
filters:
vm_state: active
register: result
- debug:
var: openstack_servers
msg: "{{ result.openstack_servers }}"
'''
import fnmatch
@ -82,6 +84,10 @@ def main():
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec, **module_kwargs)
is_old_facts = module._name == 'os_server_facts'
if is_old_facts:
module.deprecate("The 'os_server_facts' module has been renamed to 'os_server_info', "
"and the renamed one no longer returns ansible_facts", version='2.13')
sdk, cloud = openstack_cloud_from_module(module)
try:
@ -95,8 +101,11 @@ def main():
# TODO(mordred) This is handled by sdk now
openstack_servers = [server for server in openstack_servers
if fnmatch.fnmatch(server['name'], pattern) or fnmatch.fnmatch(server['id'], pattern)]
module.exit_json(changed=False, ansible_facts=dict(
openstack_servers=openstack_servers))
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_servers=openstack_servers))
else:
module.exit_json(changed=False, openstack_servers=openstack_servers)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))

View file

@ -14,12 +14,14 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
---
module: os_subnets_facts
short_description: Retrieve facts about one or more OpenStack subnets.
module: os_subnets_info
short_description: Retrieve information about one or more OpenStack subnets.
version_added: "2.0"
author: "Davide Agnello (@dagnello)"
description:
- Retrieve facts about one or more subnets from OpenStack.
- Retrieve information about one or more subnets from OpenStack.
- This module was called C(os_subnets_facts) before Ansible 2.9, returning C(ansible_facts).
Note that the M(os_subnets_info) module no longer returns C(ansible_facts)!
requirements:
- "python >= 2.7"
- "openstacksdk"
@ -43,34 +45,36 @@ extends_documentation_fragment: openstack
'''
EXAMPLES = '''
- name: Gather facts about previously created subnets
os_subnets_facts:
- name: Gather information about previously created subnets
os_subnets_info:
auth:
auth_url: https://identity.example.com
username: user
password: password
project_name: someproject
register: result
- name: Show openstack subnets
debug:
var: openstack_subnets
msg: "{{ result.openstack_subnets }}"
- name: Gather facts about a previously created subnet by name
os_subnets_facts:
- name: Gather information about a previously created subnet by name
os_subnets_info:
auth:
auth_url: https://identity.example.com
username: user
password: password
project_name: someproject
name: subnet1
register: result
- name: Show openstack subnets
debug:
var: openstack_subnets
msg: "{{ result.openstack_subnets }}"
- name: Gather facts about a previously created subnet with filter
- name: Gather information about a previously created subnet with filter
# Note: name and filters parameters are not mutually exclusive
os_subnets_facts:
os_subnets_info:
auth:
auth_url: https://identity.example.com
username: user
@ -78,15 +82,16 @@ EXAMPLES = '''
project_name: someproject
filters:
tenant_id: 55e2ce24b2a245b09f181bf025724cbe
register: result
- name: Show openstack subnets
debug:
var: openstack_subnets
msg: "{{ result.openstack_subnets }}"
'''
RETURN = '''
openstack_subnets:
description: has all the openstack facts about the subnets
description: has all the openstack information about the subnets
returned: always, but can be null
type: complex
contains:
@ -143,13 +148,20 @@ def main():
filters=dict(required=False, type='dict', default=None)
)
module = AnsibleModule(argument_spec)
is_old_facts = module._name == 'os_subnets_facts'
if is_old_facts:
module.deprecate("The 'os_subnets_facts' module has been renamed to 'os_subnets_info', "
"and the renamed one no longer returns ansible_facts", version='2.13')
sdk, cloud = openstack_cloud_from_module(module)
try:
subnets = cloud.search_subnets(module.params['name'],
module.params['filters'])
module.exit_json(changed=False, ansible_facts=dict(
openstack_subnets=subnets))
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_subnets=subnets))
else:
module.exit_json(changed=False, openstack_subnets=subnets)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))

View file

@ -13,13 +13,15 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = '''
---
module: os_user_facts
short_description: Retrieve facts about one or more OpenStack users
module: os_user_info
short_description: Retrieve information about one or more OpenStack users
extends_documentation_fragment: openstack
version_added: "2.1"
author: "Ricardo Carrillo Cruz (@rcarrillocruz)"
description:
- Retrieve facts about a one or more OpenStack users
- Retrieve information about a one or more OpenStack users
- This module was called C(os_user_facts) before Ansible 2.9, returning C(ansible_facts).
Note that the M(os_user_info) module no longer returns C(ansible_facts)!
requirements:
- "python >= 2.7"
- "openstacksdk"
@ -41,42 +43,46 @@ options:
'''
EXAMPLES = '''
# Gather facts about previously created users
- os_user_facts:
# Gather information about previously created users
- os_user_info:
cloud: awesomecloud
register: result
- debug:
var: openstack_users
msg: "{{ result.openstack_users }}"
# Gather facts about a previously created user by name
- os_user_facts:
# Gather information about a previously created user by name
- os_user_info:
cloud: awesomecloud
name: demouser
register: result
- debug:
var: openstack_users
msg: "{{ result.openstack_users }}"
# Gather facts about a previously created user in a specific domain
- os_user_facts:
# Gather information about a previously created user in a specific domain
- os_user_info:
cloud: awesomecloud
name: demouser
domain: admindomain
register: result
- debug:
var: openstack_users
msg: "{{ result.openstack_users }}"
# Gather facts about a previously created user in a specific domain with filter
- os_user_facts:
# Gather information about a previously created user in a specific domain with filter
- os_user_info:
cloud: awesomecloud
name: demouser
domain: admindomain
filters:
enabled: False
register: result
- debug:
var: openstack_users
msg: "{{ result.openstack_users }}"
'''
RETURN = '''
openstack_users:
description: has all the OpenStack facts about users
description: has all the OpenStack information about users
returned: always, but can be null
type: complex
contains:
@ -123,6 +129,10 @@ def main():
)
module = AnsibleModule(argument_spec)
is_old_facts = module._name == 'os_user_facts'
if is_old_facts:
module.deprecate("The 'os_user_facts' module has been renamed to 'os_user_info', "
"and the renamed one no longer returns ansible_facts", version='2.13')
sdk, opcloud = openstack_cloud_from_module(module)
try:
@ -150,8 +160,11 @@ def main():
filters['domain_id'] = domain
users = opcloud.search_users(name, filters)
module.exit_json(changed=False, ansible_facts=dict(
openstack_users=users))
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_users=users))
else:
module.exit_json(changed=False, openstack_users=users)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))

View file

@ -1602,17 +1602,17 @@ lib/ansible/modules/cloud/openstack/os_coe_cluster.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_coe_cluster.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_coe_cluster_template.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_coe_cluster_template.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_flavor_facts.py validate-modules:E324
lib/ansible/modules/cloud/openstack/os_flavor_facts.py validate-modules:E335
lib/ansible/modules/cloud/openstack/os_flavor_facts.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_flavor_facts.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_flavor_info.py validate-modules:E324
lib/ansible/modules/cloud/openstack/os_flavor_info.py validate-modules:E335
lib/ansible/modules/cloud/openstack/os_flavor_info.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_flavor_info.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_floating_ip.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_group.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_image.py validate-modules:E324
lib/ansible/modules/cloud/openstack/os_image.py validate-modules:E326
lib/ansible/modules/cloud/openstack/os_image.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_image.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_image_facts.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_image_info.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_ironic.py validate-modules:E322
lib/ansible/modules/cloud/openstack/os_ironic.py validate-modules:E323
lib/ansible/modules/cloud/openstack/os_ironic.py validate-modules:E326
@ -1627,8 +1627,8 @@ lib/ansible/modules/cloud/openstack/os_ironic_node.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_ironic_node.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_keypair.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_keystone_domain.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_keystone_domain_facts.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_keystone_domain_facts.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_keystone_domain_info.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_keystone_domain_info.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_keystone_endpoint.py validate-modules:E322
lib/ansible/modules/cloud/openstack/os_keystone_endpoint.py validate-modules:E326
lib/ansible/modules/cloud/openstack/os_keystone_endpoint.py validate-modules:E337
@ -1643,8 +1643,8 @@ lib/ansible/modules/cloud/openstack/os_member.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_member.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_network.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_network.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_networks_facts.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_networks_facts.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_networks_info.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_networks_info.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_nova_flavor.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_nova_flavor.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_nova_host_aggregate.py validate-modules:E337
@ -1653,13 +1653,13 @@ lib/ansible/modules/cloud/openstack/os_object.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_pool.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_port.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_port.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_port_facts.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_port_facts.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_port_info.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_port_info.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_project.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_project_access.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_project_access.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_project_facts.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_project_facts.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_project_info.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_project_info.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_quota.py validate-modules:E322
lib/ansible/modules/cloud/openstack/os_quota.py validate-modules:E323
lib/ansible/modules/cloud/openstack/os_quota.py validate-modules:E326
@ -1678,8 +1678,8 @@ lib/ansible/modules/cloud/openstack/os_server.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_server.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_server_action.py validate-modules:E324
lib/ansible/modules/cloud/openstack/os_server_action.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_server_facts.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_server_facts.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_server_info.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_server_info.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_server_group.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_server_group.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_server_metadata.py validate-modules:E337
@ -1691,12 +1691,12 @@ lib/ansible/modules/cloud/openstack/os_stack.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_subnet.py validate-modules:E326
lib/ansible/modules/cloud/openstack/os_subnet.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_subnet.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_subnets_facts.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_subnets_facts.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_subnets_info.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_subnets_info.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_user.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_user.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_user_facts.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_user_facts.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_user_info.py validate-modules:E337
lib/ansible/modules/cloud/openstack/os_user_info.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_user_group.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_user_role.py validate-modules:E338
lib/ansible/modules/cloud/openstack/os_volume.py validate-modules:E322