forked from RedHatOfficial/ocp4-vsphere-upi-automation
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.yml
executable file
·133 lines (125 loc) · 4.44 KB
/
main.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
- name: Copy append-bootstrap.ign file into install-dir
template:
src: "append-bootstrap.ign.j2"
dest: "{{ playbook_dir }}/install-dir/append-bootstrap.ign"
- name: Download the ova file
get_url:
url: "{{ download.ova }}"
dest: "{{ playbook_dir }}/downloads/{{vcenter.template_name}}.ova"
validate_certs: no
when: skip_ova is not defined
- name: Deploy the OVF template into the folder
vmware_deploy_ovf:
hostname: "{{ vcenter.ip }}"
username: "{{ vcenter.admin_username }}"
password: "{{ vcenter.admin_password }}"
datacenter: "{{ vcenter.datacenter }}"
datastore: "{{ vcenter.datastore }}"
folder: "{{ vcenter.folder_absolute_path }}"
name: '{{ vcenter.template_name }}'
allow_duplicates: False
disk_provisioning: thin
networks: "{u'VM Network':u'{{ vcenter.network }}'}"
ova: "{{ playbook_dir }}/downloads/{{vcenter.template_name}}.ova"
power_on: False
validate_certs: False
when: skip_ova is not defined
- name: Remove the Network Adapter
command: "govc device.remove -vm {{ vcenter.folder_absolute_path }}/{{ vcenter.template_name }} ethernet-0"
when: skip_ova is not defined
- name: Update VM options on the template
command: "govc vm.change -vm {{ vcenter.folder_absolute_path }}/{{ vcenter.template_name }} -latency high -e=disk.EnableUUID=TRUE -e=guestinfo.ignition.config.data.encoding=base64 -e=guestinfo.ignition.config.data=blah"
when: skip_ova is not defined
- name: "Bootstrap base64"
debug:
msg: "{{ appendBootstrapContent }}"
verbosity: 1
- name: "Master base64"
debug:
msg: "{{ masterContent }}"
verbosity: 1
- name: "Worker base64 "
debug:
msg: "{{ workerContent }}"
verbosity: 1
- name: Create bootstrap VM from the template
vmware_guest:
hostname: "{{ vcenter.ip }}"
username: "{{ vcenter.service_account_username }}"
password: "{{ vcenter.service_account_password }}"
datacenter: "{{ vcenter.datacenter }}"
validate_certs: no
folder: "{{ vcenter.folder_absolute_path }}"
name: "{{ item.name }}"
state: "{{ vcenter.vm_power_state }}"
template: "{{ vcenter.template_name }}"
disk:
- size_gb: 120
type: thin
datastore: "{{ vcenter.datastore }}"
hardware:
memory_mb: 16384
num_cpus: 4
memory_reservation_lock: True
networks:
- name: "{{ vcenter.network }}"
mac: "{{ item.macaddr }}"
wait_for_ip_address: no
customvalues:
- key: guestinfo.ignition.config.data
value: "{{ appendBootstrapContent }}"
loop: "{{ bootstrap_vms }}"
- name: Create master VMs from ther template
vmware_guest:
hostname: "{{ vcenter.ip }}"
username: "{{ vcenter.service_account_username }}"
password: "{{ vcenter.service_account_password }}"
datacenter: "{{ vcenter.datacenter }}"
validate_certs: no
folder: "{{ vcenter.folder_absolute_path }}"
name: "{{ item.name }}"
state: "{{ vcenter.vm_power_state }}"
template: "{{ vcenter.template_name }}"
disk:
- size_gb: 120
type: thin
datastore: "{{ vcenter.datastore }}"
hardware:
memory_mb: 16384
num_cpus: 4
memory_reservation_lock: True
networks:
- name: "{{ vcenter.network }}"
mac: "{{ item.macaddr }}"
wait_for_ip_address: no
customvalues:
- key: guestinfo.ignition.config.data
value: "{{ masterContent }}"
loop: "{{ master_vms }}"
- name: Create worker VMs from the template
vmware_guest:
hostname: "{{ vcenter.ip }}"
username: "{{ vcenter.service_account_username }}"
password: "{{ vcenter.service_account_password }}"
datacenter: "{{ vcenter.datacenter }}"
validate_certs: no
folder: "{{ vcenter.folder_absolute_path }}"
name: "{{ item.name }}"
state: "{{ vcenter.vm_power_state }}"
template: "{{ vcenter.template_name }}"
disk:
- size_gb: 120
type: thin
datastore: "{{ vcenter.datastore }}"
hardware:
memory_mb: 16384
num_cpus: 4
memory_reservation_lock: True
networks:
- name: "{{ vcenter.network }}"
mac: "{{ item.macaddr }}"
wait_for_ip_address: no
customvalues:
- key: guestinfo.ignition.config.data
value: "{{ workerContent }}"
loop: "{{ worker_vms }}"