I am trying to remove a synced folder but with no Success.
I had a Vagrantfile like:
..
config.vm.synced_folder "/folder",
"/vagrant/folder", default_sync_opts
..
but now I no longer have the folder 'folder', I tried just removing that line but it keeps trying to sync that folder.
I've also tried to add again that line and add the disabled : true option but it does not work. It still tries to sync. (plus it would be annoying to keep ever every folder I ever synced on Vagrantfile with disabled: true)
Anyone has gone through this/what can I do? I really don't want to vagrant destroy/vagrant up
have you run vagrant reload --provision? It won't destroy your environment.
Related
I'm trying to install multiple of the same homestead box. Each one for a different project, totally isolated from each other. None of them will be run concurrently, only one at a time.
But when I try to run vagrant up, it tells me that a box with the name 'homestead-7' already exists. How can I rename it?
I don't see the name anywhere in the vagrantfile in the project directory, nor any 'boxes' folder in either the project .vagrant directory or my home .vagrant directory. vagrant global-status tells me that there is 1 homestead-7 box already for the project that is already in progress.
You need to add "name" property under your "Homestead.yaml" file, for example:
name: my-new-homestead
and make sure that your authorize, keys and folders are pointing to the correct path.
To use Homestead in a per project basis, you need to add it as a dependency in each one of your projects:
composer require laravel/homestead --dev
Use php vendor/bin/homestead make to generate the Vagrantfile and Homestead.yaml files. Then you can simply run vagrant up from your project.
See more on the Laravel documentation.
I'm using vagrant and have hashicorp/precise32 box. My projects in /products/ folder on this box. I want to reach this folder from my host computer. So added this configuration to my Vagrantfile
config.vm.synced_folder "/products","/products"
Also created /products folder on host. But after reload when I connect to box over SSH, /products folder's all contents are disappearing. When I comment out the config.vm.synced_folder line and reload, contents appering again.
Can you please tell me what's I missing?
Thank you.
Vagrant sync folder works the other way around
Synced folders enable Vagrant to sync a folder on the host machine to
the guest machine, allowing you to continue working on your project's
files on your host machine, but use the resources in the guest machine
to compile or run your project.
so if you have an existing folder on your guest machine and you ask vagrant to create a sync folder with one of your folder from the host, it will do but replace the content from the content of your host.
There is an old question with some good reference to understand it further
I was trying to fix an issue in vagrant-rackspace plugin, which required running a command to remove the requiretty line from the sudoers file before the synced folder ran, as the rsync command would fail with sudo: sorry, you must have a tty to run sudo.
However, regardless of the order in the Vagrantfile, the synced folder action would always go first. It seems that in core Vagrant, the synced folder has the highest priority, and will always run first. I thought it would be like the provisioners, which are run in order they're put in the Vagrantfile.
Eventually I remembered a similar looking line of code in a plugin I'd worked on recently:
action_hook(:install_chef, Plugin::ALL_ACTIONS) do |hook|
require_relative 'action/install_chef'
hook.after(Vagrant::Action::Builtin::Provision, Action::InstallChef)
if defined? VagrantPlugins::AWS::Action::TimedProvision
hook.after(VagrantPlugins::AWS::Action::TimedProvision,
Action::InstallChef)
end
end
So, I just changed that to make sure the task I wanted always ran before the synced folder task:
action_hook(:tty_workaround, Plugin::ALL_ACTIONS) do |hook|
require_relative 'action/tty_workaround'
hook.after(Vagrant::Action::Builtin::SyncedFolders, Action::TTYWorkaround)
end
Worked like a charm!
I'm still trying to figure out if there's a way of doing this in Vagrant core, but for now I'm planning on making a vagrant plugin where you can give a path to a script you want to run on the vagrant node in the config, allowing you to use the above approach in any Vagrant instance, not just vagrant-rackspace.
I'm working on getting a Vagrant setup running for the first time on a Windows 8.1 machine. I've been pouring over all the documentation to understand how it all works. I used puphpet to help me configure a Ubuntu 14 LAMP development box to use.
My confusion is around how the synced folders are setup. It seems that the synced folders on install, always create a new 'default' and 'html' folder in whatever local directory I specify in my puphpet setup. I then have to put any code files I want to run in the default folder.
For example: host folder: ./www ends up having /www/default and www//html in it after Vagrant up. Why is this occurring? I left the remote folder to the default /var/www.
My ideal setup was to have a Vagrant box folder setup on my machine, and then have my code project reside in the same directory as the Vagrant box files. However, it seems that I can only put the code project in the 'default' directory that Vagrant creates.
I can't find any mention of this in the documentation. Is this normal behaviour for this to be happening? If not, how can I get around this so that I can keep the code in whatever directory that I want?
Here's the relevant code from the puphpet config file:
synced_folder:
Rh7fCuil7xE4:
source: ./www
target: /var/www
sync_type: default
rsync:
args: '-z'
exclude: .vagrant/
auto: 'false'
Author of puphpet here.
Nginx creates a folder for its default vhost (same with Apache). That's what those two folders are. It also appears there's a small bug in puphpet that will create both folders, even though one is the right one. I'll see about fixing it, but it shouldn't affect your VM in the slightest.
/var/www is what you've defined as your target, so anything that appears in your master's ./www will also appear in your VM's /var/www and vice-versa.
There are few subfolders in my project folder that wouldn't need to be synced to the guest machine. (In particular the .git folder, which contains >800 files.) Is there a way to unsync subfolders of a synced folder in Vagrant? Or how should I prevent unneeded folders from being synced?
Disabling sync this way doesn't seem to work, when /vagrant/ is synced by default:
config.vm.synced_folder "www/kisa/.git/", "/vagrant/www/kisa/.git/", disabled: true
Normally (with vboxsf, vmhgfs, NFS, ...) the syncing is done by mounting the specified directory from the host to the guest. For performance reasons there should be no need to prevent some content from "syncing", as the data is not transferred unless you access it from the guest. If you write the data on the guest but don't want to sync it back to the host, easiest is to write it somewhere else. =)
The upcoming Vagrant 1.5 will include rsync synced folders which will support rsync__exclude option. Some cloud provider plugins (aws, digital_ocean, ..) already use rsync, but support for excluding depends on the provider. In some cases you just have to sync only the wanted folders separately. You can disable the default sync with
config.vm.synced_folder ".", "/vagrant", disabled: true
I can't pretend to understand this, but the method shown at this. seems to work for me for a Linux (Ubuntu) guest on a windows 7 host.
I wanted to use it for exactly what he describes - to exclude a node_modules directory from being shared.
In case the link disappears the gist is:
$ mkdir ~/vagrant_node_modules
$ sudo mount --bind ~/vagrant_node_modules /vagrant/node_modules
so that /vagrant is shared but /vagrant/node_modules is not.
Someone more knowledgeable than me might know if there are problems with this.