Seeding a file or directory into your image once booted
In our very first template, we demonstrated a simple provisioner of type file
where we uploaded and replaced the /etc/motd
file during the Packer build. This was uploaded over the SSH communicator using an SFTP operation. The file
provisioner can actually do multiple files at once or even directories. The syntax and behavior for this are similar to rsync
. Note that archived files will not be extracted automatically. Another provisioner can be used to extract an archive once it’s been uploaded. In our first example, we set content
to a string we wanted to write to /etc/motd
. You may also use herefile syntax to upload multiple line files as content to embed a text file inside your template. It’s usually a better idea to use the source
or sources
option to reference local files instead of embedding them. There are three main options for specifying your file content, as follows:
content
: Raw text to be uploaded...