vmotion condition

I am trying to perform vmotion of multiple VMs between 2 ESXi hosts using the vmare_vmotion module. We need to set a cap for memory utilization of the destination host to <= 70% and the storage utilization to <= 90%.

Required result: VMs have to be migrated until the memory and storage utilization has reached. The loop should stop VM migration once the memory & storage threshold has reached.

  • name: Perform storage vMotion and host vMotion of virtual machine
    vmware_vmotion:
    hostname: “{{ running_host }}”
    username: “{{ esxi_user }}”
    password: “{{ esxi_pass }}”
    validate_certs: no
    vm_name: “{{ item.guest_name }}”
    destination_host: “{{ destination_host }}”
    destination_datastore: “{{ item.name }}”
    delegate_to: localhost
    with_nested:
  • “{{vm_info.virtual_machines}}”
  • “{{ansible_datastore}}”

Any inputs is highly appreciated.

Real-time memory and datastore calculation using the pre-defined module for VMware.Please provide if this is achievable in Ansible or not.

Thanks,
Mani

Can we invoke any script to capture the memory and datastore utilization?

Hi Mani,

Your best bet would be to use PowerCLI, https://communities.vmware.com/thread/539904?start=15&tstart=0

Hi David,

Thank you for the info.