Last active
September 26, 2024 17:33
-
-
Save kwilczynski/7336212e73986ae9a2600cf634159f4d to your computer and use it in GitHub Desktop.
Using govc to add ExtraConfig setting to a virtual machine in VSphere.
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
export GOVC_URL='' | |
export GOVC_USERNAME='' | |
export GOVC_PASSWORD='' | |
# Disabled. Only use if TLS is completely broken. | |
# export GOVC_INSECURE=1 | |
export GOVC_TLS_CA_CERTS=$(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE' 2>/dev/null) |
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
while read vm; do | |
govc vm.power -s -vm.dns=${vm} && govc vm.power -off -vm.dns=${vm} | |
govc vm.change -e 'mem.hotadd=true' -e 'vcpu.hotadd=true' -vm.dns=${vm} | |
govc vm.change -c 2-vm.dns=${vm} | |
govc vm.power -on -vm.dns=${vm} | |
govc vm.info -vm.dns=${dns} -json | jq -r '.VirtualMachines[].Config.ExtraConfig[] | select(.Key | contains("hotadd"))' | |
read -p "Next? " -n 1 -r answer && [[ $answer =~ ^[Yy]$ ]] || break && echo | |
done < list.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment