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