@ -86,6 +86,11 @@ options:
availability_zone :
description :
- Ignored . Present for backwards compatibility
volume :
version_added : " 2.10 "
description :
- ID of a volume to create an image from .
- The volume must be in AVAILABLE state .
requirements : [ " openstacksdk " ]
'''
@ -109,6 +114,33 @@ EXAMPLES = '''
properties :
cpu_arch : x86_64
distro : ubuntu
# Create image from volume attached to an instance
- name : create volume snapshot
os_volume_snapshot :
auth :
" {{ auth }} "
display_name : myvol_snapshot
volume : myvol
force : yes
register : myvol_snapshot
- name : create volume from snapshot
os_volume :
auth :
" {{ auth }} "
size : " {{ myvol_snapshot.snapshot.size }} "
snapshot_id : " {{ myvol_snapshot.snapshot.id }} "
display_name : myvol_snapshot_volume
wait : yes
register : myvol_snapshot_volume
- name : create image from volume snapshot
os_image :
auth :
" {{ auth }} "
volume : " {{ myvol_snapshot_volume.volume.id }} "
name : myvol_image
'''
from ansible . module_utils . basic import AnsibleModule
@ -132,9 +164,13 @@ def main():
ramdisk = dict ( default = None ) ,
kernel = dict ( default = None ) ,
properties = dict ( type = ' dict ' , default = { } ) ,
volume = dict ( default = None ) ,
state = dict ( default = ' present ' , choices = [ ' absent ' , ' present ' ] ) ,
)
module_kwargs = openstack_module_kwargs ( )
module_kwargs = openstack_module_kwargs (
mutually_exclusive = [ [ ' filename ' , ' volume ' ] ] ,
)
module = AnsibleModule ( argument_spec , * * module_kwargs )
sdk , cloud = openstack_cloud_from_module ( module )
@ -162,6 +198,7 @@ def main():
protected = module . params [ ' protected ' ] ,
min_disk = module . params [ ' min_disk ' ] ,
min_ram = module . params [ ' min_ram ' ] ,
volume = module . params [ ' volume ' ] ,
* * kwargs
)
changed = True