diff --git a/README.md b/README.md index 345efb0..d940801 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ As it stands right now, the repo works for several installation usecases: 1. vSphere ESXi and vCenter 6.7 installed. For vCenter 6.5 please see a cautionary note below: 2. A datacenter created with a vSphere host added to it, a datastore exists and has adequate capacity -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. +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. 4. The necessary services such as [DNS/LB(Load Balancer] must be up and running before this repo can be used 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` @@ -121,29 +121,35 @@ With all the details in hand from the prerequisites, populate the **group_vars/a #### Option 1: DHCP + use of OVA template ```sh -ansible-playbook -i staging dhcp_ova.yml +ansible-playbook --flush-cache -i staging dhcp_ova.yml ``` #### Option 2: DHCP + PXE boot ```sh -ansible-playbook -i staging dhcp_pxe.yml +ansible-playbook --flush-cache -i staging dhcp_pxe.yml ``` #### Option 3: ISO + Static IPs ```sh -ansible-playbook -i staging static_ips.yml +ansible-playbook --flush-cache -i staging static_ips.yml ``` #### Option 4: DHCP + use of OVA template in a Restricted Network ```sh # Refer to restricted.md file for more details -ansible-playbook -i staging restricted_ova.yml +ansible-playbook --flush-cache -i staging restricted_ova.yml ``` #### Miscellaneous -* 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 +* If you are re-running the installation playbook make sure to blow away any existing VMs (in `ocp4` folder) listed below: + 1. bootstrap + 2. masters + 3. workers + 4. `rhcos-vmware` template (if not using the extra param as shown below) +* 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. ```sh - -e vcenter_preqs_met=true + -e skip_ova=true ``` -* 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 + +* 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 ```sh -e clean=true ``` @@ -159,7 +165,7 @@ ansible-playbook -i staging restricted_ova.yml 2. master.ign and worker.ign 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** 7. The **bootstrap.ign** is copied over to the web server in the designated location -8. A folder is created in the vCenter under the mentioned datacenter and the template file is imported +8. A folder is created in the vCenter under the mentioned datacenter and the template is imported 9. The template file is edited to carry certain default settings and runtime parameters common to all the VMs 10. VMs (bootstrap, master0-2, worker0-2) are generated in the designated folder and (in state of) **poweredon** @@ -169,6 +175,7 @@ If everything goes well you should be able to log into all of the machines using ```sh # Assuming you are able to resolve bootstrap.ocp4.example.com on this machine +# Replace the bootstrap hostname with any of the master or worker hostnames ssh -i ~/.ssh/ocp4 core@bootstrap.ocp4.example.com ``` @@ -203,6 +210,7 @@ To check if the registry information has been picked up: ```sh # On Master or Bootstrap cat /etc/containers/registries.conf +cat /root/.docker/config.json ``` To check if your certs have been picked up: ```sh diff --git a/group_vars/all.yml b/group_vars/all.yml index 0d07d14..6c64c3b 100755 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -17,19 +17,19 @@ vcenter: vm_power_state: poweredon templateName: rhcos-vmware download: - clients_url: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/4.4.3/ - dependencies_url: https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/4.4/latest/ + clients_url: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest + dependencies_url: https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/latest/latest govc: https://github.com/vmware/govmomi/releases/download/v0.22.1/govc_linux_amd64.gz bootstrap_vms: - - { name : "bootstrap", mac: "00:50:56:a8:aa:a1", ip: "192.168.86.181"} + - { name: "bootstrap", macaddr: "00:50:56:a8:aa:a1", ipaddr: "192.168.86.181"} master_vms: - - { name : "master0", mac: "00:50:56:a8:aa:a2", ip: "192.168.86.182"} - - { name : "master1", mac: "00:50:56:a8:aa:a3", ip: "192.168.86.183"} - - { name : "master2", mac: "00:50:56:a8:aa:a4", ip: "192.168.86.184"} + - { name: "master0", macaddr: "00:50:56:a8:aa:a2", ipaddr: "192.168.86.182"} + - { name: "master1", macaddr: "00:50:56:a8:aa:a3", ipaddr: "192.168.86.183"} + - { name: "master2", macaddr: "00:50:56:a8:aa:a4", ipaddr: "192.168.86.184"} worker_vms: - - { name : "worker0", mac: "00:50:56:a8:aa:a5", ip: "192.168.86.185"} - - { name : "worker1", mac: "00:50:56:a8:aa:a6", ip: "192.168.86.186"} - - { name : "worker2", mac: "00:50:56:a8:aa:a7", ip: "192.168.86.187"} + - { name: "worker0", macaddr: "00:50:56:a8:aa:a5", ipaddr: "192.168.86.185"} + - { name: "worker1", macaddr: "00:50:56:a8:aa:a6", ipaddr: "192.168.86.186"} + - { name: "worker2", macaddr: "00:50:56:a8:aa:a7", ipaddr: "192.168.86.187"} static_ip: gateway: 192.168.86.1 netmask: 255.255.255.0 diff --git a/restricted.md b/restricted.md index 6db0d2b..945721d 100644 --- a/restricted.md +++ b/restricted.md @@ -136,10 +136,10 @@ In [group_vars/all.yml](group_vars/all.yml)'s registry dict, with rest being op Now that helper, registry and the automation configs are all set, lets run the installation with the command: ```sh -# If vCenter folders exist -ansible-playbook --flush-cache -i staging restricted_ova.yml -e vcenter_preqs_met=true +# If rhcos-vmware template exists in the folder and you want to reuse it +ansible-playbook --flush-cache -i staging restricted_ova.yml -e skip_ova=true -# If vCenter folders DONT exist +# If rhcos-vmware template DOES NOT exist in the folder and you want to download/upload/create it ansible-playbook --flush-cache -i staging restricted_ova.yml ``` diff --git a/roles/dhcp_ova/tasks/main.yml b/roles/dhcp_ova/tasks/main.yml index 9067cb0..0c45ff7 100755 --- a/roles/dhcp_ova/tasks/main.yml +++ b/roles/dhcp_ova/tasks/main.yml @@ -8,7 +8,7 @@ url: "{{ download.ova }}" dest: "{{ playbook_dir }}/downloads/{{vcenter.templateName}}.ova" validate_certs: no - when: vcenter_preqs_met is not defined + when: skip_ova is not defined - name: Deploy the OVF template into the folder vmware_deploy_ovf: @@ -25,15 +25,15 @@ ova: "{{ playbook_dir }}/downloads/{{vcenter.templateName}}.ova" power_on: False validate_certs: False - when: vcenter_preqs_met is not defined + when: skip_ova is not defined - name: Remove the Network Adapter command: "govc device.remove -vm {{ folder }}/{{ vcenter.templateName }} ethernet-0" - when: vcenter_preqs_met is not defined + when: skip_ova is not defined - name: Update VM options on the template 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" - when: vcenter_preqs_met is not defined + when: skip_ova is not defined - name: "Bootstrap base64" debug: @@ -69,7 +69,7 @@ memory_reservation_lock: True networks: - name: "{{ vcenter.network }}" - mac: "{{ item.mac }}" + mac: "{{ item.macaddr }}" wait_for_ip_address: no customvalues: - key: guestinfo.ignition.config.data @@ -97,7 +97,7 @@ memory_reservation_lock: True networks: - name: "{{ vcenter.network }}" - mac: "{{ item.mac }}" + mac: "{{ item.macaddr }}" wait_for_ip_address: no customvalues: - key: guestinfo.ignition.config.data @@ -125,7 +125,7 @@ memory_reservation_lock: True networks: - name: "{{ vcenter.network }}" - mac: "{{ item.mac }}" + mac: "{{ item.macaddr }}" wait_for_ip_address: no customvalues: - key: guestinfo.ignition.config.data diff --git a/roles/dhcp_pxe/tasks/main.yml b/roles/dhcp_pxe/tasks/main.yml index 11781f8..56ace39 100755 --- a/roles/dhcp_pxe/tasks/main.yml +++ b/roles/dhcp_pxe/tasks/main.yml @@ -19,7 +19,7 @@ memory_reservation_lock: True networks: - name: "{{ vcenter.network }}" - mac: "{{ item.mac }}" + mac: "{{ item.macaddr }}" wait_for_ip_address: no loop: "{{ bootstrap_vms }}" - name: Create master VMs from the template @@ -43,7 +43,7 @@ memory_reservation_lock: True networks: - name: "{{ vcenter.network }}" - mac: "{{ item.mac }}" + mac: "{{ item.macaddr }}" wait_for_ip_address: no loop: "{{ master_vms }}" @@ -68,7 +68,7 @@ memory_reservation_lock: True networks: - name: "{{ vcenter.network }}" - mac: "{{ item.mac }}" + mac: "{{ item.macaddr }}" wait_for_ip_address: no loop: "{{ worker_vms }}" diff --git a/roles/static_ips/tasks/main.yml b/roles/static_ips/tasks/main.yml index ec649c6..f5d0203 100644 --- a/roles/static_ips/tasks/main.yml +++ b/roles/static_ips/tasks/main.yml @@ -64,7 +64,7 @@ vars: machine_name: "{{ item.name }}" machine_type: bootstrap - machine_ip: "{{ item.ip }}" + machine_ip: "{{ item.ipaddr }}" template: src: kernel-params.j2 dest: "{{role_path}}/files/{{item.name}}-kernel-params.txt" @@ -74,7 +74,7 @@ vars: machine_name: "{{ item.name }}" machine_type: master - machine_ip: "{{ item.ip }}" + machine_ip: "{{ item.ipaddr }}" template: src: kernel-params.j2 dest: "{{role_path}}/files/{{item.name}}-kernel-params.txt" @@ -84,7 +84,7 @@ vars: machine_name: "{{ item.name }}" machine_type: worker - machine_ip: "{{ item.ip }}" + machine_ip: "{{ item.ipaddr }}" template: src: kernel-params.j2 dest: "{{role_path}}/files/{{item.name}}-kernel-params.txt" diff --git a/roles/vmware/tasks/main.yml b/roles/vmware/tasks/main.yml index 2cb89d7..b0e7a88 100755 --- a/roles/vmware/tasks/main.yml +++ b/roles/vmware/tasks/main.yml @@ -1,3 +1,7 @@ - - name: Create the vCenter folder by the same name as the cluster + - name: Check if the vCenter folder already exists + command: "govc folder.info {{ folder }}" + register: folder_exists + + - name: Create the vCenter folder by the same name as the cluster, only if it doesn't exist command: "govc folder.create {{ folder }}" - when: vcenter_preqs_met is not defined + when: folder_exists.rc != 0