Skip to content

Conversation

@alezzandro
Copy link

@alezzandro alezzandro commented Dec 11, 2024

Fixes #2096

SUMMARY

Fixing issue on changing "disk_mode" #2096.
As reported in the issue trying to change the disk_mode on an existing vm disk. If the disk is "independent_persistent" and I want to change it to "persistent" no change will be made. Other combinations also won't work.

I edited the vmware_guest_disk.py for including the disk_mode change in the VM reconfiguration if the disk_mode parameter is changing from the existing one.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

community.vmware.vmware_guest_disk

ADDITIONAL INFORMATION

Please note I've just made a small change that still requires you to pass to the module at least the following information:

- name: VMware Change Disk Mode
  hosts: localhost
  tasks:
  - name: Change disk mode for virtual machine using name
    community.vmware.vmware_guest_disk:
      hostname: "{{ vcenter_hostname }}"
      username: "{{ vcenter_username }}"
      password: "{{ vcenter_password }}"
      datacenter: "{{ vcenter_dc }}"
      name: "{{ vm_name }}"
      validate_certs: false
      disk:
        - controller_number: "{{ vm_disk_controller_number }}"
          unit_number: "{{ vm_disk_unit_number }}"
          disk_mode: "persistent" 
          size_kb: "{{ vm_disk_size_kb }}"
    delegate_to: localhost
    register: disk_facts

@mariolenz
Copy link
Collaborator

I'm sorry, I didn't find much time to work on this collection during the last weeks. I hope I'm able to review this PR soon.

@alezzandro
Copy link
Author

@mariolenz any news?

@mariolenz
Copy link
Collaborator

Could you please add a changelog fragment?

It would be great to have a test case for this. Maybe we can re-use a disk that's created here:

- name: create new disk(s) with valid disk mode

Something like

- name: Change disk mode
  vmware_guest_disk:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    datacenter: "{{ dc1 }}"
    validate_certs: false
    name: test_vm1
    disk:
      - datastore: "{{ rw_datastore }}"
        disk_mode: "persistent"
        scsi_controller: 0
        scsi_type: 'paravirtual'
        size_gb: 1
        state: present
        type: eagerzeroedthick
        unit_number: 2
  register: test_change_disk_mode

- debug:
    msg: "{{ test_change_disk_mode }}"

- name: assert that changes were made
  assert:
    that:
      - test_change_disk_mode is changed

after this test maybe? That would be line 111.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

community.vmware.vmware_guest_disk: changing "disk_mode" has no effect

2 participants