logo

How to setup govc to automate vSphere Tasks

This post is a long overdue tutorial on how to setup govc.

What is govc? It’s a cli utilizing govmomi, a go library used to interact with vSphere API. Why use govc? It’s fast and way better to use for automation tasks.

Installation:

  1. Download release binary here:
  2. Depending on the platform, decompress:
    • gzip -d govc_linux_amd64.gz
  3. Flag it as executable
    • chmod +x govc_linux_amd64
  4. Move the executable to your $PATH:
    • mv govc_linux_amd64 /usr/local/bin/govc

How to use:

  1. Create a flat file with the below content
  2. source the file to export
  3. run govc
    • sample: govc ls

export GOVC_URL=https://172.16.0.21
export [email protected]
export GOVC_PASSWORD=VMware1!
export GOVC_INSECURE=true

Advance examples here:

https://github.com/vmware/govmomi/tree/master/govc

Leave a Reply

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.