Logging and Troubleshooting
In previous chapters, we showed the basics of templates with multiple builders and provisioners providing code examples that should be free of errors. Obviously, creating these samples isn’t as smooth as just writing and building. There is a lot of troubleshooting involved in most Packer journeys. As the complexity goes up, it becomes difficult to manage logs, and sometimes it’s not obvious what’s going wrong. Here, we’ll describe some standard debugging tricks and how to manage complex logs in a parallel build. We’ll also cover some tips and tricks that prepare us for future chapters, including automation and CI pipelines.
In this chapter, we’ll cover the following topics:
- Managing
stderr
andstdout
- Using environment variables for logging and debugging
- Controlling flow and using breakpoints
First, understand that Packer uses a separate process for each build by default. Building a template...