The vmware_vm_vm_drs_rule module

With this module, you can configure VMware DRS Affinity rules. These allow you to control the placement of virtual machines within your cluster:

- name: Create DRS Affinity Rule for VM-VM  vmware_vm_vm_drs_rule:    hostname: "{{ vsphere_host }}"    username: "{{ vsphere_username }}"    password: "{{ vsphere_password }}"    cluster_name: "cluster"    vms: "{{ item }}"    drs_rule_name: ""    enabled: "True"    mandatory: "True"    affinity_rule: "True"  with_items:    - "example_vm"    - "another_example_vm"

In the previous example, we are creating a rule that will result in the VMs example_vm and another_example_vm never running on the same physical host.

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.