mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
fix!: do not detach volume if server is not provided (#632)
Do not detach volume if `server` is not provided ##### SUMMARY Volumes were automatically detached from servers if they already exists and attached to a server. This PR fixes this issue after adding new ```volume_attachment``` module so user can attach/detach volumes with that module Fixes: #490 ##### ISSUE TYPE - Bugfix Pull Request ##### COMPONENT NAME ```volume``` --------- Co-authored-by: Jonas L. <jooola@users.noreply.github.com>
This commit is contained in:
parent
3c84f19ef5
commit
e8fda3557c
3 changed files with 2 additions and 28 deletions
2
changelogs/fragments/remove-auto-detach-volume.yml
Normal file
2
changelogs/fragments/remove-auto-detach-volume.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
breaking_changes:
|
||||
- volume - Volumes are no longer detached when the server argument is not provided. Please use the ``volume_attachment`` module to manage volume attachments.
|
||||
|
|
@ -244,12 +244,6 @@ class AnsibleHCloudVolume(AnsibleHCloud):
|
|||
action = self.hcloud_volume.attach(server, automount=automount)
|
||||
action.wait_until_finished()
|
||||
self._mark_as_changed()
|
||||
else:
|
||||
if self.hcloud_volume.server is not None:
|
||||
if not self.module.check_mode:
|
||||
action = self.hcloud_volume.detach()
|
||||
action.wait_until_finished()
|
||||
self._mark_as_changed()
|
||||
|
||||
labels = self.module.params.get("labels")
|
||||
if labels is not None and labels != self.hcloud_volume.labels:
|
||||
|
|
|
|||
|
|
@ -99,28 +99,6 @@
|
|||
- volume is not changed
|
||||
- volume.hcloud_volume.server == hcloud_server_name
|
||||
|
||||
- name: test detach Volume with checkmode
|
||||
hetzner.hcloud.volume:
|
||||
name: "{{hcloud_volume_name}}"
|
||||
check_mode: true
|
||||
register: volume
|
||||
- name: verify detach Volume with checkmode
|
||||
assert:
|
||||
that:
|
||||
- volume is changed
|
||||
- volume.hcloud_volume.server == hcloud_server_name
|
||||
|
||||
- name: test detach Volume
|
||||
hetzner.hcloud.volume:
|
||||
name: "{{hcloud_volume_name}}"
|
||||
register: volume
|
||||
- name: verify detach volume
|
||||
assert:
|
||||
that:
|
||||
- volume is changed
|
||||
- volume.hcloud_volume.location == hcloud_location_name
|
||||
- volume.hcloud_volume.server != hcloud_server_name
|
||||
|
||||
- name: test update Volume label
|
||||
hetzner.hcloud.volume:
|
||||
name: "{{hcloud_volume_name}}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue