Simply  Seth
Simply Seth

Reputation: 3496

how to add a disk to vcenter guest using Ansible

I'm attempting to add a second disk to a vmware vcenter instance.

Here is what I have:

- name: "Modifying ..."
  local_action:
    module: vsphere_guest
    vcenter_hostname: "{{ vcenter.hostname }}"
    username: "{{ vcenter_user[datacenter]['username'] }}"
    password: "{{ vcenter_user[datacenter]['password'] }}"
    guest: "{{ inventory_hostname }}"
    # Looky looky heeya ...#
    state: reconfigured
    ########################
    vm_extra_config:
      vcpu.hotadd: yes
      mem.hotadd:  yes
      notes: "{{ datacenter }} {{ purpose |replace('_',' ') }}"
    vm_disk: 
      disk1:
        size_gb: 50
        type: thin
        datastore: "{{ vcenter.datastore }}"
      disk2:
        size_gb: 200
        type: thin
        datastore: "{{ vcenter.datastore }}"
    vm_hardware:
      memory_mb: "{{ vm.memory|int }}"
      num_cpus: "{{ vm.cpus|int }}"
      osid: "{{ os.id }}"
    esxi:
      datacenter: "{{ esxi.datacenter }}"
      hostname: "{{ esxi.hostname }}"

So the vcenter sees the reconfigure and there are no errors displayed.

Also there are no errors on the console when I runt the playbook.

It just simply does not add the second disk.

So is there a way to add the disk or will I have to write a python script to do it?

Thanks.

Upvotes: 1

Views: 4311

Answers (1)

abuzze
abuzze

Reputation: 1561

The function def reconfigure_vm in the vsphere_guest module does only include code for changing the RAM and the CPU. But i don't see any code for changing the other hardware. This is only possible while creating a new VM at the moment.

Upvotes: 1

Related Questions