From 32c337ee395cdc0fca4d593412c316f2a6914922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= <4281581+LKaemmerling@users.noreply.github.com> Date: Mon, 11 Mar 2019 16:57:23 +0100 Subject: [PATCH] hcloud_server: streamline label handling (#53633) --- .../modules/cloud/hcloud/hcloud_server.py | 2 +- .../targets/hcloud_server/tasks/main.yml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_server.py b/lib/ansible/modules/cloud/hcloud/hcloud_server.py index 2fc9b7ee09..02df1beb5b 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_server.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_server.py @@ -274,7 +274,7 @@ class AnsibleHcloudServer(Hcloud): self._mark_as_changed() labels = self.module.params.get("labels") - if labels is not None: + if labels is not None and labels != self.hcloud_server.labels: if not self.module.check_mode: self.hcloud_server.update(labels=labels) self._mark_as_changed() diff --git a/test/integration/targets/hcloud_server/tasks/main.yml b/test/integration/targets/hcloud_server/tasks/main.yml index 5a9722b3a5..1d5d6011ec 100644 --- a/test/integration/targets/hcloud_server/tasks/main.yml +++ b/test/integration/targets/hcloud_server/tasks/main.yml @@ -312,6 +312,24 @@ - main_server.hcloud_server.labels.key == "other" - main_server.hcloud_server.labels.mylabel == 123 + +- name: test update server with labels in other order + hcloud_server: + name: "{{ hcloud_server_name}}" + server_type: cx11 + image: "ubuntu-18.04" + ssh_keys: + - ci@ansible.hetzner.cloud + labels: + mylabel: 123 + key: other + state: started + register: main_server +- name: verify update server with labels in other order + assert: + that: + - main_server is not changed + - name: cleanup with labels hcloud_server: name: "{{ hcloud_server_name }}"