Hi Shiva,

You can do like this -

---
- hosts: localhost
  gather_facts: false
  vars_files:
    - vcenter_vars.yml
  tasks:
  - name: Resize to 10GB from 4GB
    vmware_guest_disk:
      validate_certs: False
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_username }}'
      password: '{{ vcenter_password }}'
      datacenter: Asia-Datacenter1
      name: vm_8046
      disk:
        - datastore: "ds_171_2"
          scsi_controller: 0
          scsi_type: 'paravirtual'
          size_gb: 10
          state: present
          unit_number: 0

TASK [Resize to 10GB from 4GB]
**********************************************************************
task path: /Volumes/data/src/playbooks/vmware/vmware_guest_disk_resize.yml:7
redirecting (type: modules) ansible.builtin.vmware_guest_disk to
community.vmware.vmware_guest_disk
changed: [localhost] => {"changed": true, "disk_changes": {"0": "Disk size
increased."}, "disk_data": {"0": {"backing_datastore": "ds_171_2",
"backing_disk_mode": "persistent", "backing_eagerlyscrub": false,
"backing_filename": "[ds_171_2] vm_8046/vm_8046.vmdk",
"backing_thinprovisioned": false, "backing_writethrough": false,
"capacity_in_bytes": 10737418240, "capacity_in_kb": 10485760,
"controller_key": 1000, "iolimit_limit": -1, "iolimit_shares_level":
"normal", "iolimit_shares_limit": 1000, "key": 2000, "label": "Hard disk
1", "shares_level": "normal", "shares_limit": 1000, "summary": "10,485,760
KB", "unit_number": 0}}}


If you have multiple disks, you need to gather information about all disk
and pass it to vmware_guest_disk before making any changes.

You can take the help of this playbook
https://github.com/Akasurde/ansible-reproducers/blob/master/55999/i55999.yml.
(This playbook adds a new disk to configuration, but can be modified to
resize disk as well)

On Tue, Jun 9, 2020 at 11:48 AM JC JC <[email protected]> wrote:

> Hi Team,
>
>
>
> I'm looking for ansible script to resize my Existing Virtual machine
> Primary Hard disk (VMDK).
>
>
>
> Cheers
>
> Shiva Shankar S
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/43fc8a33-8db1-46bb-8875-ca8333c3caeeo%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/43fc8a33-8db1-46bb-8875-ca8333c3caeeo%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Thanks,
Abhijeet Kasurde

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFwWkHro90sG79kxBkKsFgG-Bchne0v6q0TnLnEtiOn4_6hGWw%40mail.gmail.com.

Reply via email to