ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
823 stars 1.52k forks source link

community.general.proxmox_kvm Destroy Detached Disk #8828

Closed polachz closed 3 weeks ago

polachz commented 1 month ago

Summary

When use community.general.proxmox_kvm module to destroy the VM, all VM disks are destroyed, even if disk is detached from VM. This behavior can't be changed by any parameter.

When VM is destroyed by Proxmox GUI, special checkbox:

Must be checked to destroy detached disk

Issue Type

Bug Report

Component Name

proxmox_kvm

Ansible Version

ansible [core 2.16.9]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/boss/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/boss/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.4 (main, Jun  7 2024, 00:00:00) [GCC 14.1.1 20240607 (Red Hat 14.1.1-5)] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True

Community.general Version

Collection        Version
----------------- -------
community.general 7.4.0  

Configuration

$ ansible-config dump --only-changed

OS / Environment

Fedora 40

Steps to Reproduce

- name: "Detaching VM Drive"
  community.general.proxmox_disk:
    api_host: "{{ pve_api_host }}"
    api_user: "{{ pve_api_user }}"
    api_password: "{{ pve_password | default(omit) }}"
    api_token_id: "{{ pve_api_token_id | default(omit) }}"
    api_token_secret: "{{ pve_api_token_secret | default(omit) }}"

    vmid: 100

    media: 'disk'
    disk: scsi1
    state: 'detached'
  delegate_to: localhost

- name: "Destroy Proxmox VM"
community.general.proxmox_kvm:
    api_host: "{{ pve_api_host }}"
    api_user: "{{ pve_api_user }}"
    api_password: "{{ pve_password | default(omit) }}"
    api_token_id: "{{ pve_api_token_id | default(omit) }}"
    api_token_secret: "{{ pve_api_token_secret | default(omit) }}"

    vmid:  100
    state: absent
  delegate_to: localhost

Expected Results

I expected thatdetached VM disk stay preserved on the Proxmox storage as it happened when VM is removed by GUI.

Alternatively i excpect parameter to specify if detached disk will be destroyed or not.

See sumary filed

Actual Results

VM Disk is destroyed and can't be re-attached to re-created VM

Code of Conduct

ansibullbot commented 1 month ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 1 month ago

cc @Ajpantuso @Thulium-Drake @UnderGreen @helldorado @joshainglis @karmab @krauthosting click here for bot help

polachz commented 3 weeks ago

After my various triees by the direct Proxmox REST api I have discoveredt that the RST API has same behavior. Then here is no way how to reach this. Closing as invalid