From 77acba047b6c40d31f42bb9a61b3c71f29ef4a32 Mon Sep 17 00:00:00 2001 From: wuchunyang Date: Tue, 27 Apr 2021 17:38:19 +0800 Subject: [PATCH] Fix the idempotent of compute_flavor module if flavor's swap is not set (or 0),nova returns empty string [0] rather than 0 when query flavor spec. this behavior will break the idempotent of the ansible deployment. this ps changes the empty string to 0 before compare them. [0]: https://docs.openstack.org/api-ref/compute/?expanded=list-flavors-detail,list-flavors-with-details-detail#list-flavors-with-details Change-Id: I041cbcc0432051d795e2c3f0e7ac7378e1970008 --- plugins/modules/compute_flavor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/modules/compute_flavor.py b/plugins/modules/compute_flavor.py index 85092b44..33be67cb 100644 --- a/plugins/modules/compute_flavor.py +++ b/plugins/modules/compute_flavor.py @@ -220,6 +220,8 @@ def main(): if flavor: old_extra_specs = flavor['extra_specs'] + if flavor['swap'] == "": + flavor['swap'] = 0 for param_key in ['ram', 'vcpus', 'disk', 'ephemeral', 'swap', 'rxtx_factor', 'is_public']: if module.params[param_key] != flavor[param_key]: require_update = True