I would like to generate a public/private ssh key pair during packer provisioning and copy the files to the host machine. Is there a way to copy files out from the VM to the host using packer?
File Provisioner in PackerIt allows us to create machine images. It can be used for multiple platforms from a single source template. A common use case is creating images that can be used later in cloud infrastructure. We will use File Provisioner in this blog.
A Packer template is a configuration file that defines the image you want to build and how to build it. Packer templates use the Hashicorp Configuration Language (HCL).
Builders are components of Packer that are able to create a machine image for a single platform. Builders read in some configuration and use that to run and generate a machine image. A builder is invoked as part of a build in order to create the actual resulting images.
I figured it out. The file provisioner has a "direction" option that allows download instead of upload
{
"type": "file",
"source": "app.tar.gz",
"destination": "/tmp/app.tar.gz",
"direction" : "download"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With