Backport hcloud_volume attach step should be idempotent
This commit is contained in:
parent
0a624eaad3
commit
116262e5e8
3 changed files with 16 additions and 5 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- hcloud_volume - Fix idempotency when attaching a server to a volume.
|
|
@ -232,7 +232,7 @@ class AnsibleHcloudVolume(Hcloud):
|
|||
server_name = self.module.params.get("server")
|
||||
if server_name:
|
||||
server = self.client.servers.get_by_name(server_name)
|
||||
if self.hcloud_volume.server != server:
|
||||
if self.hcloud_volume.server is None or self.hcloud_volume.server.name != server.name:
|
||||
if not self.module.check_mode:
|
||||
automount = self.module.params.get("automount", False)
|
||||
self.hcloud_volume.attach(server, automount=automount).wait_until_finished()
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
image: ubuntu-18.04
|
||||
state: started
|
||||
location: "fsn1"
|
||||
register: main_server
|
||||
register: vol_server
|
||||
- name: verify setup server
|
||||
assert:
|
||||
that:
|
||||
- main_server is changed
|
||||
- vol_server is changed
|
||||
|
||||
- name: test missing size parameter on create Volume
|
||||
hcloud_volume:
|
||||
|
@ -86,7 +86,17 @@
|
|||
that:
|
||||
- volume is changed
|
||||
- volume.hcloud_volume.server == "{{hcloud_server_name}}"
|
||||
- main_server is changed
|
||||
|
||||
- name: test attach volume idempotence
|
||||
hcloud_volume:
|
||||
name: "{{hcloud_volume_name}}"
|
||||
server: "{{hcloud_server_name}}"
|
||||
register: volume
|
||||
- name: verify attach volume idempotence
|
||||
assert:
|
||||
that:
|
||||
- volume is not changed
|
||||
- volume.hcloud_volume.server == "{{hcloud_server_name}}"
|
||||
|
||||
- name: test detach volume with checkmode
|
||||
hcloud_volume:
|
||||
|
@ -109,7 +119,6 @@
|
|||
- volume is changed
|
||||
- volume.hcloud_volume.location == "fsn1"
|
||||
- volume.hcloud_volume.server != "{{hcloud_server_name}}"
|
||||
- main_server is changed
|
||||
|
||||
- name: test update volume label
|
||||
hcloud_volume:
|
||||
|
|
Loading…
Reference in a new issue