github.com/jerryclinesmith/packer@v0.3.7/website/source/docs/provisioners/file.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "File Provisioner" 4 --- 5 6 # File Provisioner 7 8 Type: `file` 9 10 The file provisioner uploads files to machines built by Packer. The 11 recommended usage of the file provisioner is to use it to upload files, 12 and then use [shell provisioner](/docs/provisioners/shell.html) to move 13 them to the proper place, set permissions, etc. 14 15 The file provisioner can upload both single files and complete directories. 16 17 ## Basic Example 18 19 <pre class="prettyprint"> 20 { 21 "type": "file", 22 "source": "app.tar.gz", 23 "destination": "/tmp/app.tar.gz" 24 } 25 </pre> 26 27 ## Configuration Reference 28 29 The available configuration options are listed below. All elements are required. 30 31 * `source` (string) - The path to a local file or directory to upload to the 32 machine. The path can be absolute or relative. If it is relative, it is 33 relative to the working directory when Packer is executed. If this is a 34 directory, the existence of a trailing slash is important. Read below on 35 uploading directories. 36 37 * `destination` (string) - The path where the file will be uploaded to in the 38 machine. This value must be a writable location and any parent directories 39 must already exist. 40 41 ## Directory Uploads 42 43 The file provisioner is also able to upload a complete directory to the 44 remote machine. When uploading a directory, there are a few important things 45 you should know. 46 47 First, the destination directory must already exist. If you need to 48 create it, use a shell provisioner just prior to the file provisioner 49 in order to create the directory. 50 51 Next, the existence of a trailing slash on the source path will determine 52 whether the directory name will be embedded within the destination, or 53 whether the destination will be created. An example explains this best: 54 55 If the source is `/foo` (no trailing slash), and the destination is 56 `/tmp`, then the contents of `/foo` on the local machine will be uploaded 57 to `/tmp/foo` on the remote machine. The `foo` directory on the remote 58 machine will be created by Packer. 59 60 If the source, however, is `/foo/` (a trailing slash is present), and 61 the destination is `/tmp`, then the contents of `/foo` will be uploaded 62 directly into `/tmp` directly. 63 64 This behavior was adopted from the standard behavior of rsync. Note that 65 under the covers, rsync may or may not be used.