Last active
March 6, 2023 07:20
-
-
Save chenweienn/dfd52423eaac5c299cb4370a2336930f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| # set -x | |
| # intall om | |
| echo "+++ installing om" | |
| curl -L -O https://github.com/pivotal-cf/om/releases/download/7.8.2/om-linux-amd64-7.8.2 | |
| chmod +x om-linux-amd64-7.8.2 | |
| cp om-linux-amd64-7.8.2 /usr/local/bin/om | |
| om --version | |
| echo "" | |
| # intall govc | |
| echo "+++ installing govc" | |
| curl -L -O "https://github.com/vmware/govmomi/releases/latest/download/govc_$(uname -s)_$(uname -m).tar.gz" | |
| tar -C /usr/local/bin -xvzf govc*tar.gz govc | |
| govc version | |
| echo "" | |
| # download ops-manager-vsphere-2.10.51-build.662.ova | |
| echo "downloading Ops Manager vsphere ova" | |
| PIVNET_TOKEN='XXX' | |
| om download-product -p ops-manager -f "ops-manager-vsphere-2.10.51*ova" --product-version 2.10.51 --pivnet-api-token $PIVNET_TOKEN -o ./ | |
| echo "" | |
| # authenticate govc | |
| export GOVC_URL=XXX GOVC_USERNAME=administrator@vsphere.local GOVC_PASSWORD='XXX' GOVC_INSECURE=1 GOVC_DATASTORE=XXX GOVC_DATACENTER=XXX GOVC_CLUSTER=XXX | |
| govc about | |
| echo "" | |
| # import spec | |
| govc import.spec ops-manager-vsphere-2.10.51*ova > opsmgr-2.10.51.json | |
| OPSMGR_IP="192.168.1.10" | |
| OPSMGR_NETMASK="255.255.255.0" | |
| OPSMGR_GATEWAY="192.168.1.1" | |
| OPSMGR_DNS_SERVER="192.168.116.1" | |
| OPSMGR_NTP="XXX" | |
| OPSMGR_SSH_PUB_KEY="ssh-rsa AAAABb1fJ...Vj4lhAeojw==" | |
| OPSMGR_CUSTOM_NAME="poc-ops-manager" | |
| OPSMGR_NETWORK="tas-infra-segment" | |
| OPSMGR_IPAllocationPolicy="fixedPolicy" | |
| OPSMGR_NAME="ops-manager" | |
| cat opsmgr-2.10.51.json | \ | |
| jq --arg ip $OPSMGR_IP '(.PropertyMapping[] | select(.Key=="ip0") | .Value) |= $ip' | \ | |
| jq --arg netmask $OPSMGR_NETMASK '(.PropertyMapping[] | select(.Key=="netmask0") | .Value) |= $netmask' | \ | |
| jq --arg gateway $OPSMGR_GATEWAY '(.PropertyMapping[] | select(.Key=="gateway") | .Value) |= $gateway' | \ | |
| jq --arg dns $OPSMGR_DNS_SERVER '(.PropertyMapping[] | select(.Key=="DNS") | .Value) |= $dns' | \ | |
| jq --arg ntp $OPSMGR_NTP '(.PropertyMapping[] | select(.Key=="ntp_servers") | .Value) |= $ntp' | \ | |
| jq --arg pubkey "$OPSMGR_SSH_PUB_KEY" '(.PropertyMapping[] | select(.Key=="public_ssh_key") | .Value) |= $pubkey' | \ | |
| jq --arg name $OPSMGR_CUSTOM_NAME '(.PropertyMapping[] | select(.Key=="custom_hostname") | .Value) |= $name' | \ | |
| jq --arg net $OPSMGR_NETWORK '(.NetworkMapping[] | select(.Name=="Network 1") | .Network) |= $net' | \ | |
| jq '(.IPAllocationPolicy) |= "fixedPolicy"' | \ | |
| jq '(.Name) |= "ops-manager"' | \ | |
| jq '(.PowerOn) |= true' | tee opsmgr-2.10.51-configured.json | |
| # import ova | |
| govc import.ova -options=./opsmgr-2.10.51-configured.json ops-manager-vsphere*ova |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment