-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhost_groups.yml
42 lines (40 loc) · 1.69 KB
/
host_groups.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
- name: "Configure host groups"
vars:
host_group_map: {}
module_defaults:
group/vmware:
hostname: "{{ hostvars[groups['vc'][0]].NESTEDVMIP }}"
username: 'administrator@{{ vc_fact_domain }}'
password: "{{ vc_fact_password }}"
validate_certs: false
block:
- name: "Create DRS Host group variables"
vars:
affinty_type: "{{ item.zoneAffinity | default('ComputeCluster') }}"
ansible.builtin.set_fact:
host_group_map: "{{ host_group_map | default({}) | combine({item.name: []}) }}"
when: "item.server == vcenter and affinty_type == 'HostGroup'"
loop: "{{ vcenter_failure_domains }}"
- name: "Populate DRS Host group variables"
vars:
affinty_type: "{{ item.zoneAffinity | default('ComputeCluster') }}"
ansible.builtin.set_fact:
host_group_map: "{{ host_group_map | default({}) | combine({item.name: host_group_map[item.name] + [hostvars[groups['esxi'][fd_idx]].NESTEDVMIP]}) }}"
when: "item.server == vcenter and affinty_type == 'HostGroup'"
loop: "{{ host_indexed_failure_domains }}"
loop_control:
index_var: fd_idx
- name: "Create DRS Host group"
vars:
affinty_type: "{{ item.zoneAffinity | default('ComputeCluster') }}"
community.vmware.vmware_drs_group:
cluster_name: '{{ item.topology.computeCluster.split("/")[-1] }}'
datacenter_name: "{{ item.topology.datacenter }}"
group_name: "{{ item.name }}"
hosts: "{{ host_group_map[item.name] }}"
state: present
when: "item.server == vcenter and affinty_type == 'HostGroup'"
loop: "{{ host_indexed_failure_domains }}"
loop_control:
index_var: fd_idx