Skip to content

Terraform for my homelab infrastructure. Uses vSphere provider to provision the ESXi hosts and the VM's

Notifications You must be signed in to change notification settings

Jayden-Lind/LINDS-Terraform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LINDS-Terraform

terraform

Intro

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.

Packer

Vsphere

  1. Change to packer directory
$ cd packer/
  1. Fill in packer/vars.auto.pkrvars.hcl.example and rename it to packer/vars.auto.pkrvars.hcl.

Example:

vsphere_server   = "jd-vsca-01.linds.com.au"
vsphere_user     = "[email protected]"
vsphere_password = "xxxxxxxxxx"
datacenter       = "LINDS"
datastore        = "JD-Datastore-OS"
network_name     = "Native VLAN"
host             = "jd-esxi-01.linds.com.au"
ssh_password     = "xxxxxxxxxx"
  1. 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

  2. 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 .

Proxmox

To build CentOS 9 on proxmox

  1. Copy and rename variables-proxmox.pkrvars.hcl.example to variables-proxmox.pkrvars.hcl and fill in variables

  2. 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

  1. Run the below command
cd packer && packer build -var-file=packer_jd.pkrvars.hcl -only=proxmox-iso.ubuntu -force .

Terraform

vSphere

  1. 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"
  1. Initialise Terraform and apply configuration
$ terraform init

$ terraform plan

$ terraform apply

State

State is kept on TrueNAS NFS share, that is then rsync'd to secondary TrueNAS offsite. This can be seen in versions.tf.

Proxmox

  1. Switch to proxmox directory

cd proxmox/

  1. Copy and rename terraform.tfvars.example

  2. Initialise Terraform and apply configuration

$ terraform plan -var-file proxmox_jd_terraform.tfvars
$ terraform plan -var-file proxmox_linds_terraform.tfvars

About

Terraform for my homelab infrastructure. Uses vSphere provider to provision the ESXi hosts and the VM's

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages