diff --git a/changelogs/fragments/remove-auto-detach-volume.yml b/changelogs/fragments/remove-auto-detach-volume.yml new file mode 100644 index 0000000..2c4bd06 --- /dev/null +++ b/changelogs/fragments/remove-auto-detach-volume.yml @@ -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. diff --git a/plugins/modules/volume.py b/plugins/modules/volume.py index 1bcb442..118dc4c 100644 --- a/plugins/modules/volume.py +++ b/plugins/modules/volume.py @@ -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: diff --git a/tests/integration/targets/volume/tasks/test.yml b/tests/integration/targets/volume/tasks/test.yml index 60189aa..11f9e7c 100644 --- a/tests/integration/targets/volume/tasks/test.yml +++ b/tests/integration/targets/volume/tasks/test.yml @@ -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}}"