|
|
@ -147,6 +147,12 @@ options:
|
|
|
|
- Force stop/start the instance if required to apply changes, otherwise a running instance will not be changed.
|
|
|
|
- Force stop/start the instance if required to apply changes, otherwise a running instance will not be changed.
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
default: no
|
|
|
|
default: no
|
|
|
|
|
|
|
|
allow_root_disk_shrink:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Enables a volume shrinkage when the new size is smaller than the old one.
|
|
|
|
|
|
|
|
type: bool
|
|
|
|
|
|
|
|
default: no
|
|
|
|
|
|
|
|
version_added: '2.7'
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- List of tags. Tags are a list of dictionaries having keys C(key) and C(value).
|
|
|
|
- List of tags. Tags are a list of dictionaries having keys C(key) and C(value).
|
|
|
@ -743,11 +749,33 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|
|
|
|
|
|
|
|
|
|
|
security_groups_changed = self.security_groups_has_changed()
|
|
|
|
security_groups_changed = self.security_groups_has_changed()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Volume data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args_volume_update = {}
|
|
|
|
|
|
|
|
root_disk_size = self.module.params.get('root_disk_size')
|
|
|
|
|
|
|
|
root_disk_size_changed = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if root_disk_size is not None:
|
|
|
|
|
|
|
|
res = self.query_api('listVolumes', type='ROOT', virtualmachineid=instance['id'])
|
|
|
|
|
|
|
|
[volume] = res['volume']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size = volume['size'] >> 30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args_volume_update['id'] = volume['id']
|
|
|
|
|
|
|
|
args_volume_update['size'] = root_disk_size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shrinkok = self.module.params.get('allow_root_disk_shrink')
|
|
|
|
|
|
|
|
if shrinkok:
|
|
|
|
|
|
|
|
args_volume_update['shrinkok'] = shrinkok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root_disk_size_changed = root_disk_size != size
|
|
|
|
|
|
|
|
|
|
|
|
changed = [
|
|
|
|
changed = [
|
|
|
|
service_offering_changed,
|
|
|
|
service_offering_changed,
|
|
|
|
instance_changed,
|
|
|
|
instance_changed,
|
|
|
|
security_groups_changed,
|
|
|
|
security_groups_changed,
|
|
|
|
ssh_key_changed,
|
|
|
|
ssh_key_changed,
|
|
|
|
|
|
|
|
root_disk_size_changed,
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
if any(changed):
|
|
|
|
if any(changed):
|
|
|
@ -787,6 +815,11 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
|
|
|
|
instance = self.poll_job(instance, 'virtualmachine')
|
|
|
|
instance = self.poll_job(instance, 'virtualmachine')
|
|
|
|
self.instance = instance
|
|
|
|
self.instance = instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Root disk size
|
|
|
|
|
|
|
|
if root_disk_size_changed:
|
|
|
|
|
|
|
|
async_result = self.query_api('resizeVolume', **args_volume_update)
|
|
|
|
|
|
|
|
self.poll_job(async_result, 'volume')
|
|
|
|
|
|
|
|
|
|
|
|
# Start VM again if it was running before
|
|
|
|
# Start VM again if it was running before
|
|
|
|
if instance_state == 'running' and start_vm:
|
|
|
|
if instance_state == 'running' and start_vm:
|
|
|
|
instance = self.start_instance()
|
|
|
|
instance = self.start_instance()
|
|
|
@ -986,6 +1019,7 @@ def main():
|
|
|
|
tags=dict(type='list', aliases=['tag']),
|
|
|
|
tags=dict(type='list', aliases=['tag']),
|
|
|
|
details=dict(type='dict'),
|
|
|
|
details=dict(type='dict'),
|
|
|
|
poll_async=dict(type='bool', default=True),
|
|
|
|
poll_async=dict(type='bool', default=True),
|
|
|
|
|
|
|
|
allow_root_disk_shrink=dict(type='bool', default=False),
|
|
|
|
))
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
required_together = cs_required_together()
|
|
|
|
required_together = cs_required_together()
|
|
|
|