Troubleshooting a package collector build
I'm just getting started with Packer and I've had a few cases where my build doesn't work and I LOVE to get into the box to investigate the cause. However, there doesn't seem packer login
to be a command or similar command to give me a shell. Instead, the launch just ends and rips off 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 interested if there is a way to just pause after a failed startup (and before cleaning), and then start cleaning it up after my debugging is complete.
Thank.
source to share
This has been my main annoyance with packer
. Fortunately, it packer build
now has an option -on-error
that gives you options.
packer build -on-error=ask ...
...
From the package builder docs:
-on-error=cleanup
(default)-on-error=abort
,-on-error=ask
- choose what to do when the assembly fails. cleanup cleans up after the previous steps, removes temporary files and virtual machines. abort exits without any cleanup, which might require the next build to be used-force
.ask
presents a prompt and waits for you to clear, abort, or retry the failed step.
source to share
Yes, the way I am dealing with this is to put a long sleep in the inline script writer after a failed step, then I can ssh to the box and see what happens. Of course the debug flag is useful, but if you are building the packer remotely (I am doing it in jenkins) you cannot sit there and click a button.
I'm trying to run tests on everything I package outside of a build - with the help of a chef assistant. I have tests in the kitchen all over before it's packed. It is a huge pain to try and debug anything other than the packer during the packer run.
source to share
While looking for information for myself, I came across numerous error messages / feature requests for Packer.
Apparently someone added new features for virtual bots and vmware collectors a year ago ( https://github.com/mitchellh/packer/issues/409 ), but it hasn't merged into the main one.
On another bug ( https://github.com/mitchellh/packer/issues/1687 ), they were looking at adding more functionality to --debug, but that seemed to stop.
source to share
If the Packer build is not working, first check where the build process is stuck, but check in this sequence:
- Are the commands loading correctly?
- Is the preseed config ok?
- If 1.and 2. are ok, then this means that the box has loaded, and the next one to check is the login: SSH keys, ports, ...
- Finally, any problems in provisioning scripts
source to share