3 # Copyright (c) 2016 IBM
5 # This module is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This software is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this software. If not, see <http://www.gnu.org/licenses/>.
25 module: os_router_facts
26 short_description: Retrieve facts about routers within OpenStack.
28 author: "Originally: David Shrewsbury (@Shrews); modified"
30 - Retrieve facts about routers from OpenStack.
32 - Facts are placed in the C(openstack_routers) variable.
39 - Unique name or ID of a port.
44 - A dictionary of meta data to use for further filtering. Elements
45 of this dictionary will be matched against the returned port
46 dictionaries. Matching is currently limited to strings within
47 the port dictionary, or strings within nested dictionaries.
50 extends_documentation_fragment: openstack
54 # Gather facts about all routers
58 # Gather facts about a single port
61 port: 6140317d-e676-31e1-8a4a-b1913814a471
63 # Gather facts about all routers that have device_id set to a specific value
64 # and with a status of ACTIVE.
69 - Name or ID of the router
72 device_id: 1038a010-3a37-4a9d-82ea-652f1da36597
78 description: List of port dictionaries. A subset of the dictionary keys
79 listed below may be returned, depending on your cloud provider.
80 returned: always, but can be null
87 argument_spec = openstack_full_argument_spec(
88 router={'required': False, 'default': None},
89 filters={'required': False, 'type': 'dict', 'default': None},
91 module_kwargs = openstack_module_kwargs()
92 module = AnsibleModule(argument_spec, **module_kwargs)
95 module.fail_json(msg='shade is required for this module')
97 router = module.params.pop('router')
98 filters = module.params.pop('filters')
101 cloud = shade.openstack_cloud(**module.params)
102 routers = cloud.search_routers(router, filters)
103 module.exit_json(changed=False, ansible_facts=dict(
104 openstack_routers=routers))
106 except shade.OpenStackCloudException as e:
107 module.fail_json(msg=str(e))
109 from ansible.module_utils.basic import *
110 from ansible.module_utils.openstack import *
112 if __name__ == '__main__':