From be3fe340c8f60db399f11878c457695d2e5d05b7 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Mon, 27 Nov 2017 17:23:31 -0800 Subject: [PATCH] add a section about uploading files that don't exist. --- website/source/docs/provisioners/file.html.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/website/source/docs/provisioners/file.html.md b/website/source/docs/provisioners/file.html.md index 26e2fc239..0405e8db5 100644 --- a/website/source/docs/provisioners/file.html.md +++ b/website/source/docs/provisioners/file.html.md @@ -47,9 +47,6 @@ The available configuration options are listed below. All elements are required. - `direction` (string) - The direction of the file transfer. This defaults to "upload". If it is set to "download" then the file "source" in the machine will be downloaded locally to "destination" - -The source file must exist before running Packer, this means that creating the -file with a provisioner does not work. ## Directory Uploads @@ -78,6 +75,17 @@ directly. This behavior was adopted from the standard behavior of rsync. Note that under the covers, rsync may or may not be used. +## Uploading files that don't exist before Packer starts + +In general, local files used as the source **must** exist before Packer is run. +This is great for catching typos and ensuring that once a build is started, +that it will succeed. However, this also means that you can't generate a file +during your build and then upload it using the file provisioner later. +A convenient workaround is to upload a directory instead of a file. The +directory still must exist, but its contents don't. You can write your +generated file to the directory during the Packer run, and have it be uploaded +later. + ## Symbolic link uploads The behavior when uploading symbolic links depends on the communicator. The