From a1ec74334ae3eeb29272bdd2332636403ccc6320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Mon, 18 Feb 2019 18:48:47 +0100 Subject: [PATCH] cloudscale_volume: fail fast on volume type change (#52231) * cloudscale_volume: fail fast on volume type change Currently a volume gets resized before the type change check. With this change, we check early and ensure we fail before any changes made. * fix too many blank lines --- .../modules/cloud/cloudscale/cloudscale_volume.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/cloud/cloudscale/cloudscale_volume.py b/lib/ansible/modules/cloud/cloudscale/cloudscale_volume.py index e988bc9104b..0f878bfa9dc 100644 --- a/lib/ansible/modules/cloud/cloudscale/cloudscale_volume.py +++ b/lib/ansible/modules/cloud/cloudscale/cloudscale_volume.py @@ -261,18 +261,18 @@ def main(): volume.delete() if module.params['state'] == 'present': - for param, conv in (('server_uuids', set), ('size_gb', int)): - if module.params[param] is None: - continue - if conv(volume.info[param]) != conv(module.params[param]): - volume.update(param) - if (module.params['type'] is not None and volume.info['type'] != module.params['type']): module.fail_json( msg='Cannot change type of an existing volume.', ) + for param, conv in (('server_uuids', set), ('size_gb', int)): + if module.params[param] is None: + continue + if conv(volume.info[param]) != conv(module.params[param]): + volume.update(param) + module.exit_json(changed=volume.changed, **volume.info)