Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chmod fails to alter permissions in Vagrant VM

I am trying to set up a Vagrant environment to host Snowplow (https://github.com/snowplow). When I launch vagrant from a cygwin shell

$vagrant up && vagrant ssh

I get into an Ubuntu guest image (12.04), and when I attempt to install java8 into this environment using ansible, I get this message:

vagrant@precise64:~$ ansible-playbook /vagrant/ansible-playbooks/java8-gradle.yml --inventory-file=/vagrant/home/ansible/ansible_hosts --connection=local ERROR: The file /vagrant/home/ansible/ansible_hosts is marked as executable, but failed to execute correctly. If this is not supposed to be an executable script, correct this with chmod -x /vagrant/home/ansible/ansible_hosts.

The file is indeed 777:

-rwxrwxrwx 1 vagrant vagrant 24 Mar 3 19:03 ansible_hosts*

but this same file is sync'd to the host (Windows) and cygwin shows the file as 644:

-rw-r--r-- 1 rcoe Domain Users 24 Mar 3 14:03 ansible_hosts

Is there a known issue running in a headless (VirtualBox) Vagrant environment that doesn't allow permissions to be set on files that are sync'd to the host?

Thanks.

like image 243
Robin Coe Avatar asked Mar 03 '15 19:03

Robin Coe


1 Answers

It is a known deficiency, but reportedly not a bug: Changing shared folder permissions from within virtual machine

There is a good tutorial on how to set up the synced folder in vagrant so that it would suit your needs - if you navigate to that link it will show the following snippet

config.vm.synced_folder "./", "/var/sites/dev.query-auth", id: "vagrant-root",
   owner: "vagrant",
   group: "www-data",
   mount_options: ["dmode=775,fmode=664"]

that shows how to adjust the permissions of the synced folder.

Alternatively you could also use a different method of syncing the folder, such as rsync (keeping in mind what the trade-offs are)

config.vm.synced_folder "/Users/ryansechrest/Projects/Sites", "/var/www/domains", 
   type: "rsync"

More on that here

like image 143
Rafał Nowosielski Avatar answered Sep 28 '22 10:09

Rafał Nowosielski