From 40a384214c4d03f91ff00753f83821348d0442d4 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 2 May 2023 19:21:15 +0200 Subject: [PATCH] Ensure coe_cluster_template compare labels properly SDK does return all keys and values of the template labels as strings. At the same time user can define some labels as integers or booleans, which will break comparison of labels and lead to module failure on consecutive runs. Change-Id: I7ab624428c8bb06030a2b28888f5cb89bb249f08 --- .../fragments/coe_cluster_template_labels_comparison.yml | 7 +++++++ ci/roles/coe_cluster_template/tasks/main.yml | 6 ++++++ plugins/modules/coe_cluster_template.py | 3 +++ 3 files changed, 16 insertions(+) create mode 100644 changelogs/fragments/coe_cluster_template_labels_comparison.yml diff --git a/changelogs/fragments/coe_cluster_template_labels_comparison.yml b/changelogs/fragments/coe_cluster_template_labels_comparison.yml new file mode 100644 index 00000000..5d26647d --- /dev/null +++ b/changelogs/fragments/coe_cluster_template_labels_comparison.yml @@ -0,0 +1,7 @@ +--- + +bugfixes: + - | + coe_cluster_template - now labels are converted to strings by module that + fixes module idempotence in case label values defined by users are + integers or booleans. diff --git a/ci/roles/coe_cluster_template/tasks/main.yml b/ci/roles/coe_cluster_template/tasks/main.yml index f310ebb7..8e121604 100644 --- a/ci/roles/coe_cluster_template/tasks/main.yml +++ b/ci/roles/coe_cluster_template/tasks/main.yml @@ -26,6 +26,9 @@ keypair_id: '{{ keypair.keypair.id }}' name: k8s state: present + labels: + docker_volume_size: 10 + cloud_provider_tag: v1.23.1 register: coe_cluster_template - name: Assert return values of coe_cluster_template module @@ -43,6 +46,9 @@ keypair_id: '{{ keypair.keypair.id }}' name: k8s state: present + labels: + docker_volume_size: 10 + cloud_provider_tag: v1.23.1 register: coe_cluster_template - name: Assert return values of coe_cluster_template module diff --git a/plugins/modules/coe_cluster_template.py b/plugins/modules/coe_cluster_template.py index 7217a8b4..caed9fc4 100644 --- a/plugins/modules/coe_cluster_template.py +++ b/plugins/modules/coe_cluster_template.py @@ -433,6 +433,9 @@ class COEClusterTemplateModule(OpenStackModule): if isinstance(labels, str): labels = dict([tuple(kv.split(":")) for kv in labels.split(",")]) + elif isinstance(labels, dict): + labels = dict({str(k): str(v) + for k, v in labels.items()}) if labels != cluster_template['labels']: non_updateable_keys.append('labels')