Welcome! This repository was designed to automate the deploy of a single VM from a template in vCenter 8.0 using Terraform.
This project was developed and tested on an Intel NUC 13 Pro i5 with 64GB RAM, serving as the physical server. The server runs VMware ESXi 8.0, vCenter 8.0, and a VyOS server for communication within the home network and the internal lab.
Ensure the following prerequisites are met before proceeding:
- ESXi 6.7 or later
- vCenter 6.7 or later
- 01 template for use. Check out this link for instructions on creating a template using Packer. The provided template was used to create the template in vCenter.
Follow these steps for installation:
- Install Packer: Getting Started with Packer
- Install the vSphere plugin: Packer vSphere Plugin
To generate a hashed password, follow the instructions in the official documentation. OpenSSL was used in this instance, but you can use mkpasswd
from the whois
package.
openssl passwd -6 -salt $(openssl rand -base64 12) ubuntu
Execute the following command to build with HCL:
packer build -force -on-error=ask -var-file variables.pkrvars100GBdisk.hcl -var-file vsphere.pkrvars.hcl ubuntu-22.04.pkr.hcl
├── README.md
├── main.tf
├── output.tf
├── templates
│ ├── metadata.yaml
│ └── userdata.yaml
├── terraform.tfstate
├── terraform.tfvars
├── variables.tf
└── vars.auto.tfvars
This project follows the directory structure:
README.md
: Project documentation.main.tf
: Main Terraform configuration file.output.tf
: Terraform output configuration file.templates/
: Directory containing metadata and userdata YAML templates.metadata.yaml
: Metadata YAML template.userdata.yaml
: Userdata YAML template.
terraform.tfstate
: Terraform state file.terraform.tfvars
: Terraform variable values.variables.tf
: Terraform variable definitions.vars.auto.tfvars
: Auto-generated Terraform variable values.
If you have any questions, encounter issues, or have suggestions, please feel free to open an issue on GitHub or reach out to the maintainer at [email protected].