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