hcloud_volume attach step should be idempotent (#56906)

This commit is contained in:
Lukas Kämmerling 2019-05-27 07:48:48 +02:00 committed by René Moser
parent 8f89d1d3da
commit 7f08de6b6c
3 changed files with 16 additions and 5 deletions

View file

@ -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()