Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disk resize fails when using Ansible 2.15 #2043

Open
kbreit opened this issue Apr 12, 2024 · 3 comments
Open

Disk resize fails when using Ansible 2.15 #2043

kbreit opened this issue Apr 12, 2024 · 3 comments

Comments

@kbreit
Copy link

kbreit commented Apr 12, 2024

SUMMARY

community.vmware is used to build Windows VMs in vSphere. The playbook has existed for a while and used to work but when using it in an Ansible 2.15 execution environment, it fails. It seems to work under 2.9 though. The error is:

"Failed to manage disks for virtual machine 'vm_test' with exception : (\"Parameters for device 'scsi0' may not be modified while the virtual machine is powered on.\", None)",

This error is coming from VMware as it shows in the vSphere web UI. However, resizing the disks in the web UI works, as does Ansible 2.9.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_guest_disk

ANSIBLE VERSION
ansible [core 2.15.5]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.16 (main, Sep 22 2023, 17:57:55) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python3.9)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
# /usr/share/ansible/collections/ansible_collections
Collection            Version
--------------------- -------
ansible.posix         1.5.2
ansible.windows       1.13.0
cloud.common          2.1.3
community.general     5.2.0
community.vmware      3.5.0
community.windows     1.12.0
infoblox.nios_modules 1.4.1
vmware.vmware_rest    2.3.1
CONFIGURATION
CONFIG_FILE() = /etc/ansible/ansible.cfg
OS / ENVIRONMENT

vsphere 7.0, Windows VM

STEPS TO REPRODUCE
#######
# Play: Add disk from disk_personalities
#
#   Applies when Virtual_System_Operation == "Deploy" and sequentially
#   after vSphere deployment actions have completed with success for the
#   guest system.
#######
    - name: Diskpersonality Deploy
      vmware_guest_disk:
        validate_certs: false
        hostname: "{{ selected_vcenter }}"
        username: "{{ vcenter.username }}"
        password: "{{ vcenter.password }}"
        datacenter: "{{ selected_vcenter_datacenter }}"
        folder: "{{ selected_vcenter_folder }}"
        name: "{{ guest_input_name }}"
        disk:
          - size_gb: "{{ item.sizegb|int }}"
            type: thin
            datastore: "{{ selected_vmguest_datastore }}"
            state: present
            disk_mode: "persistent"
            scsi_type: lsilogic
            scsi_controller: "{{ item.controller|int }}"
            unit_number: "{{ item.unit|int }}"
      delegate_to: localhost
      loop: "{{ disks }}"
      when:
        - Virtual_System_Operation == "Deploy"
        # - vestal_run == true
EXPECTED RESULTS

I would expect the play to resize the disks in vSphere.

ACTUAL RESULTS
  File "<string>", line 3, in raise_from
failed: [localhost] (item={'controller': '0', 'scsi_type': 'paravirtual', 'unit': '2', 'sizegb': '60', 'mountpoint': 'e', 'os_disknum': '2'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "datacenter": "DC",
            "disk": [
                {
                    "autoselect_datastore": null,
                    "bus_sharing": "noSharing",
                    "cluster_disk": false,
                    "compatibility_mode": null,
                    "controller_number": null,
                    "controller_type": null,
                    "datastore": "vsanDatastore",
                    "destroy": true,
                    "disk_mode": "persistent",
                    "filename": null,
                    "iolimit": null,
                    "rdm_path": null,
                    "scsi_controller": 0,
                    "scsi_type": "lsilogic",
                    "shares": null,
                    "sharing": false,
                    "size": null,
                    "size_gb": 60,
                    "size_kb": null,
                    "size_mb": null,
                    "size_tb": null,
                    "state": "present",
                    "type": "thin",
                    "unit_number": 2
                }
            ],
            "folder": "Discovered virtual machine",
            "hostname": "vsphere.company.com",
            "moid": null,
            "name": "vm_test",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "proxy_host": null,
            "proxy_port": null,
            "use_instance_uuid": false,
            "username": "company\\\\username",
            "uuid": null,
            "validate_certs": false
        }
    },
    "item": {
        "controller": "0",
        "mountpoint": "e",
        "os_disknum": "2",
        "scsi_type": "paravirtual",
        "sizegb": "60",
        "unit": "2"
    },
    "msg": "Failed to manage disks for virtual machine 'vm_test' with exception : (\\"Parameters for device 'scsi0' may not be modified while the virtual machine is powered on.\\", None)"
@mariolenz
Copy link
Collaborator

mariolenz commented Apr 19, 2024

It looks like you're using community.vmware 3.5.0 but this is quite old. Do you run into the same issue with 3.11.2 / 4.2.0 3.11.3 / 4.3.0?

@kbreit-insight
Copy link

@mariolenz Sorry about the delay but 4.3.0 doesn't appear to fix it.

@SwiperNo
Copy link

SwiperNo commented May 17, 2024

Having this same issue as well. I noticed that people were stating they fixed their issue by adding scsi_type, but seems like it still does not work on my end either. It looks like they were using community version 2.8 instead. I may revert back to this.

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

No branches or pull requests

4 participants