我想使用Ansible将新的虚拟机添加到现有的VMware虚拟机/主机组(DRS组)中。但是,使用下面列出的模块,将始终学习整个组,并且只添加这一个虚拟机。如何在不删除已有虚拟机的情况下将新虚拟机添加到DRS角色?
- name: "Create DRS VM group"
delegate_to: localhost
vmware_drs_group:
hostname: "{{ vcenter_hostname }}"
password: "{{ vcenter_password }}"
username: "{{ vcenter_username }}"
cluster_name: DC0_C0
datacenter_name: DC0
group_name: TEST_VM_01
vms:
- DC0_C0_RP0_VM0
- DC0_C0_RP0_VM1
state: present发布于 2021-06-09 22:51:13
这是有效的:
- name: "Get information about VM/Host groups (DRS VM groups)"
register: cluster_drs_group_info
vmware_drs_group_info:
hostname: "{{ vcenter_hostname }}"
password: "{{ vcenter_password }}"
username: "{{ vcenter_username }}"
validate_certs: False
cluster_name: "{{ cluster}}"
delegate_to: localhost
- name: "Create VM list"
set_fact:
linux_drs_vms: "{{ cluster_drs_group_info.drs_group_info.Cluster[0].vms }} + ['{{ vm_name }}']"
- name: "Create VM/Host groups (DRS VM groups)"
delegate_to: localhost
vmware_drs_group:
hostname: "{{ vcenter_hostname }}"
password: "{{ vcenter_password }}"
username: "{{ vcenter_username }}"
validate_certs: False
cluster_name: "{{ cluster }}"
datacenter_name: "{{ datacenter }}"
group_name: "VMGroup - LinuxVMs"
state: present
vms: "{{ item }}"
loop:
- "{{ linux_drs_vms }}"https://stackoverflow.com/questions/67901231
复制相似问题