Developing Packer Plugins
In the previous chapter, we covered basic automation for Packer builds. Up until now, most of Packer’s existing builder use cases should be familiar, but what about the functionalities Packer lacks? Since Packer is open source, you could fork and edit the code base, but it’s much easier to write a plugin. HashiCorp’s projects use Go and Remote Procedure Call (RPC) for plugin development, which allows plugins to be developed as standalone Go binaries or to be built into the project itself. Plugins come in four flavors: builders, provisioners, post-processors, and data sources. Each function is defined by an interface that must be implemented. Packer makes this easy to do by providing templates. We’ll explore the templates by implementing two plugins in this chapter. First, we’ll implement a basic data source and then a more complex builder. Before any of that, we will cover the basics of Go in the context of Packer. This is...