Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a file to host during packer provisioning?

Tags:

packer

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?

like image 530
Tom Sweeney Avatar asked Apr 09 '16 01:04

Tom Sweeney


People also ask

What is Provisioner in 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.

What are packer files?

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).

What are builders in packer?

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.


1 Answers

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"
}
like image 161
Tom Sweeney Avatar answered Oct 21 '22 05:10

Tom Sweeney