Summary
In this chapter, we showed a basic template to provide us with a first base image for Packer to build further images. We selected CentOS 9 Streams as a Linux distribution to simulate enterprise environments, but next, we will add other options to our template, including other Linux distributions and Windows. Templates can be written in either HCL2 or JSON. HCL2 is the recommended template format for new projects, but JSON templates are widely available on the internet and easily converted to HCL2 if necessary. JSON can still help when automation is used to build templates, but from here forward, we will focus on writing example templates in HCL2.
Simple templates like the one in this chapter cut a lot of corners and hardcode a lot of attributes, but in the next chapter, it will be apparent how limiting that can be and how variables can be used to simplify templates and improve reusable attributes.