3 # Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
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_images_facts
26 short_description: Retrieve facts about an image within OpenStack.
28 author: "Originally: Davide Agnello (@dagnello); modified"
30 - Retrieve facts about a image image from OpenStack.
32 - Facts are placed in the C(openstack) variable.
39 - Name or ID of the image
43 - A dictionary of meta data to use for further filtering. Elements of
44 this dictionary may be additional dictionaries.
46 extends_documentation_fragment: openstack
50 # Gather facts about a previously created image named image1
53 auth_url: https://your_api_url.com:9000/v2.0
56 project_name: someproject
58 - debug: var=openstack
63 description: has all the openstack facts about the image
64 returned: always, but can be null
68 description: Unique UUID.
72 description: Name given to the image.
76 description: Image status.
80 description: Image created at timestamp.
84 description: Image deleted flag.
88 description: Container format of the image.
92 description: Min amount of RAM required for this image.
96 description: Disk format of the image.
100 description: Image updated at timestamp.
104 description: Additional properties associated with the image.
108 description: Min amount of disk space required for this image.
112 description: Image protected flag.
116 description: Checksum for the image.
120 description: Owner for the image.
124 description: Is public flag of the image.
128 description: Image deleted at timestamp.
132 description: Size of the image.
140 argument_spec = openstack_full_argument_spec(
141 image={'required': False, 'default': None},
142 filters={'required': False, 'default': None},
144 module_kwargs = openstack_module_kwargs()
145 module = AnsibleModule(argument_spec, **module_kwargs)
148 module.fail_json(msg='shade is required for this module')
150 image = module.params.pop('image')
151 filters = module.params.pop('filters')
154 cloud = shade.openstack_cloud(**module.params)
155 images = cloud.search_images(image, filters)
156 module.exit_json(changed=False, ansible_facts={
157 'openstack_images': images})
159 except shade.OpenStackCloudException as e:
160 module.fail_json(msg=str(e))
162 # this is magic, see lib/ansible/module_common.py
163 from ansible.module_utils.basic import *
164 from ansible.module_utils.openstack import *
165 if __name__ == '__main__':