feat(vmware): add hypervisor.node for ESXi host pinning (mutually exclusive with cluster)
This commit is contained in:
@@ -47,6 +47,7 @@ hypervisor_defaults:
|
||||
username: ""
|
||||
password: ""
|
||||
host: ""
|
||||
node: ""
|
||||
storage: ""
|
||||
datacenter: ""
|
||||
cluster: ""
|
||||
@@ -139,7 +140,7 @@ hypervisor_required_fields:
|
||||
hypervisor: [url, username, password, host, storage]
|
||||
system: [id]
|
||||
vmware:
|
||||
hypervisor: [url, username, password, datacenter, cluster, storage]
|
||||
hypervisor: [url, username, password, datacenter, storage]
|
||||
system: []
|
||||
xen:
|
||||
hypervisor: []
|
||||
|
||||
@@ -166,6 +166,23 @@
|
||||
label: "hypervisor.{{ item }}"
|
||||
no_log: true
|
||||
|
||||
- name: Validate VMware placement (cluster or node required, mutually exclusive)
|
||||
when:
|
||||
- system_cfg.type == "virtual"
|
||||
- hypervisor_type == "vmware"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- >-
|
||||
(hypervisor_cfg.cluster | default('') | string | length > 0)
|
||||
or (hypervisor_cfg.node | default('') | string | length > 0)
|
||||
- >-
|
||||
(hypervisor_cfg.cluster | default('') | string | length == 0)
|
||||
or (hypervisor_cfg.node | default('') | string | length == 0)
|
||||
fail_msg: >-
|
||||
VMware requires either hypervisor.cluster or hypervisor.node (mutually exclusive).
|
||||
cluster targets a vSphere cluster; node targets a specific ESXi host.
|
||||
quiet: true
|
||||
|
||||
- name: Validate hypervisor-specific required system fields
|
||||
when:
|
||||
- system_cfg.type == "virtual"
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
{%- endfor -%}
|
||||
{{ ns.out }}
|
||||
community.vmware.vmware_guest:
|
||||
cluster: "{{ hypervisor_cfg.cluster }}"
|
||||
cluster: "{{ hypervisor_cfg.cluster if (hypervisor_cfg.node | default('') | length == 0) else omit }}"
|
||||
esxi_hostname: "{{ hypervisor_cfg.node if (hypervisor_cfg.node | default('') | length > 0) else omit }}"
|
||||
folder: "{{ system_cfg.path if system_cfg.path | string | length > 0 else omit }}"
|
||||
name: "{{ hostname }}"
|
||||
# Generic guest ID — VMware auto-detects OS post-install
|
||||
|
||||
Reference in New Issue
Block a user