Skip to content

Prerequitites & Preparation

direnv

It is advisable to install direnv to persist environmental variables to a hidden .envrc file.

After direnv is installed, set up on the local repository path:

# add direnv hooks
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
source ~/.zshrc

# add .envrc and .env to gitignores (global, local)
git config --global core.excludesFile '~/.gitignore'
touch ~/.gitignore
echo '.envrc' >> ~/.gitignore
echo '.env' >> ~/.gitignore
echo '.envrc' >> .gitignore
echo '.env' >> .gitignore

# remove .gitignored files
git ls-files -i --exclude-from=.gitignore | xargs git rm --cached

# set up direnv config to whitelist folders for direnv
mkdir -p ~/.config/direnv
cat > ~/.config/direnv/direnv.toml << EOF
[whitelist]
prefix = [ "/path/to/folders/to/whitelist" ]
exact = [ "/path/to/envrc/to/whitelist" ]
EOF

direnv reload

govmomi/govc

govc is a vSphere CLI built on top of govmomi.

The CLI is designed to be a user friendly CLI alternative to the GUI and well suited for automation tasks. It also acts as a test harness for the govmomi APIs and provides working examples of how to use the APIs.

We will use it to identify names of vSphere resources

# these variables should be known from VCSA installation
cat << EOF >> .envrc
export GOVC_URL="vsphere-ip-or-hostname"
export GOVC_USERNAME="administrator@example.com"
export GOVC_PASSWORD="changeme"
export GOVC_DATACENTER=Homelab
export GOVC_INSECURE=true
EOF

Using govc

See docs for usage

# find networks
govc find -type n
# find resource pool path
govc find -type p
# find datastore
govc find -type s

Ansible

  1. Install pipx

  2. Install ansible

sh pipx install --include-deps ansible # inject 'docker' and 'kubernetes' pkgs into 'ansible' namespace pipx inject ansible docker kubernetes

  1. Update Ansible requirements

sh ansible-galaxy install -r ./ansible/requirements.yaml --force

  1. Update python requirements

sh # pip3 install -r ./ansible/requirements.txt # use conda env instead :)

Terraform

VM Images