-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfull_vsphere.yaml
252 lines (230 loc) · 8.98 KB
/
full_vsphere.yaml
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
---
- hosts: localhost
gather_facts: false
become: false
vars_files:
- vars/config.yaml
vars_prompt:
- name: cluster_name
prompt: Specify cluster name
private: false
tasks:
- name: Destroy Full cluster
when: action == "delete" or action == "destroy"
block:
- name: Delete A dns record
amazon.aws.route53:
state: absent
zone: "{{ dns_zone }}"
record: "{{ item }}.{{ cluster_name}}.{{ cluster_domain }}"
type: A
loop:
- "api"
- "*.apps"
- name: Stop Full VM - masters
community.vmware.vmware_guest:
state: poweredoff
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
cluster: "Cluster-1"
datacenter: "SDDC-Datacenter"
folder: "/Workloads/{{ env_type }}-{{ guid }}"
name: "{{ ocp_vmname_master_prefix }}-{{ _index }}"
ignore_errors: true
loop: "{{ query('sequence', 'start=1 end=3') }}"
loop_control:
loop_var: _index
- name: Delete Full VM - masters
community.vmware.vmware_guest:
state: absent
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
cluster: "Cluster-1"
datacenter: "SDDC-Datacenter"
folder: "/Workloads/{{ env_type }}-{{ guid }}"
name: "{{ ocp_vmname_master_prefix }}-{{ _index }}"
loop: "{{ query('sequence', 'start=1 end=3') }}"
loop_control:
loop_var: _index
- name: Stop Full VM - workers
community.vmware.vmware_guest:
state: poweredoff
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
cluster: "Cluster-1"
datacenter: "SDDC-Datacenter"
folder: "/Workloads/{{ env_type }}-{{ guid }}"
name: "{{ ocp_vmname_worker_prefix }}-{{ _index }}"
ignore_errors: true
loop: "{{ query('sequence', 'start=1 end=3') }}"
loop_control:
loop_var: _index
- name: Delete Full VM - workers
community.vmware.vmware_guest:
state: absent
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
cluster: "Cluster-1"
datacenter: "SDDC-Datacenter"
folder: "/Workloads/{{ env_type }}-{{ guid }}"
name: "{{ ocp_vmname_worker_prefix }}-{{ _index }}"
loop: "{{ query('sequence', 'start=1 end=3') }}"
loop_control:
loop_var: _index
- name: Remove Assisted Installer Cluster
agonzalezrh.install_openshift.delete_cluster:
cluster_id: "{{ cluster_id }}"
offline_token: "{{ offline_token }}"
- name: Create Full cluster
when: action == "create"
block:
- name: Add A dns record - api
amazon.aws.route53:
state: present
overwrite: true
zone: "{{ dns_zone }}"
record: "{{ item }}.{{ cluster_name}}.{{ cluster_domain }}"
type: A
value: "{{ network_prefix }}.220"
ttl: 30
loop:
- "api"
- name: Add A dns record - apps
amazon.aws.route53:
state: present
overwrite: true
zone: "{{ dns_zone }}"
record: "{{ item }}.{{ cluster_name}}.{{ cluster_domain }}"
type: A
value: "{{ network_prefix }}.221"
ttl: 30
loop:
- "*.apps"
- name: Create Assisted Installer Cluster
agonzalezrh.install_openshift.create_cluster:
name: "{{ cluster_name }}"
openshift_version: "{{ cluster_version }}"
base_dns_domain: "{{ cluster_domain }}"
offline_token: "{{ offline_token }}"
pull_secret: "{{ pull_secret }}"
high_availability_mode: "Full"
schedulable_masters: false
service_networks:
- cidr: "172.31.0.0/16"
machine_networks:
- cidr: "{{ network_prefix }}.0/24"
api_vip: "{{ network_prefix }}.220"
api_vips:
- ip: "{{ network_prefix }}.220"
ingress_vip: "{{ network_prefix }}.221"
ingress_vips:
- ip: "{{ network_prefix }}.221"
register: newcluster
- name: Create Infrastructure environment
agonzalezrh.install_openshift.create_infra_env:
name: "{{ cluster_name }}-infra-env"
image_type: "{{ cluster_iso_type }}"
cluster_id: "{{ newcluster.result.id }}"
ssh_authorized_key: "{{ ssh_authorized_key }}"
offline_token: "{{ offline_token }}"
pull_secret: "{{ pull_secret }}"
# static_network_config: "{{ static_network_config }}"
register: newinfraenv
- name: Create directory for downloaded credential files
ansible.builtin.file:
state: directory
path: "{{ output_dir }}/{{ cluster_name }}"
recurse: true
- name: Upload ISO image to vSphere
import_tasks: tasks/vsphere/upload_iso.yaml
vars:
image_url: "{{ newinfraenv.result.download_url }}"
- name: Create a three master VMs for Full cluster
include_tasks: tasks/vsphere/create_masters.yaml
vars:
image_url: "{{ newinfraenv.result.download_url }}"
vmname: "{{ ocp_vmname_master_prefix }}-{{ _index }}"
loop: "{{ query('sequence', 'start=1 end=3') }}"
loop_control:
loop_var: _index
- name: Create a three worker VMs for Full cluster
include_tasks: tasks/vsphere/create_workers.yaml
vars:
image_url: "{{ newinfraenv.result.download_url }}"
vmname: "{{ ocp_vmname_worker_prefix }}-{{ _index }}"
loop: "{{ query('sequence', 'start=1 end=3') }}"
loop_control:
loop_var: _index
- name: Wait for the hosts to be ready
agonzalezrh.install_openshift.wait_for_hosts:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
expected_hosts: 6
infra_env_id: "{{ newinfraenv.result.id }}"
configure_hosts:
- hostname: master-{{ cluster_name }}-1
role: master
- hostname: master-{{ cluster_name }}-2
role: master
- hostname: master-{{ cluster_name }}-3
role: master
- hostname: worker-{{ cluster_name }}-1
role: worker
- hostname: worker-{{ cluster_name }}-2
role: worker
- hostname: worker-{{ cluster_name }}-3
role: worker
wait_timeout: 600
- name: Start cluster installation
agonzalezrh.install_openshift.install_cluster:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
wait_timeout: 1200
- name: Obtain OpenShift cluster credentials
register: credentials
agonzalezrh.install_openshift.get_credentials:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
- name: Display credentials
debug:
var: credentials.result
- name: Downloads OpenShift cluster credentials
agonzalezrh.install_openshift.download_credentials:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
file_name: "{{ item }}"
dest: "{{ output_dir }}/{{ cluster_name }}/{{ item }}"
loop:
- kubeadmin-password
- kubeconfig
- kubeconfig-noingress
- name: Scale router pod to the number of workers
environment:
KUBECONFIG: "{{ output_dir }}/{{ cluster_name }}/kubeconfig"
kubernetes.core.k8s:
state: patched
kind: IngressController
name: default
namespace: openshift-ingress-operator
merge_type: merge
definition:
spec:
replicas: 3
- name: Downloads OpenShift cluster files
agonzalezrh.install_openshift.download_files:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
file_name: "{{ item }}"
dest: "{{ output_dir }}/{{ cluster_name }}/{{ item }}"
loop:
- bootstrap.ign
- master.ign
- metadata.json
- worker.ign
- install-config.yaml
- custom_manifests.json
- custom_manifests.yaml