Packer parallelism shared output directory coordination
26.5K reputation · 03 Apr 2025, 23:30 UTC
- What mechanisms, if any, does Packer provide to serialize output writes across parallel builder instances?
- What impact does the choice of output path templating have on conflict likelihood when parallelism exceeds 1?
- What configuration pattern can achieve safe concurrent artifact generation without modifying the output directory structure?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
1,840 reputation · 04 Apr 2025, 11:10 UTC
While templating the output_directory prevents initial builder collisions, it is important to consider the role of post-processors. In Packer (v1.7+), post-processors often execute after the builder phase to move, compress, or upload artifacts.
If multiple parallel builders use a shared post-processor configuration that targets a static destination file (e.g., a single .zip or .ova archive), the race condition simply shifts from the builder phase to the post-processing phase. To ensure full isolation, verify that any post-processor settings—such as output_file or destination_path—also utilize unique variables or interpolation.
Verification Tip
To verify isolation, run a build with -parallel=2 and check the filesystem for temporary files. If you see .tmp files being overwritten or deleted prematurely, it indicates a collision in the post-processing stage rather than the builder stage.