Uses vSphere terraform provider to provision VM's, Host Port Groups, Datastore.
For Proxmox I use bpg/proxmox
Packer to create the VM template of CentOS images, which is then cloned per ESXi host and Proxmox host.
- Change to packer directory
$ cd packer/
- Fill in
packer/vars.auto.pkrvars.hcl.example
and rename it topacker/vars.auto.pkrvars.hcl
.
Example:
vsphere_server = "jd-vsca-01.linds.com.au"
vsphere_user = "administrator@vsphere.local"
vsphere_password = "xxxxxxxxxx"
datacenter = "LINDS"
datastore = "JD-Datastore-OS"
network_name = "Native VLAN"
host = "jd-esxi-01.linds.com.au"
ssh_password = "xxxxxxxxxx"
-
In the designated datastore, copy CentOS 9 Stream ISO to
<datastore>/ISO/CentOS-Stream-9.iso
and CentOS 8 Stream ISO to<datastore>/ISO/CentOS-Stream-8.iso
-
Run the below command to build and provision both CentOS 9 and CentOS 8.
$ cd packer/
$ packer build -force .
To build only CentOS 8:
$ packer build -var-file=vars.auto.pkrvars.hcl -only=vsphere-iso.centos8 -force .
To build only CentOS 9:
$ packer build -var-file=vars.auto.pkrvars.hcl -only=vsphere-iso.centos9 -force .
To build CentOS 9 on proxmox
-
Copy and rename variables-proxmox.pkrvars.hcl.example to variables-proxmox.pkrvars.hcl and fill in variables
-
Run the below command
cd packer && packer build -var-file=packer_jd.pkrvars.hcl -only=proxmox-iso.centos-9 -force .
To build Ubuntu Server 2024 on proxmox
- Run the below command
cd packer && packer build -var-file=packer_jd.pkrvars.hcl -only=proxmox-iso.ubuntu -force .
- Copy and rename terraform.tfvars.example
Example:
vsphere_server = "xxxx"
vsphere_user = "xxxx"
vsphere_password = "xxxx"
datacenter = "xxxx"
jd-datastore = "xxxx"
jd-host = "xxxx"
linds-host = "xxxx"
linds-datastore = "xxxx"
jd_network_name = "xxxxxxx"
jd_centos_9 = "CentOS 9"
jd_centos_8 = "CentOS 8"
linds_centos_9 = "CentOS 9-LINDS"
linds_centos_8 = "CentOS 8-LINDS"
host_licensekey = "xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"
- Initialise Terraform and apply configuration
$ terraform init
$ terraform plan
$ terraform apply
State is kept on TrueNAS NFS share, that is then rsync'd to secondary TrueNAS offsite. This can be seen in versions.tf.
- Switch to proxmox directory
cd proxmox/
-
Copy and rename terraform.tfvars.example
-
Initialise Terraform and apply configuration
$ terraform plan -var-file proxmox_jd_terraform.tfvars
$ terraform plan -var-file proxmox_linds_terraform.tfvars