I am using Linux Mint as Host and CentOS as guest, whenever i am trying to share a folder to an apache folder (example below) it fails and all other apache actions fail to.
config.vm.share_folder "apache", "/var/www/html", "../src", :extra => 'dmode=775,fmode=775', :nfs => (FFI::Platform::IS_WINDOWS ? false: true)
I get following error then:
error: unpacking of archive failed on file /var/www/html: cpio: chown failed - Operation not permitted
However, when i mount the folder to lets say /html, there is not a single problem and my vagrant runs clean.
I am desperatly trying to get things in the folders they are meant to be, any idea how i can fix this?
here we've having some kind of this problem too.
The way it worked here was to adjust the syntax of nfs exporting to:
config.vm.synced_folder ".", "/vagrant", :nfs => { :mount_options => ["dmode=777","fmode=777"] }
as stated in 26710386
note the :nfs line and mount options. You must to use it as
nfs => { :mount_options => ["dmode=777","fmode=777"] }
and not as the latter way type: "nfs", mount_options: ... was.
Hope it helps.
Related
I have a Vagrantfile and the default option for mounting on non windows machines is NFS.
if Vagrant::Util::Platform.windows? == false
config.vm.synced_folder ".", "/vagrant", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp']
end
However we have a developer that didn't have NFS installed on his 'nix box and it took awhile to figure out that was the problem.
Is there a way to check if the host machine has NFS installed in a similar approach from within the vagrantfile?
You can read this https://www.vagrantup.com/docs/plugins/host-capabilities.html The definition and implementation of host capabilities is identical to guest capabilities.
In my Vagrantfile (Vagrant 1.7.4) I have the following:
config.vm.synced_folder ".", "/home/vagrant/sync", type: "rsync", :mount_options => ["dmode=777", "fmode=666"], rsync__exclude: [".git/"]
When I issue vagrant up, it outputs the following:
==> default: Rsyncing folder: /project/ => /home/vagrant/sync
==> default: - Exclude: [".vagrant", ".git/",]
==> default: Mounting shared folders...
default: /vagrant => /project
I don't understand why there is a shared and a synced folder. I'm using virtualbox so i understand these are the same but I just want a shared folder - why are there 2?
So first sync folder is the Vagrant term for Virtual Box shared folder, so you're correct to say the 2 are the same. Now coming to your question,
By default, Vagrant will share your project directory (the directory
with the Vagrantfile) to /vagrant.
This is defined as config.vm.synced_folder ".", "/vagrant"; so this one always comes, if you define or not new sync folder.
If you want not to have the default sync folder, you can add the following to your Vagrant file
config.vm.synced_folder ".", "/vagrant", disabled: true
I managed to setting up my Symfony2 project inside a ubuntu vagrant box. But it takes around 20 seconds to load the website through it's webserver. After some research, i came up with using nfs for the sync folder. Here're my setting from Vagrantfile:
config.vm.network "private_network", ip: "192.168.56.101"
config.vm.synced_folder ".", "/vagrant", :nfs => true, :mount_options => ["dmode=777","fmode=777"]
After starting de vagrant box i get the following error
==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mount -o 'dmode=777,fmode=777' 192.168.56.1:'/Users/marcschenk/Projects/teleboy.ch' /vagrant
Stdout from the command:
Stderr from the command:
stdin: is not a tty
mount.nfs: an incorrect mount option was specified
The VM seems to work, but the synced folder's obviously empty. What did i wrong?
My setup:
Vagrant 1.6.5 & Virtualbox 4.3.18
Host: OS X 10.10
Guest: Ubuntu 12.04
Found the solution for the problem here https://github.com/mitchellh/vagrant/issues/2546
The correct syntax for vagrant version 1.3 to 1.6 is:
config.vm.synced_folder ".", "/vagrant", :nfs => { :mount_options => ["dmode=777","fmode=777"] }
I want to develop WordPress websites locally using Vagrant (Host: Windows 8 64-bit; Guest: Ubuntu 12.04 LTS). I am using Chris Wiegman's Primary Vagrant (an Apache version of VVV)
I got it working, but as soon as I added all my files the site ran incredibly slow. After research I'm guessing this is down to shared folders being slow. The work around as mention in this blog post on the Vagrant website, is to use rsync.
Despite their being no instructions on how to get rsync working on Windows, I came across this article which recommends the free version of cwrsync. I also had to add the path environmental variable so that rsync worked across all folders on Windows (this answer helped with this)
I edited the vagrant file so that rsync would be used by appending ,"rsync", rsync__exclude: ".git/" to the Primary Vagrant vagrant file:
config.vm.synced_folder "sites/stable.wordpress.vagrant", "/var/www/stable.wordpress.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/stable.wordpress.vagrant/uploads", "/var/www/stable.wordpress.vagrant/wordpress/wp-content/uploads", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/trunk.wordpress.vagrant", "/var/www/trunk.wordpress.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/trunk.wordpress.vagrant/uploads", "/var/www/trunk.wordpress.vagrant/wordpress/wp-content/uploads", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/Search-Replace-DB", "/var/www/replacedb.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/phpmyadmin", "/var/www/phpmyadmin.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
config.vm.synced_folder "sites/webgrind", "/var/www/webgrind.vagrant", :owner => "www-data", :mount_options => [ "dmode=775", "fmode=774" ],"rsync", rsync__exclude: ".git/"
Then I did a vagrant up --provision. But unfortunately I am getting the following error messages. Despite trying to find the issue online, I can't.
Here are the error messages:
==> default: Rsyncing folder: /cygdrive/c/Users/IanAnderson/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites
/stable.wordpress.vagrant/ => /var/www/stable.wordpress.vagrant
==> default: - Exclude: [".vagrant/", ".git/"]
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /cygdrive/c/Users/IanAnderson/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites/stable.wordpress.v
agrant/
Guest path: /var/www/stable.wordpress.vagrant
Command: rsync --verbose --archive --delete -z --chmod=ugo=rwX --no-perms -e ssh -p 2222 -o StrictHostKeyChecking=no -i
'C:/Users/IanAnderson/.vagrant.d/insecure_private_key' --exclude .vagrant/ --exclude .git/ /cygdrive/c/Users/IanAnderson
/Documents/Sites/Vagrants/Primary-Vagrant/vagrant-local/sites/stable.wordpress.vagrant/ vagrant#127.0.0.1:/var/www/stabl
e.wordpress.vagrant
Error: Warning: Permanently added '[127.0.0.1]:2222' (RSA) to the list of known hosts.
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [Receiver=3.0.9]
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(759) [sender=3.0.6]
Try using MinGW. It brings its own ssh.exe in /bin
and rsync.exe in /msys/<version_number>/bin.
Adding these directories to my PATH made it work on my machine.
Adding to Sebastian Kliem's answer: for me it was necessary to add the MinGW /bin directory to the start of my PATH. I got the error you mentioned when using git's ssh with MinGW's rsync. Putting MinGW at the start made sure the two worked well together.
This is no rsync solution, but it works for sharing files to a windows host with better performace than regular virtual box shares.
I successfully used this plugin which starts a nfs daemon on windows: https://github.com/winnfsd/vagrant-winnfsd
I haven't tested it thoroughly because it is a work in progress and first time supporting windows on my project. It seems to do the trick and performs decently so far. Haven't tried it with MySQL data shared onto the host, which was the slowest resource of the server stack.
Also, i use it along the vagrant-bindfs plugin to route the user uid/gid. This probably ads overhead to the mix though but automates the whole process.
I know this question is older than the issue, but in case this might help someone: there is a known issue with Vagrant >=1.8.0 and Windows hosts that triggers this kind of error messages.
To prevent this, try removing the following lines (77 to 79) in $VAGRANT_HOME\embedded\gems\gems\vagrant-1.8.0\plugins\synced_folders\rsync\helper.rb :
"-o ControlMaster=auto " +
"-o ControlPath=#{controlpath} " +
"-o ControlPersist=10m " +
Source
I have been using http://www.puphpet.com successfully to generate vagrant+puppet environments for a number of projects. Then this week I got tasked with writing a prototype for a project using Laravel 4. Since I'm not going to be the one working on the project full time, I figured it would be best to make a VM environment for it that the next person can just clone for the repo. Not having much experience with Laravel 4 I got everything to run in the dev environment just fine. Then I tried to run the first migration and here the problems start with the app/storage file permissions.
1. app/storage must be writable by the web user
Fine, took out id: vagrant from the synced folder provisioning and set the owner & group to www-data like so:
config.vm.synced_folder "./www", "/var/www", owner: "www-data", group: "www-data"
2. Artisan can only be run from inside the vagrant box to have access to the DB
Fine, vagrant ssh and run artisan from the www folder.
3. app/storage & app/database have to be writable by the vagrant user in order to use migrations
Grrr, ok, added the following awful piece of code to the vagrant file (note, tried to do this in Puppet first and it didn't take):
config.vm.provision :shell, :inline =>
"usermod -a -G www-data vagrant"
4. app/storage & app/database are not writeable by the group
Argh!!! Ok, let's try this Puppet directive:
file { "/var/www/app/storage":
source => "/var/www/app/storage/",
mode => 0775,
ensure => 'directory',
owner => 'www-data',
group => 'www-data',
recurse => true
}
Nope, doesn't work. Tried to do the same with the Puppet exec {} directive to no effect. It seems that permissions for the vagrant synced folder are set by the host machine, not the guest.
Finally ended up manually changing the permissions for the folder in the host machine. Is there any simpler way to do this? I would really just like to be able to give the next dev a worry free environment they can clone from the repo, not have them re-setup everything after cloning.
UPDATE
We've figured out that if we change the Apache run user, vagrant doesn't override it on reload. So we've done that manually and it's working better than changing the synced folder's permissions & owner. Now we're just trying to figure out how to make that change manually in Puppet.
After some discussion on Twitter, figured out the following:
There's a constraint from VirtualBox on vagrant that does not allow you to set permissions for the synced folder from inside the guest OS. See this issue on github.
You can use the following code to set the synced folder permissions from the vagrant file:
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777","fmode=666"]
Or you can change the Apache runtime user to vagrant from the puppet manifest like so:
exec { "change_httpd_user":
command => "sed -i 's/www-data/vagrant/g' /etc/apache2/envvars",
onlyif => "/bin/grep -q 'www-data' '/etc/apache2/envvars'",
notify => Service['apache2'],
require => Package['apache2'],
}
file { "/var/lock/apache2":
ensure => "directory",
owner => "vagrant",
group => "vagrant",
require => Exec['change_httpd_user'],
}
Or any combination of the above
I'm not using pupphet in my setup and I came up with 2 solutions:
(1) In my bootstrap.sh file:
sudo sed -i 's/APACHE_RUN_USER=.*/APACHE_RUN_USER=vagrant/g' /etc/apache2/envvars
sudo sed -i 's/APACHE_RUN_GROUP=.*/APACHE_RUN_GROUP=www-data/g' /etc/apache2/envvars
(2) Im my VagrantFile:
config.vm.synced_folder "./", "/vagrant", id: "vagrant-root" , :owner => "vagrant", :group => "www-data"
config.vm.synced_folder "./app/storage", "/vagrant/app/storage", id: "vagrant-storage",
:owner => "vagrant",
:group => "www-data",
:mount_options => ["dmode=775","fmode=664"]
config.vm.synced_folder "./public", "/vagrant/public", id: "vagrant-public",
:owner => "vagrant",
:group => "www-data",
:mount_options => ["dmode=775","fmode=664"]
Have a look at this section of the Vagrant documentation http://docs.vagrantup.com/v2/synced-folders/basic_usage.html