############################################################# # Run this script from the same location of the ign files # ############################################################# ########################## Installing govc ################################################# # mkdir $HOME/bin # cd $HOME/bin # wget https:////github.com/vmware/govmomi/releases/download/v0.22.1/govc_linux_amd64.gz # gunzip govc_linux_amd64.gz && mv govc_linux_amd64 govc && chmod +x govc ############################################################################################ ######################## # Using govc to deploy # # 1x Bootstrap # # 3x Masters # # 3x Workers # ######################## ######VARIABLES##### export GOVC_URL='10.31.xx.xx' export GOVC_USERNAME='xxxxx@vsphere.local' export GOVC_PASSWORD='xxxxx' export GOVC_INSECURE=1 CLUSTER_NAME="openshift" CLUSTER_DOMAIN="ocp.lab" RHCOS_TEMPLATE="rhcos-4.3.8" VM_NETWORK="AMS_SHARED_SERVICES_OAM_2508" VM_DATASTORE="OpenShift_SAS_n01" VM_DATACENTER="Openshift-DC" VM_FOLDER="openshift" BOOTSTRAP_MAC='00:50:56:23:F7:21' BOOTSTRAP_NAME='bootstrap' MASTER0_MAC='00:50:56:1E:A5:6A' MASTER0_NAME='master0' MASTER1_MAC='00:50:56:1E:33:25' MASTER1_NAME='master1' MASTER2_MAC='00:50:56:0C:F8:E0' MASTER2_NAME='master2' WORKER0_MAC='00:50:56:1E:2C:5D' WORKER0_NAME='worker0' WORKER1_MAC='00:50:56:24:CD:19' WORKER1_NAME='worker1' WORKER2_MAC='00:50:56:24:CD:19' WORKER2_NAME='worker2' echo -e "\e[1;32m Set disk.EnableUUID to true for the template ${RHCOS_TEMPLATE} \e[0m" govc vm.change -e="disk.enableUUID=1" -vm="/${VM_DATACENTER}/vm/${RHCOS_TEMPLATE}" echo -e "\e[1;32m Set ign.data for the template ${RHCOS_TEMPLATE} \e[0m" govc vm.change -e="guestinfo.ignition.config.data=changeme" -vm="/${VM_DATACENTER}/vm/${RHCOS_TEMPLATE}" echo -e "\e[1;32m Set Ign.data.encoding for the template ${RHCOS_TEMPLATE} \e[0m" govc vm.change -e="guestinfo.ignition.config.data.encoding=base64" -vm="/${VM_DATACENTER}/vm/${RHCOS_TEMPLATE}" echo -e "\e[1;32m Deploying - Bootstrap node \e[0m" bootstrap=$(cat append-bootstrap.ign | base64 -w0) govc vm.clone -vm ${RHCOS_TEMPLATE} -annotation=BootstrapNode -c=4 -m=16384 -net ${VM_NETWORK} -net.address ${BOOTSTRAP_MAC} -on=false -folder=${VM_FOLDER} -ds=${VM_DATASTORE} ${BOOTSTRAP_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.change -e="guestinfo.ignition.config.data=${bootstrap}" -vm=${BOOTSTRAP_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} echo -e "\e[1;32m Deploying - ${MASTER0_NAME} node \e[0m" master=$(cat master.ign | base64 -w0) govc vm.clone -vm ${RHCOS_TEMPLATE} -annotation=MasterNode00 -c=4 -m=16384 -net ${VM_NETWORK} -net.address ${MASTER0_MAC} -on=false -folder=${VM_FOLDER} -ds=${VM_DATASTORE} ${MASTER0_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.change -e="guestinfo.ignition.config.data=${master}" -vm=${MASTER0_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} echo -e "\e[1;32m Deploying - ${MASTER1_NAME} node \e[0m" master=$(cat master.ign | base64 -w0) govc vm.clone -vm ${RHCOS_TEMPLATE} -annotation=MasterNode01 -c=4 -m=16384 -net ${VM_NETWORK} -net.address ${MASTER1_MAC} -on=false -folder=${VM_FOLDER} -ds=${VM_DATASTORE} ${MASTER1_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.change -e="guestinfo.ignition.config.data=${master}" -vm=${MASTER1_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} echo -e "\e[1;32m Deploying - ${MASTER2_NAME} node \e[0m" master=$(cat master.ign | base64 -w0) govc vm.clone -vm ${RHCOS_TEMPLATE} -annotation=MasterNode02 -c=4 -m=16384 -net ${VM_NETWORK} -net.address ${MASTER2_MAC} -on=false -folder=${VM_FOLDER} -ds=${VM_DATASTORE} ${MASTER2_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.change -e="guestinfo.ignition.config.data=${master}" -vm=${MASTER2_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} echo -e "\e[1;32m Deploying - ${WORKER0_NAME} node \e[0m" worker=$(cat worker.ign | base64 -w0) govc vm.clone -vm ${RHCOS_TEMPLATE} -annotation=WorkerNode00 -c=4 -m=16384 -net ${VM_NETWORK} -net.address ${WORKER0_MAC} -on=false -folder=${VM_FOLDER} -ds=${VM_DATASTORE} ${WORKER0_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.change -e="guestinfo.ignition.config.data=${worker}" -vm=${WORKER0_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} echo -e "\e[1;32m Deploying - ${WORKER1_NAME} node \e[0m" worker=$(cat worker.ign | base64 -w0) govc vm.clone -vm ${RHCOS_TEMPLATE} -annotation=WorkerNode01 -c=4 -m=16384 -net ${VM_NETWORK} -net.address ${WORKER1_MAC} -on=false -folder=${VM_FOLDER} -ds=${VM_DATASTORE} ${WORKER1_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.change -e="guestinfo.ignition.config.data=${worker}" -vm=${WORKER1_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} echo -e "\e[1;32m Deploying - ${WORKER2_NAME} node \e[0m" worker=$(cat worker.ign | base64 -w0) govc vm.clone -vm ${RHCOS_TEMPLATE} -annotation=WorkerNode02 -c=4 -m=16384 -net ${VM_NETWORK} -net.address ${WORKER2_MAC} -on=false -folder=${VM_FOLDER} -ds=${VM_DATASTORE} ${WORKER2_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.change -e="guestinfo.ignition.config.data=${worker}" -vm=${WORKER2_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} echo -e "\e[1;32m Powering ON Nodes \e[0m" govc vm.power -on=true ${BOOTSTRAP_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.power -on=true ${MASTER0_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.power -on=true ${MASTER1_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.power -on=true ${MASTER2_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.power -on=true ${WORKER0_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.power -on=true ${WORKER1_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN} govc vm.power -on=true ${WORKER2_NAME}.${CLUSTER_NAME}.${CLUSTER_DOMAIN}