hcloud_server: streamline label handling (#53633)
This commit is contained in:
parent
1a306ce871
commit
32c337ee39
2 changed files with 19 additions and 1 deletions
|
@ -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()
|
||||
|
|
|
@ -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 }}"
|
||||
|
|
Loading…
Reference in a new issue