This example repository facilitates VMware Cloud Foundation Automation (VCFA) blueprint deployments using Terraform. It integrates with VCF Automation (VCFA) and is designed to work with a self-hosted GitHub Actions runner for streamlined on-premises automation.
- Terraform-based provisioning of Aria Automation blueprints
- Dynamic input configuration via GitHub workflow dispatch
- Per-deployment state management for easy apply and destroy operations
- Integrated debugging and log artifact upload
- Cloud-init and Ansible integration to configure VMs post-deployment
- VMware Aria Automation / VCFA environment
- Terraform (>= 1.6)
- GitHub repository with:
- Workflow file (
.github/workflows/deploy-vcfa.yml) - Terraform files (
tf/main.tf,tf/variables.tf, etc.)
- Workflow file (
- Self-hosted GitHub Actions runner with systemd service configured and running
- Backend directory for per-deployment
tfstatefiles (e.g.,/home/user/tfstate/)
The following inputs are accepted by the GitHub workflow:
action:applyordestroyhostname: Hostname of the VMipAddress: Static IP addressgateway: Default gatewayprefixLength: Subnet mask prefix lengthdns: (optional) DNS servers (can be pulled from secrets)
All variables are automatically passed into Terraform using the TF_VAR_ environment variable convention.
A local backend is used with a dynamic path, based on the deployment name. This enables isolated state tracking per deployment.
Example backend config:
terraform {
backend "local" {}
}In practice, the path is overridden dynamically during the workflow using:
terraform init -backend-config="path=$HOME/tfstate/${DEPLOYMENT_NAME}.tfstate"The workflow does the following:
- Checks out the repository
- Initializes Terraform with a dynamic
tfstatefile - Validates and plans the configuration
- Applies or destroys the deployment based on input
- Uploads debug logs on failure
- Moves
tfstateto a permanent directory per deployment name
You can run the Terraform workflow manually on your runner:
export TF_VAR_hostname=<hostname>
export TF_VAR_ipAddress=<ipAddress>
export TF_VAR_gateway=<gateway>
export TF_VAR_dns='["<dnsServerIP>"]'
export TF_VAR_prefixLength=<prefixLength>
export DEPLOYMENT_NAME=$TF_VAR_hostname
terraform init -backend-config="path=$HOME/tfstate/${DEPLOYMENT_NAME}.tfstate"
terraform apply -auto-approveTo destroy the deployment:
terraform init -backend-config="path=$HOME/tfstate/${DEPLOYMENT_NAME}.tfstate"
terraform destroy -auto-approveTo ensure your runner is always listening:
sudo systemctl status actions.runner.<USERNAME>-<REPO>.runner-name.service
# example
# sudo systemctl status actions.runner.NJSchulz-vcfa-terraform.terraform.serviceTo restart if needed:
sudo systemctl restart actions.runner.<USRENAME>-<REPO>.runner-name.service
# example
# sudo systemctl restart actions.runner.NJSchulz-vcfa-terraform.terraform.serviceYou can run multiple runners on the same VM by placing each in its own directory and registering with a unique name.
- Full GitOps control of VCFA blueprint deployments
- Repeatable infrastructure via Terraform
- Easy rollback and teardown
- GitHub UI and API integration
- Developer-friendly and auditable
MIT