Packer template pipeline for multiple VMs

I am following this guide for template pipelining:

I have created about 6 scripts and chained them together to generate one VM.

I would now like to modify these scripts to output different VM versions for different purposes.

For example, I have one script which installs all 3rd party software. I have small differences between 2 VMs on what software should be installed.

My problem is this:
To filter provisioners based on VM type I need to define multiple sources for a build.

If I define multiple build sources in the script I will get multiple VM outputs. If I have two scripts in a row which does this I will start to get “thrash VMs” which I need to throw away because I do not know how to tell the scripts that they should only run one of the sources at a time.

Have I misunderstood something here?

Is there a mechanism where I can tell the script to only use one of the two sources when I build?

Is there some other mechanism for filtering provisioners?

Should I follow some other process for pipelining packer scripts together and still be able to generate different VM types using the same scripts?

Maybe that will help.

In the link above you can see how to tell a provisioner to run on a specific build source using the only configuration.

Not sure though about running the same proviosoner on multiple builds in a sequence one by one.

provisioner - build - Blocks | Packer by HashiCorp

Thanks for the reply.

Yes I am aware of the “only” parameterization, but that will (as far as I know) still produce multiple outputs when running the script (one output for each source).

The problem begins when combining multiple sources and “only” parameterization with multiple chained together .hcl files. I cannot see how I can chain together .hcl files like that in a build pipeline without running into the issue of generating “trash” VMs?