3

Apart from installing applications like emacs on my guest machine, I would also like to upload some configuration files (e.g. to configure emacs for Clojure development). Sadly, Vagrant's documentation gives no clue about how to do this. I guess I'd have to put the configuration files into a shared folder and then copy them from the shared folder on the guest machine to the desired locations?

0

2 Answers 2

9

You can use the "file" provisioner. It seems to be undocumented, but usage is simple. For example:

Vagrant.configure('2') do |config|
  # ...

  config.vm.provision :file do |file|
    file.source      = '~/.my.conf'
    file.destination = '/home/vagrant/.my.conf'
  end
end

First catch is that it is run as the ssh user ("vagrant" by default) without sudo, so you need to have write access to the directory on the VM. A workaround is to copy to a temporary location and then use a normal shell provisioner to copy/move it to right place.

Second issues is that target paths are not expanded correctly. So using ~ or $HOME most probably won't work as expected. (The source path on the other hand is expanded.)

1
  • Vagrant 1.5 will expand also the target paths on most guest platforms.
    – tmatilai
    Feb 3, 2014 at 15:14
1

Yes, you should "put the configuration files into a shared folder and then copy them from the shared folder on the guest machine to the desired location".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .