mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Remove openstack modules (#15)
These went to the openstack collection instead.
This commit is contained in:
parent
0ffe9fa6c4
commit
2728cfe59d
19 changed files with 0 additions and 1624 deletions
27
.github/BOTMETA.yml
vendored
27
.github/BOTMETA.yml
vendored
|
@ -655,33 +655,6 @@ files:
|
||||||
$modules/cloud/opennebula/one_vm.py:
|
$modules/cloud/opennebula/one_vm.py:
|
||||||
authors: ilicmilan meerkampdvv
|
authors: ilicmilan meerkampdvv
|
||||||
maintainers: rsmontero xorel
|
maintainers: rsmontero xorel
|
||||||
$modules/cloud/openstack/_os_flavor_facts.py:
|
|
||||||
authors: Shrews
|
|
||||||
maintainers: cloudnull dagnello emonty gtema juliakreger mnaser odyssey4me rcarrillocruz
|
|
||||||
$modules/cloud/openstack/_os_image_facts.py:
|
|
||||||
authors: dagnello
|
|
||||||
maintainers: Shrews cloudnull emonty gtema juliakreger mnaser odyssey4me rcarrillocruz
|
|
||||||
$modules/cloud/openstack/_os_keystone_domain_facts.py:
|
|
||||||
authors: rcarrillocruz
|
|
||||||
maintainers: Shrews cloudnull dagnello emonty gtema juliakreger mnaser odyssey4me
|
|
||||||
$modules/cloud/openstack/_os_networks_facts.py:
|
|
||||||
authors: dagnello
|
|
||||||
maintainers: Shrews cloudnull emonty gtema juliakreger mnaser odyssey4me rcarrillocruz
|
|
||||||
$modules/cloud/openstack/_os_port_facts.py:
|
|
||||||
authors: Shrews
|
|
||||||
maintainers: cloudnull dagnello emonty gtema juliakreger mnaser odyssey4me rcarrillocruz
|
|
||||||
$modules/cloud/openstack/_os_project_facts.py:
|
|
||||||
authors: rcarrillocruz
|
|
||||||
maintainers: Shrews cloudnull dagnello emonty gtema juliakreger mnaser odyssey4me
|
|
||||||
$modules/cloud/openstack/_os_server_facts.py:
|
|
||||||
authors: emonty
|
|
||||||
maintainers: Shrews cloudnull dagnello gtema juliakreger mnaser odyssey4me rcarrillocruz
|
|
||||||
$modules/cloud/openstack/_os_subnets_facts.py:
|
|
||||||
authors: dagnello
|
|
||||||
maintainers: Shrews cloudnull emonty gtema juliakreger mnaser odyssey4me rcarrillocruz
|
|
||||||
$modules/cloud/openstack/_os_user_facts.py:
|
|
||||||
authors: rcarrillocruz
|
|
||||||
maintainers: Shrews cloudnull dagnello emonty gtema juliakreger mnaser odyssey4me
|
|
||||||
$modules/cloud/oracle/oci_vcn.py:
|
$modules/cloud/oracle/oci_vcn.py:
|
||||||
authors: rohitChaware
|
authors: rohitChaware
|
||||||
maintainers: $team_oracle
|
maintainers: $team_oracle
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
os_flavor_info.py
|
|
|
@ -1,238 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# Copyright (c) 2015 IBM
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
|
||||||
module: os_flavor_info
|
|
||||||
short_description: Retrieve information about one or more flavors
|
|
||||||
author: "David Shrewsbury (@Shrews)"
|
|
||||||
description:
|
|
||||||
- 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:
|
|
||||||
- The result contains a list of unsorted flavors.
|
|
||||||
requirements:
|
|
||||||
- "python >= 2.7"
|
|
||||||
- "openstacksdk"
|
|
||||||
options:
|
|
||||||
name:
|
|
||||||
description:
|
|
||||||
- A flavor name. Cannot be used with I(ram) or I(vcpus) or I(ephemeral).
|
|
||||||
ram:
|
|
||||||
description:
|
|
||||||
- "A string used for filtering flavors based on the amount of RAM
|
|
||||||
(in MB) desired. This string accepts the following special values:
|
|
||||||
'MIN' (return flavors with the minimum amount of RAM), and 'MAX'
|
|
||||||
(return flavors with the maximum amount of RAM)."
|
|
||||||
|
|
||||||
- "A specific amount of RAM may also be specified. Any flavors with this
|
|
||||||
exact amount of RAM will be returned."
|
|
||||||
|
|
||||||
- "A range of acceptable RAM may be given using a special syntax. Simply
|
|
||||||
prefix the amount of RAM with one of these acceptable range values:
|
|
||||||
'<', '>', '<=', '>='. These values represent less than, greater than,
|
|
||||||
less than or equal to, and greater than or equal to, respectively."
|
|
||||||
type: bool
|
|
||||||
default: 'no'
|
|
||||||
vcpus:
|
|
||||||
description:
|
|
||||||
- A string used for filtering flavors based on the number of virtual
|
|
||||||
CPUs desired. Format is the same as the I(ram) parameter.
|
|
||||||
type: bool
|
|
||||||
default: 'no'
|
|
||||||
limit:
|
|
||||||
description:
|
|
||||||
- Limits the number of flavors returned. All matching flavors are
|
|
||||||
returned by default.
|
|
||||||
ephemeral:
|
|
||||||
description:
|
|
||||||
- A string used for filtering flavors based on the amount of ephemeral
|
|
||||||
storage. Format is the same as the I(ram) parameter
|
|
||||||
type: bool
|
|
||||||
default: 'no'
|
|
||||||
availability_zone:
|
|
||||||
description:
|
|
||||||
- Ignored. Present for backwards compatibility
|
|
||||||
extends_documentation_fragment:
|
|
||||||
- openstack.cloud.openstack
|
|
||||||
|
|
||||||
'''
|
|
||||||
|
|
||||||
EXAMPLES = '''
|
|
||||||
# Gather information about all available flavors
|
|
||||||
- os_flavor_info:
|
|
||||||
cloud: mycloud
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- 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_info:
|
|
||||||
cloud: mycloud
|
|
||||||
ram: "512"
|
|
||||||
|
|
||||||
# Get all flavors that have 1024 MB or more of RAM.
|
|
||||||
- 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_info:
|
|
||||||
cloud: mycloud
|
|
||||||
ram: "MIN"
|
|
||||||
limit: 1
|
|
||||||
|
|
||||||
# Get all flavors with 1024 MB of RAM or more, AND exactly 2 virtual CPUs.
|
|
||||||
- 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_info:
|
|
||||||
cloud: mycloud
|
|
||||||
ram: ">=1024"
|
|
||||||
vcpus: "2"
|
|
||||||
ephemeral: "<30"
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
RETURN = '''
|
|
||||||
openstack_flavors:
|
|
||||||
description: Dictionary describing the flavors.
|
|
||||||
returned: On success.
|
|
||||||
type: complex
|
|
||||||
contains:
|
|
||||||
id:
|
|
||||||
description: Flavor ID.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "515256b8-7027-4d73-aa54-4e30a4a4a339"
|
|
||||||
name:
|
|
||||||
description: Flavor name.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "tiny"
|
|
||||||
disk:
|
|
||||||
description: Size of local disk, in GB.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
sample: 10
|
|
||||||
ephemeral:
|
|
||||||
description: Ephemeral space size, in GB.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
sample: 10
|
|
||||||
ram:
|
|
||||||
description: Amount of memory, in MB.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
sample: 1024
|
|
||||||
swap:
|
|
||||||
description: Swap space size, in MB.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
sample: 100
|
|
||||||
vcpus:
|
|
||||||
description: Number of virtual CPUs.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
sample: 2
|
|
||||||
is_public:
|
|
||||||
description: Make flavor accessible to the public.
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
sample: true
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
argument_spec = openstack_full_argument_spec(
|
|
||||||
name=dict(required=False, default=None),
|
|
||||||
ram=dict(required=False, default=None),
|
|
||||||
vcpus=dict(required=False, default=None),
|
|
||||||
limit=dict(required=False, default=None, type='int'),
|
|
||||||
ephemeral=dict(required=False, default=None),
|
|
||||||
)
|
|
||||||
module_kwargs = openstack_module_kwargs(
|
|
||||||
mutually_exclusive=[
|
|
||||||
['name', 'ram'],
|
|
||||||
['name', 'vcpus'],
|
|
||||||
['name', 'ephemeral']
|
|
||||||
]
|
|
||||||
)
|
|
||||||
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']
|
|
||||||
ram = module.params['ram']
|
|
||||||
ephemeral = module.params['ephemeral']
|
|
||||||
limit = module.params['limit']
|
|
||||||
|
|
||||||
filters = {}
|
|
||||||
if vcpus:
|
|
||||||
filters['vcpus'] = vcpus
|
|
||||||
if ram:
|
|
||||||
filters['ram'] = ram
|
|
||||||
if ephemeral:
|
|
||||||
filters['ephemeral'] = ephemeral
|
|
||||||
|
|
||||||
sdk, cloud = openstack_cloud_from_module(module)
|
|
||||||
try:
|
|
||||||
if name:
|
|
||||||
flavors = cloud.search_flavors(filters={'name': name})
|
|
||||||
|
|
||||||
else:
|
|
||||||
flavors = cloud.list_flavors()
|
|
||||||
if filters:
|
|
||||||
flavors = cloud.range_search(flavors, filters)
|
|
||||||
|
|
||||||
if limit is not None:
|
|
||||||
flavors = flavors[:limit]
|
|
||||||
|
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1 +0,0 @@
|
||||||
os_image_info.py
|
|
|
@ -1,196 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
module: os_image_info
|
|
||||||
short_description: Retrieve information about an image within OpenStack.
|
|
||||||
author: "Davide Agnello (@dagnello)"
|
|
||||||
description:
|
|
||||||
- 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"
|
|
||||||
options:
|
|
||||||
image:
|
|
||||||
description:
|
|
||||||
- Name or ID of the image
|
|
||||||
required: false
|
|
||||||
properties:
|
|
||||||
description:
|
|
||||||
- Dict of properties of the images used for query
|
|
||||||
type: dict
|
|
||||||
required: false
|
|
||||||
availability_zone:
|
|
||||||
description:
|
|
||||||
- Ignored. Present for backwards compatibility
|
|
||||||
required: false
|
|
||||||
extends_documentation_fragment:
|
|
||||||
- openstack.cloud.openstack
|
|
||||||
|
|
||||||
'''
|
|
||||||
|
|
||||||
EXAMPLES = '''
|
|
||||||
- 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 information
|
|
||||||
debug:
|
|
||||||
msg: "{{ result.openstack_image }}"
|
|
||||||
|
|
||||||
# Show all available Openstack images
|
|
||||||
- name: Retrieve all available Openstack images
|
|
||||||
os_image_info:
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- name: Show images
|
|
||||||
debug:
|
|
||||||
msg: "{{ result.openstack_image }}"
|
|
||||||
|
|
||||||
# Show images matching requested properties
|
|
||||||
- name: Retrieve images having properties with desired values
|
|
||||||
os_image_facts:
|
|
||||||
properties:
|
|
||||||
some_property: some_value
|
|
||||||
OtherProp: OtherVal
|
|
||||||
|
|
||||||
- name: Show images
|
|
||||||
debug:
|
|
||||||
msg: "{{ result.openstack_image }}"
|
|
||||||
'''
|
|
||||||
|
|
||||||
RETURN = '''
|
|
||||||
openstack_image:
|
|
||||||
description: has all the openstack information about the image
|
|
||||||
returned: always, but can be null
|
|
||||||
type: complex
|
|
||||||
contains:
|
|
||||||
id:
|
|
||||||
description: Unique UUID.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
name:
|
|
||||||
description: Name given to the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
status:
|
|
||||||
description: Image status.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
created_at:
|
|
||||||
description: Image created at timestamp.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
deleted:
|
|
||||||
description: Image deleted flag.
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
container_format:
|
|
||||||
description: Container format of the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
min_ram:
|
|
||||||
description: Min amount of RAM required for this image.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
disk_format:
|
|
||||||
description: Disk format of the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
updated_at:
|
|
||||||
description: Image updated at timestamp.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
properties:
|
|
||||||
description: Additional properties associated with the image.
|
|
||||||
returned: success
|
|
||||||
type: dict
|
|
||||||
min_disk:
|
|
||||||
description: Min amount of disk space required for this image.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
protected:
|
|
||||||
description: Image protected flag.
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
checksum:
|
|
||||||
description: Checksum for the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
owner:
|
|
||||||
description: Owner for the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
is_public:
|
|
||||||
description: Is public flag of the image.
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
deleted_at:
|
|
||||||
description: Image deleted at timestamp.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
size:
|
|
||||||
description: Size of the image.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
'''
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
argument_spec = openstack_full_argument_spec(
|
|
||||||
image=dict(required=False),
|
|
||||||
properties=dict(default=None, type='dict'),
|
|
||||||
)
|
|
||||||
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'])
|
|
||||||
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.search_images(filters=module.params['properties'])
|
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1 +0,0 @@
|
||||||
os_keystone_domain_info.py
|
|
|
@ -1,141 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# Copyright (c) 2016 Hewlett-Packard Enterprise Corporation
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
|
||||||
module: os_keystone_domain_info
|
|
||||||
short_description: Retrieve information about one or more OpenStack domains
|
|
||||||
extends_documentation_fragment:
|
|
||||||
- openstack.cloud.openstack
|
|
||||||
|
|
||||||
author: "Ricardo Carrillo Cruz (@rcarrillocruz)"
|
|
||||||
description:
|
|
||||||
- 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"
|
|
||||||
options:
|
|
||||||
name:
|
|
||||||
description:
|
|
||||||
- Name or ID of the domain
|
|
||||||
filters:
|
|
||||||
description:
|
|
||||||
- A dictionary of meta data to use for further filtering. Elements of
|
|
||||||
this dictionary may be additional dictionaries.
|
|
||||||
availability_zone:
|
|
||||||
description:
|
|
||||||
- Ignored. Present for backwards compatibility
|
|
||||||
'''
|
|
||||||
|
|
||||||
EXAMPLES = '''
|
|
||||||
# Gather information about previously created domain
|
|
||||||
- os_keystone_domain_info:
|
|
||||||
cloud: awesomecloud
|
|
||||||
register: result
|
|
||||||
- debug:
|
|
||||||
msg: "{{ result.openstack_domains }}"
|
|
||||||
|
|
||||||
# Gather information about a previously created domain by name
|
|
||||||
- os_keystone_domain_info:
|
|
||||||
cloud: awesomecloud
|
|
||||||
name: demodomain
|
|
||||||
register: result
|
|
||||||
- debug:
|
|
||||||
msg: "{{ result.openstack_domains }}"
|
|
||||||
|
|
||||||
# Gather information about a previously created domain with filter
|
|
||||||
- os_keystone_domain_info:
|
|
||||||
cloud: awesomecloud
|
|
||||||
name: demodomain
|
|
||||||
filters:
|
|
||||||
enabled: false
|
|
||||||
register: result
|
|
||||||
- debug:
|
|
||||||
msg: "{{ result.openstack_domains }}"
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
RETURN = '''
|
|
||||||
openstack_domains:
|
|
||||||
description: has all the OpenStack information about domains
|
|
||||||
returned: always, but can be null
|
|
||||||
type: complex
|
|
||||||
contains:
|
|
||||||
id:
|
|
||||||
description: Unique UUID.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
name:
|
|
||||||
description: Name given to the domain.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
description:
|
|
||||||
description: Description of the domain.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
enabled:
|
|
||||||
description: Flag to indicate if the domain is enabled.
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
'''
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
argument_spec = openstack_full_argument_spec(
|
|
||||||
name=dict(required=False, default=None),
|
|
||||||
filters=dict(required=False, type='dict', default=None),
|
|
||||||
)
|
|
||||||
module_kwargs = openstack_module_kwargs(
|
|
||||||
mutually_exclusive=[
|
|
||||||
['name', 'filters'],
|
|
||||||
]
|
|
||||||
)
|
|
||||||
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:
|
|
||||||
name = module.params['name']
|
|
||||||
filters = module.params['filters']
|
|
||||||
|
|
||||||
if name:
|
|
||||||
# Let's suppose user is passing domain ID
|
|
||||||
try:
|
|
||||||
domains = opcloud.get_domain(name)
|
|
||||||
except Exception:
|
|
||||||
domains = opcloud.search_domains(filters={'name': name})
|
|
||||||
|
|
||||||
else:
|
|
||||||
domains = opcloud.search_domains(filters)
|
|
||||||
|
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1 +0,0 @@
|
||||||
os_networks_info.py
|
|
|
@ -1,158 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
|
||||||
module: os_networks_info
|
|
||||||
short_description: Retrieve information about one or more OpenStack networks.
|
|
||||||
author: "Davide Agnello (@dagnello)"
|
|
||||||
description:
|
|
||||||
- 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"
|
|
||||||
options:
|
|
||||||
name:
|
|
||||||
description:
|
|
||||||
- Name or ID of the Network
|
|
||||||
required: false
|
|
||||||
filters:
|
|
||||||
description:
|
|
||||||
- A dictionary of meta data to use for further filtering. Elements of
|
|
||||||
this dictionary may be additional dictionaries.
|
|
||||||
required: false
|
|
||||||
availability_zone:
|
|
||||||
description:
|
|
||||||
- Ignored. Present for backwards compatibility
|
|
||||||
required: false
|
|
||||||
extends_documentation_fragment:
|
|
||||||
- openstack.cloud.openstack
|
|
||||||
|
|
||||||
'''
|
|
||||||
|
|
||||||
EXAMPLES = '''
|
|
||||||
- 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:
|
|
||||||
msg: "{{ result.openstack_networks }}"
|
|
||||||
|
|
||||||
- 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:
|
|
||||||
msg: "{{ result.openstack_networks }}"
|
|
||||||
|
|
||||||
- name: Gather information about a previously created network with filter
|
|
||||||
# Note: name and filters parameters are Not mutually exclusive
|
|
||||||
os_networks_info:
|
|
||||||
auth:
|
|
||||||
auth_url: https://identity.example.com
|
|
||||||
username: user
|
|
||||||
password: password
|
|
||||||
project_name: someproject
|
|
||||||
filters:
|
|
||||||
tenant_id: 55e2ce24b2a245b09f181bf025724cbe
|
|
||||||
subnets:
|
|
||||||
- 057d4bdf-6d4d-4728-bb0f-5ac45a6f7400
|
|
||||||
- 443d4dc0-91d4-4998-b21c-357d10433483
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- name: Show openstack networks
|
|
||||||
debug:
|
|
||||||
msg: "{{ result.openstack_networks }}"
|
|
||||||
'''
|
|
||||||
|
|
||||||
RETURN = '''
|
|
||||||
openstack_networks:
|
|
||||||
description: has all the openstack information about the networks
|
|
||||||
returned: always, but can be null
|
|
||||||
type: complex
|
|
||||||
contains:
|
|
||||||
id:
|
|
||||||
description: Unique UUID.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
name:
|
|
||||||
description: Name given to the network.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
status:
|
|
||||||
description: Network status.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
subnets:
|
|
||||||
description: Subnet(s) included in this network.
|
|
||||||
returned: success
|
|
||||||
type: list
|
|
||||||
elements: str
|
|
||||||
tenant_id:
|
|
||||||
description: Tenant id associated with this network.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
shared:
|
|
||||||
description: Network shared flag.
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
'''
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec, openstack_cloud_from_module
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
argument_spec = openstack_full_argument_spec(
|
|
||||||
name=dict(required=False, default=None),
|
|
||||||
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'])
|
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1 +0,0 @@
|
||||||
os_port_info.py
|
|
|
@ -1,225 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# Copyright (c) 2016 IBM
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
module: os_port_info
|
|
||||||
short_description: Retrieve information about ports within OpenStack.
|
|
||||||
author: "David Shrewsbury (@Shrews)"
|
|
||||||
description:
|
|
||||||
- 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"
|
|
||||||
options:
|
|
||||||
port:
|
|
||||||
description:
|
|
||||||
- Unique name or ID of a port.
|
|
||||||
filters:
|
|
||||||
description:
|
|
||||||
- A dictionary of meta data to use for further filtering. Elements
|
|
||||||
of this dictionary will be matched against the returned port
|
|
||||||
dictionaries. Matching is currently limited to strings within
|
|
||||||
the port dictionary, or strings within nested dictionaries.
|
|
||||||
availability_zone:
|
|
||||||
description:
|
|
||||||
- Ignored. Present for backwards compatibility
|
|
||||||
extends_documentation_fragment:
|
|
||||||
- openstack.cloud.openstack
|
|
||||||
|
|
||||||
'''
|
|
||||||
|
|
||||||
EXAMPLES = '''
|
|
||||||
# Gather information about all ports
|
|
||||||
- os_port_info:
|
|
||||||
cloud: mycloud
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- debug:
|
|
||||||
msg: "{{ result.openstack_ports }}"
|
|
||||||
|
|
||||||
# Gather information about a single port
|
|
||||||
- os_port_info:
|
|
||||||
cloud: mycloud
|
|
||||||
port: 6140317d-e676-31e1-8a4a-b1913814a471
|
|
||||||
|
|
||||||
# Gather information about all ports that have device_id set to a specific value
|
|
||||||
# and with a status of ACTIVE.
|
|
||||||
- os_port_info:
|
|
||||||
cloud: mycloud
|
|
||||||
filters:
|
|
||||||
device_id: 1038a010-3a37-4a9d-82ea-652f1da36597
|
|
||||||
status: ACTIVE
|
|
||||||
'''
|
|
||||||
|
|
||||||
RETURN = '''
|
|
||||||
openstack_ports:
|
|
||||||
description: List of port dictionaries. A subset of the dictionary keys
|
|
||||||
listed below may be returned, depending on your cloud provider.
|
|
||||||
returned: always, but can be null
|
|
||||||
type: complex
|
|
||||||
contains:
|
|
||||||
admin_state_up:
|
|
||||||
description: The administrative state of the router, which is
|
|
||||||
up (true) or down (false).
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
sample: true
|
|
||||||
allowed_address_pairs:
|
|
||||||
description: A set of zero or more allowed address pairs. An
|
|
||||||
address pair consists of an IP address and MAC address.
|
|
||||||
returned: success
|
|
||||||
type: list
|
|
||||||
sample: []
|
|
||||||
"binding:host_id":
|
|
||||||
description: The UUID of the host where the port is allocated.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "b4bd682d-234a-4091-aa5b-4b025a6a7759"
|
|
||||||
"binding:profile":
|
|
||||||
description: A dictionary the enables the application running on
|
|
||||||
the host to pass and receive VIF port-specific
|
|
||||||
information to the plug-in.
|
|
||||||
returned: success
|
|
||||||
type: dict
|
|
||||||
sample: {}
|
|
||||||
"binding:vif_details":
|
|
||||||
description: A dictionary that enables the application to pass
|
|
||||||
information about functions that the Networking API
|
|
||||||
provides.
|
|
||||||
returned: success
|
|
||||||
type: dict
|
|
||||||
sample: {"port_filter": true}
|
|
||||||
"binding:vif_type":
|
|
||||||
description: The VIF type for the port.
|
|
||||||
returned: success
|
|
||||||
type: dict
|
|
||||||
sample: "ovs"
|
|
||||||
"binding:vnic_type":
|
|
||||||
description: The virtual network interface card (vNIC) type that is
|
|
||||||
bound to the neutron port.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "normal"
|
|
||||||
device_id:
|
|
||||||
description: The UUID of the device that uses this port.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "b4bd682d-234a-4091-aa5b-4b025a6a7759"
|
|
||||||
device_owner:
|
|
||||||
description: The UUID of the entity that uses this port.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "network:router_interface"
|
|
||||||
dns_assignment:
|
|
||||||
description: DNS assignment information.
|
|
||||||
returned: success
|
|
||||||
type: list
|
|
||||||
dns_name:
|
|
||||||
description: DNS name
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: ""
|
|
||||||
extra_dhcp_opts:
|
|
||||||
description: A set of zero or more extra DHCP option pairs.
|
|
||||||
An option pair consists of an option value and name.
|
|
||||||
returned: success
|
|
||||||
type: list
|
|
||||||
sample: []
|
|
||||||
fixed_ips:
|
|
||||||
description: The IP addresses for the port. Includes the IP address
|
|
||||||
and UUID of the subnet.
|
|
||||||
returned: success
|
|
||||||
type: list
|
|
||||||
id:
|
|
||||||
description: The UUID of the port.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "3ec25c97-7052-4ab8-a8ba-92faf84148de"
|
|
||||||
ip_address:
|
|
||||||
description: The IP address.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "127.0.0.1"
|
|
||||||
mac_address:
|
|
||||||
description: The MAC address.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "00:00:5E:00:53:42"
|
|
||||||
name:
|
|
||||||
description: The port name.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "port_name"
|
|
||||||
network_id:
|
|
||||||
description: The UUID of the attached network.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "dd1ede4f-3952-4131-aab6-3b8902268c7d"
|
|
||||||
port_security_enabled:
|
|
||||||
description: The port security status. The status is enabled (true) or disabled (false).
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
sample: false
|
|
||||||
security_groups:
|
|
||||||
description: The UUIDs of any attached security groups.
|
|
||||||
returned: success
|
|
||||||
type: list
|
|
||||||
status:
|
|
||||||
description: The port status.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "ACTIVE"
|
|
||||||
tenant_id:
|
|
||||||
description: The UUID of the tenant who owns the network.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sample: "51fce036d7984ba6af4f6c849f65ef00"
|
|
||||||
'''
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
argument_spec = openstack_full_argument_spec(
|
|
||||||
port=dict(required=False),
|
|
||||||
filters=dict(type='dict', required=False),
|
|
||||||
)
|
|
||||||
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')
|
|
||||||
|
|
||||||
sdk, cloud = openstack_cloud_from_module(module)
|
|
||||||
try:
|
|
||||||
ports = cloud.search_ports(port, filters)
|
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1 +0,0 @@
|
||||||
os_project_info.py
|
|
|
@ -1,167 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# Copyright (c) 2016 Hewlett-Packard Enterprise Corporation
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
|
||||||
module: os_project_info
|
|
||||||
short_description: Retrieve information about one or more OpenStack projects
|
|
||||||
extends_documentation_fragment:
|
|
||||||
- openstack.cloud.openstack
|
|
||||||
|
|
||||||
author: "Ricardo Carrillo Cruz (@rcarrillocruz)"
|
|
||||||
description:
|
|
||||||
- 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"
|
|
||||||
options:
|
|
||||||
name:
|
|
||||||
description:
|
|
||||||
- Name or ID of the project
|
|
||||||
required: true
|
|
||||||
domain:
|
|
||||||
description:
|
|
||||||
- Name or ID of the domain containing the project if the cloud supports domains
|
|
||||||
filters:
|
|
||||||
description:
|
|
||||||
- A dictionary of meta data to use for further filtering. Elements of
|
|
||||||
this dictionary may be additional dictionaries.
|
|
||||||
availability_zone:
|
|
||||||
description:
|
|
||||||
- Ignored. Present for backwards compatibility
|
|
||||||
'''
|
|
||||||
|
|
||||||
EXAMPLES = '''
|
|
||||||
# Gather information about previously created projects
|
|
||||||
- os_project_info:
|
|
||||||
cloud: awesomecloud
|
|
||||||
register: result
|
|
||||||
- debug:
|
|
||||||
msg: "{{ result.openstack_projects }}"
|
|
||||||
|
|
||||||
# Gather information about a previously created project by name
|
|
||||||
- os_project_info:
|
|
||||||
cloud: awesomecloud
|
|
||||||
name: demoproject
|
|
||||||
register: result
|
|
||||||
- debug:
|
|
||||||
msg: "{{ result.openstack_projects }}"
|
|
||||||
|
|
||||||
# Gather information about a previously created project in a specific domain
|
|
||||||
- os_project_info:
|
|
||||||
cloud: awesomecloud
|
|
||||||
name: demoproject
|
|
||||||
domain: admindomain
|
|
||||||
register: result
|
|
||||||
- debug:
|
|
||||||
msg: "{{ result.openstack_projects }}"
|
|
||||||
|
|
||||||
# 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:
|
|
||||||
msg: "{{ result.openstack_projects }}"
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
RETURN = '''
|
|
||||||
openstack_projects:
|
|
||||||
description: has all the OpenStack information about projects
|
|
||||||
returned: always, but can be null
|
|
||||||
type: complex
|
|
||||||
contains:
|
|
||||||
id:
|
|
||||||
description: Unique UUID.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
name:
|
|
||||||
description: Name given to the project.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
description:
|
|
||||||
description: Description of the project
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
enabled:
|
|
||||||
description: Flag to indicate if the project is enabled
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
domain_id:
|
|
||||||
description: Domain ID containing the project (keystone v3 clouds only)
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
'''
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec, openstack_cloud_from_module
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
argument_spec = openstack_full_argument_spec(
|
|
||||||
name=dict(required=False, default=None),
|
|
||||||
domain=dict(required=False, default=None),
|
|
||||||
filters=dict(required=False, type='dict', default=None),
|
|
||||||
)
|
|
||||||
|
|
||||||
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:
|
|
||||||
name = module.params['name']
|
|
||||||
domain = module.params['domain']
|
|
||||||
filters = module.params['filters']
|
|
||||||
|
|
||||||
if domain:
|
|
||||||
try:
|
|
||||||
# We assume admin is passing domain id
|
|
||||||
dom = opcloud.get_domain(domain)['id']
|
|
||||||
domain = dom
|
|
||||||
except Exception:
|
|
||||||
# If we fail, maybe admin is passing a domain name.
|
|
||||||
# Note that domains have unique names, just like id.
|
|
||||||
dom = opcloud.search_domains(filters={'name': domain})
|
|
||||||
if dom:
|
|
||||||
domain = dom[0]['id']
|
|
||||||
else:
|
|
||||||
module.fail_json(msg='Domain name or ID does not exist')
|
|
||||||
|
|
||||||
if not filters:
|
|
||||||
filters = {}
|
|
||||||
|
|
||||||
filters['domain_id'] = domain
|
|
||||||
|
|
||||||
projects = opcloud.search_projects(name, filters)
|
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1 +0,0 @@
|
||||||
os_server_info.py
|
|
|
@ -1,114 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
|
||||||
module: os_server_info
|
|
||||||
short_description: Retrieve information about one or more compute instances
|
|
||||||
author: Monty (@emonty)
|
|
||||||
description:
|
|
||||||
- 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:
|
|
||||||
- The result contains a list of servers.
|
|
||||||
requirements:
|
|
||||||
- "python >= 2.7"
|
|
||||||
- "openstacksdk"
|
|
||||||
options:
|
|
||||||
server:
|
|
||||||
description:
|
|
||||||
- restrict results to servers with names or UUID matching
|
|
||||||
this glob expression (e.g., <web*>).
|
|
||||||
detailed:
|
|
||||||
description:
|
|
||||||
- when true, return additional detail about servers at the expense
|
|
||||||
of additional API calls.
|
|
||||||
type: bool
|
|
||||||
default: 'no'
|
|
||||||
filters:
|
|
||||||
description:
|
|
||||||
- restrict results to servers matching a dictionary of
|
|
||||||
filters
|
|
||||||
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'
|
|
||||||
extends_documentation_fragment:
|
|
||||||
- openstack.cloud.openstack
|
|
||||||
|
|
||||||
'''
|
|
||||||
|
|
||||||
EXAMPLES = '''
|
|
||||||
# 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:
|
|
||||||
msg: "{{ result.openstack_servers }}"
|
|
||||||
'''
|
|
||||||
|
|
||||||
import fnmatch
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
argument_spec = openstack_full_argument_spec(
|
|
||||||
server=dict(required=False),
|
|
||||||
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)
|
|
||||||
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:
|
|
||||||
openstack_servers = cloud.search_servers(
|
|
||||||
detailed=module.params['detailed'], filters=module.params['filters'],
|
|
||||||
all_projects=module.params['all_projects'])
|
|
||||||
|
|
||||||
if module.params['server']:
|
|
||||||
# filter servers by name
|
|
||||||
pattern = module.params['server']
|
|
||||||
# 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)]
|
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1 +0,0 @@
|
||||||
os_subnets_info.py
|
|
|
@ -1,174 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
|
||||||
module: os_subnets_info
|
|
||||||
short_description: Retrieve information about one or more OpenStack subnets.
|
|
||||||
author: "Davide Agnello (@dagnello)"
|
|
||||||
description:
|
|
||||||
- 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"
|
|
||||||
options:
|
|
||||||
name:
|
|
||||||
description:
|
|
||||||
- Name or ID of the subnet.
|
|
||||||
- Alias 'subnet' added in version 2.8.
|
|
||||||
required: false
|
|
||||||
aliases: ['subnet']
|
|
||||||
filters:
|
|
||||||
description:
|
|
||||||
- A dictionary of meta data to use for further filtering. Elements of
|
|
||||||
this dictionary may be additional dictionaries.
|
|
||||||
required: false
|
|
||||||
availability_zone:
|
|
||||||
description:
|
|
||||||
- Ignored. Present for backwards compatibility
|
|
||||||
required: false
|
|
||||||
extends_documentation_fragment:
|
|
||||||
- openstack.cloud.openstack
|
|
||||||
|
|
||||||
'''
|
|
||||||
|
|
||||||
EXAMPLES = '''
|
|
||||||
- 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:
|
|
||||||
msg: "{{ result.openstack_subnets }}"
|
|
||||||
|
|
||||||
- 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:
|
|
||||||
msg: "{{ result.openstack_subnets }}"
|
|
||||||
|
|
||||||
- name: Gather information about a previously created subnet with filter
|
|
||||||
# Note: name and filters parameters are not mutually exclusive
|
|
||||||
os_subnets_info:
|
|
||||||
auth:
|
|
||||||
auth_url: https://identity.example.com
|
|
||||||
username: user
|
|
||||||
password: password
|
|
||||||
project_name: someproject
|
|
||||||
filters:
|
|
||||||
tenant_id: 55e2ce24b2a245b09f181bf025724cbe
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- name: Show openstack subnets
|
|
||||||
debug:
|
|
||||||
msg: "{{ result.openstack_subnets }}"
|
|
||||||
'''
|
|
||||||
|
|
||||||
RETURN = '''
|
|
||||||
openstack_subnets:
|
|
||||||
description: has all the openstack information about the subnets
|
|
||||||
returned: always, but can be null
|
|
||||||
type: complex
|
|
||||||
contains:
|
|
||||||
id:
|
|
||||||
description: Unique UUID.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
name:
|
|
||||||
description: Name given to the subnet.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
network_id:
|
|
||||||
description: Network ID this subnet belongs in.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
cidr:
|
|
||||||
description: Subnet's CIDR.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
gateway_ip:
|
|
||||||
description: Subnet's gateway ip.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
enable_dhcp:
|
|
||||||
description: DHCP enable flag for this subnet.
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
ip_version:
|
|
||||||
description: IP version for this subnet.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
tenant_id:
|
|
||||||
description: Tenant id associated with this subnet.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
dns_nameservers:
|
|
||||||
description: DNS name servers for this subnet.
|
|
||||||
returned: success
|
|
||||||
type: list
|
|
||||||
elements: str
|
|
||||||
allocation_pools:
|
|
||||||
description: Allocation pools associated with this subnet.
|
|
||||||
returned: success
|
|
||||||
type: list
|
|
||||||
elements: dict
|
|
||||||
'''
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec, openstack_cloud_from_module
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
argument_spec = openstack_full_argument_spec(
|
|
||||||
name=dict(required=False, default=None, aliases=['subnet']),
|
|
||||||
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'])
|
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1 +0,0 @@
|
||||||
os_user_info.py
|
|
|
@ -1,175 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# Copyright (c) 2016 Hewlett-Packard Enterprise Corporation
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'community'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
|
||||||
module: os_user_info
|
|
||||||
short_description: Retrieve information about one or more OpenStack users
|
|
||||||
extends_documentation_fragment:
|
|
||||||
- openstack.cloud.openstack
|
|
||||||
|
|
||||||
author: "Ricardo Carrillo Cruz (@rcarrillocruz)"
|
|
||||||
description:
|
|
||||||
- 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"
|
|
||||||
options:
|
|
||||||
name:
|
|
||||||
description:
|
|
||||||
- Name or ID of the user
|
|
||||||
required: true
|
|
||||||
domain:
|
|
||||||
description:
|
|
||||||
- Name or ID of the domain containing the user if the cloud supports domains
|
|
||||||
filters:
|
|
||||||
description:
|
|
||||||
- A dictionary of meta data to use for further filtering. Elements of
|
|
||||||
this dictionary may be additional dictionaries.
|
|
||||||
availability_zone:
|
|
||||||
description:
|
|
||||||
- Ignored. Present for backwards compatibility
|
|
||||||
'''
|
|
||||||
|
|
||||||
EXAMPLES = '''
|
|
||||||
# Gather information about previously created users
|
|
||||||
- os_user_info:
|
|
||||||
cloud: awesomecloud
|
|
||||||
register: result
|
|
||||||
- debug:
|
|
||||||
msg: "{{ result.openstack_users }}"
|
|
||||||
|
|
||||||
# Gather information about a previously created user by name
|
|
||||||
- os_user_info:
|
|
||||||
cloud: awesomecloud
|
|
||||||
name: demouser
|
|
||||||
register: result
|
|
||||||
- debug:
|
|
||||||
msg: "{{ result.openstack_users }}"
|
|
||||||
|
|
||||||
# Gather information about a previously created user in a specific domain
|
|
||||||
- os_user_info:
|
|
||||||
cloud: awesomecloud
|
|
||||||
name: demouser
|
|
||||||
domain: admindomain
|
|
||||||
register: result
|
|
||||||
- debug:
|
|
||||||
msg: "{{ result.openstack_users }}"
|
|
||||||
|
|
||||||
# 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:
|
|
||||||
msg: "{{ result.openstack_users }}"
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
RETURN = '''
|
|
||||||
openstack_users:
|
|
||||||
description: has all the OpenStack information about users
|
|
||||||
returned: always, but can be null
|
|
||||||
type: complex
|
|
||||||
contains:
|
|
||||||
id:
|
|
||||||
description: Unique UUID.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
name:
|
|
||||||
description: Name given to the user.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
enabled:
|
|
||||||
description: Flag to indicate if the user is enabled
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
domain_id:
|
|
||||||
description: Domain ID containing the user
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
default_project_id:
|
|
||||||
description: Default project ID of the user
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
email:
|
|
||||||
description: Email of the user
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
username:
|
|
||||||
description: Username of the user
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
'''
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
argument_spec = openstack_full_argument_spec(
|
|
||||||
name=dict(required=False, default=None),
|
|
||||||
domain=dict(required=False, default=None),
|
|
||||||
filters=dict(required=False, type='dict', default=None),
|
|
||||||
)
|
|
||||||
|
|
||||||
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:
|
|
||||||
name = module.params['name']
|
|
||||||
domain = module.params['domain']
|
|
||||||
filters = module.params['filters']
|
|
||||||
|
|
||||||
if domain:
|
|
||||||
try:
|
|
||||||
# We assume admin is passing domain id
|
|
||||||
dom = opcloud.get_domain(domain)['id']
|
|
||||||
domain = dom
|
|
||||||
except Exception:
|
|
||||||
# If we fail, maybe admin is passing a domain name.
|
|
||||||
# Note that domains have unique names, just like id.
|
|
||||||
dom = opcloud.search_domains(filters={'name': domain})
|
|
||||||
if dom:
|
|
||||||
domain = dom[0]['id']
|
|
||||||
else:
|
|
||||||
module.fail_json(msg='Domain name or ID does not exist')
|
|
||||||
|
|
||||||
if not filters:
|
|
||||||
filters = {}
|
|
||||||
|
|
||||||
filters['domain_id'] = domain
|
|
||||||
|
|
||||||
users = opcloud.search_users(name, filters)
|
|
||||||
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))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
Loading…
Reference in a new issue