Skip to content

Instantly share code, notes, and snippets.

@dpacuszka
Last active September 23, 2021 11:38
Show Gist options
  • Save dpacuszka/9caccc93d198629125021ecbe60ee546 to your computer and use it in GitHub Desktop.
Save dpacuszka/9caccc93d198629125021ecbe60ee546 to your computer and use it in GitHub Desktop.
Initial setup of the Loadbalancer.org appliance using vSphere API and PowerShell
# Environment variables specified below are neccessary for govc
# to work. Should you want o use govc outside this script they
# must be sourced in your Bash config.
# vSphere Host URL
$env:GOVC_URL=""
# Your vSphere credentials
$env:GOVC_USERNAME=""
$env:GOVC_PASSWORD=""
# Disable certificate validation
# Set to true if using self-signed certificate
$env:GOVC_INSECURE=true
#
# Variables below are used for the purpose of this script only.
#
# Name of your Loadbalancer.org VM
$vm = ""
# IP to be used by the node
$ip = ""
# The netmask in CIDR notation
$cidr = ""
# Default Gateway
$gateway = ""
# Primary and Secondary DNS
$dns1 = ""
$dns2 = ""
# Your new WebUI password
$password = ""
# Logging into the configuration wizard
govc vm.keystrokes -vm "$vm" -s "setup"
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -s "setup"
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# This will reset IP Configuration
# Do you wish to continue? Yes
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Availabe interfaces OK
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Do you need to create a bonded interface? No
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Would you like to configure a VLAN? No
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Select interface
# eth0
# Select
govc vm.keystrokes -vm "$vm" -c KEY_TAB
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Static IP Address
govc vm.keystrokes -vm "$vm" -s "$ip"
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# CIDR prefix
govc vm.keystrokes -vm "$vm" -s "$cidr"
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Default Gateway IP Adress
govc vm.keystrokes -vm "$vm" -s "$gateway"
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Primary DNS Server
govc vm.keystrokes -vm "$vm" -s "$dns1"
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Secondary DNS Server
govc vm.keystrokes -vm "$vm" -s "$dns2"
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Summary
# Configure
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Set Password
# OK
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Password
govc vm.keystrokes -vm "$vm" -s "$password"
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_TAB
Start-Sleep -s 1
# Password again
govc vm.keystrokes -vm "$vm" -s "$password"
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_TAB
Start-Sleep -s 1
# WUI and console password set successfully
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
# Peer Recovery
# No
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Start-Sleep -s 1
govc vm.keystrokes -vm "$vm" -c KEY_ENTER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment