Skip to content

Commit 34ebe17

Browse files
committed
Improved variable names, check of vCenter folder existence and correct download URLs
1 parent 091063a commit 34ebe17

File tree

7 files changed

+48
-36
lines changed

7 files changed

+48
-36
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ As it stands right now, the repo works for several installation usecases:
1515

1616
1. vSphere ESXi and vCenter 6.7 installed. For vCenter 6.5 please see a cautionary note below:
1717
2. A datacenter created with a vSphere host added to it, a datastore exists and has adequate capacity
18-
3. The playbook(s) assumes you are running a [helper node](https://github.com/RedHatOfficial/ocp4-helpernode) running in the same network to provide all the necessary services such as [DHCP/DNS/HAProxy as LB]. Also, the MAC addresses for the machines should match between helper repo and this. If not using the helper node, the minimum expectation is that the webserver and tftp server (for PXE boot) are running on the same external host, which we will then treat as a helper node.
18+
3. The playbook(s) assumes you are running a [helper node](https://github.com/RedHatOfficial/ocp4-helpernode) in the same network to provide all the necessary services such as [DHCP/DNS/HAProxy as LB]. Also, the MAC addresses for the machines should match between helper repo and this. If not using the helper node, the minimum expectation is that the webserver and tftp server (for PXE boot) are running on the same external host, which we will then treat as a helper node.
1919
4. The necessary services such as [DNS/LB(Load Balancer] must be up and running before this repo can be used
2020
5. Ansible (preferably latest) with **Python 3** on the machine where this repo is cloned. Before you install Ansible, install the `epel-release`, run `yum -y install epel-release`
2121

@@ -121,29 +121,35 @@ With all the details in hand from the prerequisites, populate the **group_vars/a
121121
122122
#### Option 1: DHCP + use of OVA template
123123
```sh
124-
ansible-playbook -i staging dhcp_ova.yml
124+
ansible-playbook --flush-cache -i staging dhcp_ova.yml
125125
```
126126
#### Option 2: DHCP + PXE boot
127127
```sh
128-
ansible-playbook -i staging dhcp_pxe.yml
128+
ansible-playbook --flush-cache -i staging dhcp_pxe.yml
129129
```
130130
#### Option 3: ISO + Static IPs
131131
```sh
132-
ansible-playbook -i staging static_ips.yml
132+
ansible-playbook --flush-cache -i staging static_ips.yml
133133
```
134134
#### Option 4: DHCP + use of OVA template in a Restricted Network
135135
```sh
136136
# Refer to restricted.md file for more details
137-
ansible-playbook -i staging restricted_ova.yml
137+
ansible-playbook --flush-cache -i staging restricted_ova.yml
138138
```
139139

140140
#### Miscellaneous
141-
* If vCenter folder already exists with the template because you set the vCenter the last time you ran the ansible playbook but want a fresh deployment of VMs **after** you have erased all the existing VMs in the folder, append the following to the command you chose in the above step
141+
* If you are re-running the installation playbook make sure to blow away any existing VMs (in `ocp4` folder) listed below:
142+
1. bootstrap
143+
2. masters
144+
3. workers
145+
4. `rhcos-vmware` template (if not using the extra param as shown below)
146+
* If a template by the name `rhcos-vmware` already exists in vCenter, you want to reuse it and skip the OVA **download** from Red Hat and **upload** into vCenter, use the following extra param.
142147

143148
```sh
144-
-e vcenter_preqs_met=true
149+
-e skip_ova=true
145150
```
146-
* If would rather want to clean all folders `bin`, `downloads`, `install-dir` and re-download all the artifacts, append the following to the command you chose in the first step
151+
152+
* If you would rather want to clean all folders `bin`, `downloads`, `install-dir` and re-download all the artifacts, append the following to the command you chose in the first step
147153
```sh
148154
-e clean=true
149155
```
@@ -159,7 +165,7 @@ ansible-playbook -i staging restricted_ova.yml
159165
2. master.ign and worker.ign
160166
3. base64 encoded files (append-bootstrap.64, master.64, worker.64) for (append-bootstrap.ign, master.ign, worker.ign) respectiviely. This step assumes you have **base64** installed and in your **$PATH**
161167
7. The **bootstrap.ign** is copied over to the web server in the designated location
162-
8. A folder is created in the vCenter under the mentioned datacenter and the template file is imported
168+
8. A folder is created in the vCenter under the mentioned datacenter and the template is imported
163169
9. The template file is edited to carry certain default settings and runtime parameters common to all the VMs
164170
10. VMs (bootstrap, master0-2, worker0-2) are generated in the designated folder and (in state of) **poweredon**
165171

@@ -169,6 +175,7 @@ If everything goes well you should be able to log into all of the machines using
169175

170176
```sh
171177
# Assuming you are able to resolve bootstrap.ocp4.example.com on this machine
178+
# Replace the bootstrap hostname with any of the master or worker hostnames
172179
ssh -i ~/.ssh/ocp4 [email protected]
173180
```
174181

@@ -203,6 +210,7 @@ To check if the registry information has been picked up:
203210
```sh
204211
# On Master or Bootstrap
205212
cat /etc/containers/registries.conf
213+
cat /root/.docker/config.json
206214
```
207215
To check if your certs have been picked up:
208216
```sh

group_vars/all.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ vcenter:
1717
vm_power_state: poweredon
1818
templateName: rhcos-vmware
1919
download:
20-
clients_url: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/4.4.3/
21-
dependencies_url: https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/4.4/latest/
20+
clients_url: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest
21+
dependencies_url: https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/latest/latest
2222
govc: https://github.com/vmware/govmomi/releases/download/v0.22.1/govc_linux_amd64.gz
2323
bootstrap_vms:
24-
- { name : "bootstrap", mac: "00:50:56:a8:aa:a1", ip: "192.168.86.181"}
24+
- { name: "bootstrap", macaddr: "00:50:56:a8:aa:a1", ipaddr: "192.168.86.181"}
2525
master_vms:
26-
- { name : "master0", mac: "00:50:56:a8:aa:a2", ip: "192.168.86.182"}
27-
- { name : "master1", mac: "00:50:56:a8:aa:a3", ip: "192.168.86.183"}
28-
- { name : "master2", mac: "00:50:56:a8:aa:a4", ip: "192.168.86.184"}
26+
- { name: "master0", macaddr: "00:50:56:a8:aa:a2", ipaddr: "192.168.86.182"}
27+
- { name: "master1", macaddr: "00:50:56:a8:aa:a3", ipaddr: "192.168.86.183"}
28+
- { name: "master2", macaddr: "00:50:56:a8:aa:a4", ipaddr: "192.168.86.184"}
2929
worker_vms:
30-
- { name : "worker0", mac: "00:50:56:a8:aa:a5", ip: "192.168.86.185"}
31-
- { name : "worker1", mac: "00:50:56:a8:aa:a6", ip: "192.168.86.186"}
32-
- { name : "worker2", mac: "00:50:56:a8:aa:a7", ip: "192.168.86.187"}
30+
- { name: "worker0", macaddr: "00:50:56:a8:aa:a5", ipaddr: "192.168.86.185"}
31+
- { name: "worker1", macaddr: "00:50:56:a8:aa:a6", ipaddr: "192.168.86.186"}
32+
- { name: "worker2", macaddr: "00:50:56:a8:aa:a7", ipaddr: "192.168.86.187"}
3333
static_ip:
3434
gateway: 192.168.86.1
3535
netmask: 255.255.255.0

restricted.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ In [group_vars/all.yml](group_vars/all.yml)'s registry dict, with rest being op
136136
Now that helper, registry and the automation configs are all set, lets run the installation with the command:
137137

138138
```sh
139-
# If vCenter folders exist
140-
ansible-playbook --flush-cache -i staging restricted_ova.yml -e vcenter_preqs_met=true
139+
# If rhcos-vmware template exists in the folder and you want to reuse it
140+
ansible-playbook --flush-cache -i staging restricted_ova.yml -e skip_ova=true
141141

142-
# If vCenter folders DONT exist
142+
# If rhcos-vmware template DOES NOT exist in the folder and you want to download/upload/create it
143143
ansible-playbook --flush-cache -i staging restricted_ova.yml
144144
```
145145

roles/dhcp_ova/tasks/main.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
url: "{{ download.ova }}"
99
dest: "{{ playbook_dir }}/downloads/{{vcenter.templateName}}.ova"
1010
validate_certs: no
11-
when: vcenter_preqs_met is not defined
11+
when: skip_ova is not defined
1212

1313
- name: Deploy the OVF template into the folder
1414
vmware_deploy_ovf:
@@ -25,15 +25,15 @@
2525
ova: "{{ playbook_dir }}/downloads/{{vcenter.templateName}}.ova"
2626
power_on: False
2727
validate_certs: False
28-
when: vcenter_preqs_met is not defined
28+
when: skip_ova is not defined
2929

3030
- name: Remove the Network Adapter
3131
command: "govc device.remove -vm {{ folder }}/{{ vcenter.templateName }} ethernet-0"
32-
when: vcenter_preqs_met is not defined
32+
when: skip_ova is not defined
3333

3434
- name: Update VM options on the template
3535
command: "govc vm.change -vm {{ folder }}/{{ vcenter.templateName }} -latency high -e=disk.EnableUUID=TRUE -e=guestinfo.ignition.config.data.encoding=base64 -e=guestinfo.ignition.config.data=blah"
36-
when: vcenter_preqs_met is not defined
36+
when: skip_ova is not defined
3737

3838
- name: "Bootstrap base64"
3939
debug:
@@ -69,7 +69,7 @@
6969
memory_reservation_lock: True
7070
networks:
7171
- name: "{{ vcenter.network }}"
72-
mac: "{{ item.mac }}"
72+
mac: "{{ item.macaddr }}"
7373
wait_for_ip_address: no
7474
customvalues:
7575
- key: guestinfo.ignition.config.data
@@ -97,7 +97,7 @@
9797
memory_reservation_lock: True
9898
networks:
9999
- name: "{{ vcenter.network }}"
100-
mac: "{{ item.mac }}"
100+
mac: "{{ item.macaddr }}"
101101
wait_for_ip_address: no
102102
customvalues:
103103
- key: guestinfo.ignition.config.data
@@ -125,7 +125,7 @@
125125
memory_reservation_lock: True
126126
networks:
127127
- name: "{{ vcenter.network }}"
128-
mac: "{{ item.mac }}"
128+
mac: "{{ item.macaddr }}"
129129
wait_for_ip_address: no
130130
customvalues:
131131
- key: guestinfo.ignition.config.data

roles/dhcp_pxe/tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
memory_reservation_lock: True
2020
networks:
2121
- name: "{{ vcenter.network }}"
22-
mac: "{{ item.mac }}"
22+
mac: "{{ item.macaddr }}"
2323
wait_for_ip_address: no
2424
loop: "{{ bootstrap_vms }}"
2525
- name: Create master VMs from the template
@@ -43,7 +43,7 @@
4343
memory_reservation_lock: True
4444
networks:
4545
- name: "{{ vcenter.network }}"
46-
mac: "{{ item.mac }}"
46+
mac: "{{ item.macaddr }}"
4747
wait_for_ip_address: no
4848
loop: "{{ master_vms }}"
4949

@@ -68,7 +68,7 @@
6868
memory_reservation_lock: True
6969
networks:
7070
- name: "{{ vcenter.network }}"
71-
mac: "{{ item.mac }}"
71+
mac: "{{ item.macaddr }}"
7272
wait_for_ip_address: no
7373
loop: "{{ worker_vms }}"
7474

roles/static_ips/tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
vars:
6565
machine_name: "{{ item.name }}"
6666
machine_type: bootstrap
67-
machine_ip: "{{ item.ip }}"
67+
machine_ip: "{{ item.ipaddr }}"
6868
template:
6969
src: kernel-params.j2
7070
dest: "{{role_path}}/files/{{item.name}}-kernel-params.txt"
@@ -74,7 +74,7 @@
7474
vars:
7575
machine_name: "{{ item.name }}"
7676
machine_type: master
77-
machine_ip: "{{ item.ip }}"
77+
machine_ip: "{{ item.ipaddr }}"
7878
template:
7979
src: kernel-params.j2
8080
dest: "{{role_path}}/files/{{item.name}}-kernel-params.txt"
@@ -84,7 +84,7 @@
8484
vars:
8585
machine_name: "{{ item.name }}"
8686
machine_type: worker
87-
machine_ip: "{{ item.ip }}"
87+
machine_ip: "{{ item.ipaddr }}"
8888
template:
8989
src: kernel-params.j2
9090
dest: "{{role_path}}/files/{{item.name}}-kernel-params.txt"

roles/vmware/tasks/main.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
- name: Create the vCenter folder by the same name as the cluster
1+
- name: Check if the vCenter folder already exists
2+
command: "govc folder.info {{ folder }}"
3+
register: folder_exists
4+
5+
- name: Create the vCenter folder by the same name as the cluster, only if it doesn't exist
26
command: "govc folder.create {{ folder }}"
3-
when: vcenter_preqs_met is not defined
7+
when: folder_exists.rc != 0

0 commit comments

Comments
 (0)