Run on Specific "Stage" (not only on Build)

There is a method to use a single (heavy) build process with specific provisioning stage based on post-processing (like using only/except based on Post-Processing)?

Scenario:

  1. vmware-iso (or virtualbox-iso) builder from kickstart/preseed file
  2. multiple
  3. Post processing: ami-export, vsphere, vagrant

The same base image from iso+kickstart/preseed build will be the solid base for every images exported to different providers. Each image will have its own specific provision stage (vbox with virtualbox tools, vsphere VM with vmware tools, etc.).

This make real one image identical for all providers (with only different specific provider needs).

Hello,
do you mean something like a multi-stage build on docker?
You could chain your builds.

  • packerfile1 → base image with some common setup
  • packerfile2 → custom image1 with some custom setup (just starts base image and runs provisioning plus post processing)

It is not perfect but a start.
There is also a good article on that: Chaining Machine Image Builds with Packer | by Sarah Horan Van Treese | The Startup | Medium

The main feature I miss is to only build the base image unless it is already there. (Eg. read the image from artifact folder or fetch it from artifactory. If none of these succeeded, rebuild it…)