Packing multiple instances in parallel

Hi,

I play arround with packer in order to build up my lab on ESXi:

I’m struggling with how to build multiple vm on ESXi.
So far I can only build one instance and I would like to know how to build several and parameterize such a deployment.

Target is to get several equal instances built.

Thx for your help!

Do you want to build images or build instances?

You’ll have to build an image (as a template) and clone it to one to x vm(s).

But… For the last part you’ll have to use Terraform or something else. Packer won’t do it for you. :wink:

This is the way.

Thx for your replay. I searched and have found following that looks promissing.

1 Like

Terraform can certainly do this, but it should be said here that packer’s vsphere-iso builder (and others) can do this without Terraform. Also, a vSphere template is not technically required to get packer to build multiple VMs on ESXi/vSphere. Depending on your use case, using a templated, chained approach might be the way to go, however, as it can save a lot of (build) time.

To my initial point (packer can do this, without TF and without VM templates), you would simply define multiple builders in your packer template, and these will by default be built in parallel.

…and like me, you will likely find that using HCL2 instead of json will pay off in spades, since with HCL2 you can do things like define your builder as a “source” that can be reused across your multiple builders…

thx for the replay !!!

So, this means it would be possible with HCL2 to
parameterize one builder in order to build
several instance from a list, array whatever?

I built a repo with a basic approach but this is more or less static:

Based on that repo I save the ovf locally but I want to setup three
VM’s in ESXi and used them right away.

I’m not familar with HCL2 but I need to dig into.

My target would be at the end to install k8s on three nodes.
One master and two worker nodes.

Thx

@timblaktu does HCL2 support loops as well?

HCL2 syntax includes for, for_each patterns.
An intro might be here:

1 Like