2014-02-25 16:33:08 +00:00
|
|
|
---
|
|
|
|
page_title: "File Uploads - Provisioning"
|
|
|
|
sidebar_current: "provisioning-file"
|
|
|
|
---
|
|
|
|
|
|
|
|
# File Provisioner
|
|
|
|
|
|
|
|
**Provisioner name: `"file"`**
|
|
|
|
|
2015-09-25 13:14:12 +00:00
|
|
|
The file provisioner allows you to upload a file or directory from the host
|
|
|
|
machine to the guest machine.
|
2014-02-25 16:33:08 +00:00
|
|
|
|
|
|
|
File provisioning is a simple way to, for example, replicate your local
|
|
|
|
~/.gitconfig to the vagrant user's home directory on the guest machine so
|
|
|
|
you won't have to run `git config --global` every time you provision a
|
|
|
|
new VM.
|
|
|
|
|
2014-07-05 13:13:20 +00:00
|
|
|
Vagrant.configure("2") do |config|
|
|
|
|
# ... other configuration
|
|
|
|
|
2014-07-05 13:21:48 +00:00
|
|
|
config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
|
2014-07-05 13:13:20 +00:00
|
|
|
end
|
|
|
|
|
2015-09-25 13:14:12 +00:00
|
|
|
Note that, unlike with synced folders, files or directories that are uploaded
|
|
|
|
will not be kept in sync. Continuing with the example above, if you make
|
|
|
|
further changes to your local ~/.gitconfig, they will not be immediately
|
|
|
|
reflected in the copy you uploaded to the guest machine.
|
2014-02-25 16:33:08 +00:00
|
|
|
|
2015-11-19 02:13:37 +00:00
|
|
|
The file uploads by the file provisioner are done as the
|
|
|
|
_SSH or PowerShell user_. This is important since these users generally
|
|
|
|
don't have elevated privileges on their own. If you want to upload files to
|
|
|
|
locations that require elevated privileges, we recommend uploading them
|
|
|
|
to temporary locations and then using the
|
|
|
|
[shell provisioner](/v2/provisioning/shell.html)
|
|
|
|
to move them into place.
|
|
|
|
|
2014-02-25 16:33:08 +00:00
|
|
|
## Options
|
|
|
|
|
|
|
|
The file provisioner takes only two options, both of which are required:
|
|
|
|
|
2015-09-25 13:14:12 +00:00
|
|
|
* `source` (string) - Is the local path of the file or directory to be
|
|
|
|
uploaded.
|
2014-02-25 16:33:08 +00:00
|
|
|
|
|
|
|
* `destination` (string) - Is the remote path on the guest machine where
|
2015-09-25 13:14:12 +00:00
|
|
|
the source will be uploaded to. The file/folder is uploaded as the SSH user
|
|
|
|
over SCP, so this location must be writable to that user. The SSH user can be
|
2014-02-25 16:33:08 +00:00
|
|
|
determined by running `vagrant ssh-config`, and defaults to "vagrant".
|