github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/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  ## Directory Uploads
    44  
    45  The file provisioner is also able to upload a complete directory to the
    46  remote machine. When uploading a directory, there are a few important things
    47  you should know.
    48  
    49  First, the destination directory must already exist. If you need to
    50  create it, use a shell provisioner just prior to the file provisioner
    51  in order to create the directory.
    52  
    53  Next, the existence of a trailing slash on the source path will determine
    54  whether the directory name will be embedded within the destination, or
    55  whether the destination will be created. An example explains this best:
    56  
    57  If the source is `/foo` (no trailing slash), and the destination is
    58  `/tmp`, then the contents of `/foo` on the local machine will be uploaded
    59  to `/tmp/foo` on the remote machine. The `foo` directory on the remote
    60  machine will be created by Packer.
    61  
    62  If the source, however, is `/foo/` (a trailing slash is present), and
    63  the destination is `/tmp`, then the contents of `/foo` will be uploaded
    64  directly into `/tmp` directly.
    65  
    66  This behavior was adopted from the standard behavior of rsync. Note that
    67  under the covers, rsync may or may not be used.