Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Troubleshooting failed packer build

Tags:

packer

I am just getting started with Packer, and have had several instances where my build is failing and I'd LOVE to log in to the box to investigate the cause. However, there doesn't seem to be a packer login or similar command to give me a shell. Instead, the run just terminates and tears down the box before I have a chance to investigate.

I know I can use the --debug flag to pause execution at each stage, but I'm curios if there is a way to just pause after a failed run (and prior to cleanup) and then runt he cleanup after my debugging is complete.

Thanks.

like image 895
Tejay Cardon Avatar asked Jan 06 '15 17:01

Tejay Cardon


2 Answers

This was my top annoyance with packer. Thankfully, packer build now has an option -on-error that gives you options.

packer build -on-error=ask ... to the rescue.

From the packer build docs:

-on-error=cleanup (default), -on-error=abort, -on-error=ask - Selects what to do when the build fails. cleanup cleans up after the previous steps, deleting temporary files and virtual machines. abort exits without any cleanup, which might require the next build to use -force. ask presents a prompt and waits for you to decide to clean up, abort, or retry the failed step.

like image 50
Mike D Avatar answered Sep 17 '22 04:09

Mike D


Having used Packer extensively, the --debug flag is most helpful. Once the process is paused you SSH to the box with the key (in the current dir) and figure out what is going on.

like image 27
Ken Brittain Avatar answered Sep 17 '22 04:09

Ken Brittain