sous-chefs / vagrant

Development repository for the vagrant cookbook
https://supermarket.chef.io/cookbooks/vagrant
Apache License 2.0
57 stars 52 forks source link

installing plugin leads to wrong file ownership #100

Closed ingobecker closed 5 years ago

ingobecker commented 5 years ago

Cookbook version

0.9.1

Chef-client version

14.10.9

Platform Details

ubuntu 18.04.2

Scenario etc:

Running the default recipe with the attribute node['vagrant']['plugins'] = ['vagrant-libvirt'] and node['vagrant']['user'] = <user> leads to a ~/.vagrant.d directory with the ownership of <user>:root. This is caused by the shell_out call which has no group set in its options. Would be good if the permissions would be set to <user>:<user_group>. I could create a PR to fix this.

MarkGibbons commented 5 years ago

A PR would be interesting. Are you thinking of trying to determine the user group or having it set as an attribute?

thanks, Mark

ingobecker commented 5 years ago

I think both would be possible. If the user doesn't set a group explicitly but a user, i would assume, that the user wants to run the command with the primary group of the user given. If the user specifies a group, than the group could be overwritten by that.

MarkGibbons commented 5 years ago

The vagrant plugin install creates the .vagrant.d directory, not the cookbook. I don't see a way to influence the plugin install process to assign the group value. If you know how to do that a PR would be ok.

It's a simple matter to use a directory resource to set the desired attributes however:

directory '/home/user1/.vagrant.d' do
   user 'user1'
   group 'group1'
end

To me this looks like a vagrant plugin install limitation with a pretty easy chef work around. I'll intend to close this incident since there's a simple work around.

MarkGibbons commented 5 years ago

I recommend using the username and vagrant_home properties to install plugins in user directories with the right user assigned. Use a directory resource to set any other desired settings for the .vagrant.d directory, owning group would be one of those other settings. If needed the fileutils cookbook could be used to set attributes to all the files in the .vagrant.d directory.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.