Skip to content

Disk not resized when vmware vm scsi controller is "lsi logic" and vm is powered on #1595

Open
@PisikeSipelgas

Description

@PisikeSipelgas
SUMMARY

Disk not resized when vmware vm scsi controller is "lsi logic" and vm is powered on

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_guest_disk

ANSIBLE VERSION
  config file = /home/ps/.ansible.cfg
  configured module search path = ['/home/ps/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/ps/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.14 (main, Nov  7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION

Partial list:


# /usr/lib/python3.9/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
community.vmware              2.8.0

vmware.vmware_rest            2.2.0

CONFIGURATION
DEFAULT_ROLES_PATH(/home/ps/.ansible.cfg) = ['/etc/ansible/roles', '/usr/share/ansible/roles']
DEFAULT_STDOUT_CALLBACK(/home/ps/.ansible.cfg) = skippy
DEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /home/ps/.vault_pass
TRANSFORM_INVALID_GROUP_CHARS(env: ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS) = ignore
OS / ENVIRONMENT

Rocky 9.1

STEPS TO REPRODUCE

VM is deployed from template where SCSI controller is set to "LSI Logic". Deployment is successful. Vmware tools are pre-installed. VM gets powered ON.
Next step is to modify additional disk, which fails (see below). At the same time resizing disk disk directly from VmWare Vsphere Web console resizing works as expected (disk is resized without any problems).
Solution is to change SCSI controller to be "VmWare Paravirtual". Without any change in playbooks everything works.

- name: add or resize hdd
  vmware_guest_disk:
    hostname: "{{ vmware_hostname }}"
    username: "{{ vmware_username }}"
    password: "{{ vmware_password }}"
    datacenter: "{{ vm_datacenter }}"
    name: "{{ vm_hostname }}"
    folder: "{{ vm_folder }}"
    disk:
      - size_gb: "{{ item.size|int }}"
        type: "thin"
        state: present
        scsi_controller: "{{ item.controller|int }}"
        unit_number: "{{ item.lun|int }}"
        disk_mode: persistent
        datastore: "{{ item.disk_datastore }}"
  loop: "{{ disks }}"
  delegate_to: localhost
  when: ( disks is defined )

where "disks" are defined in external json file like this:

    "disks": [
        {
            "mountpoint": "/data",
            "controller": 0,
            "lun": 1,
            "size": 75,
            "disk_datastore": "3PAR_comp"
        }
    ],
EXPECTED RESULTS

VM disk attached to "LSI Logic" will be resized regardless vm is powered "on" or "off".
It did work with older ansible (centos 7 & ansible 2.9).

ACTUAL RESULTS

Task fails with message: "Parameters for device 'scsi0' may not be modified while the virtual machine is powered on."

(failed: [localhost] (item={'mountpoint': '/mnt', 'controller': 0, 'lun': 1, 'size': 200, 'disk_datastore': '3PAR_comp'}) => {"ansible_loop_var": "item", "changed": false, "item": {"controller": 0, "disk_datastore": "3PAR_comp", "lun": 1, "mountpoint": "/mnt", "size": 200}, "msg": "Failed to manage disks for virtual machine 'vm.example.com' with exception : (\"Parameters for device 'scsi0' may not be modified while the virtual machine is powered on.\", None)"})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions