Skip to content

Instantly share code, notes, and snippets.

@lehrblogger
Last active December 10, 2015 14:08
Show Gist options
  • Save lehrblogger/4445336 to your computer and use it in GitHub Desktop.
Save lehrblogger/4445336 to your computer and use it in GitHub Desktop.
In my Chef cookbook:
["/home/vagrant/test", "/home/vagrant/test/subtest"].each do |dir|
Chef::Log.info(dir)
directory dir do
owner "vagrant"
group "vagrant"
mode 0644
recursive true
action :create
end
end
In my log I see the following (running `rvmsudo vagrant up`, after destroying the previous VM):
...
[2013-01-03T17:49:25+00:00] INFO: /home/vagrant/test
[2013-01-03T17:49:25+00:00] INFO: /home/vagrant/test/subtest
...
[2013-01-03T17:49:42+00:00] INFO: Processing directory[/home/vagrant/test] action create (vine_shared::default line 22)
[2013-01-03T17:49:42+00:00] INFO: directory[/home/vagrant/test] created directory /home/vagrant/test
[2013-01-03T17:49:42+00:00] INFO: directory[/home/vagrant/test] owner changed to 900
[2013-01-03T17:49:42+00:00] INFO: directory[/home/vagrant/test] group changed to 900
[2013-01-03T17:49:42+00:00] INFO: directory[/home/vagrant/test] mode changed to 644
[2013-01-03T17:49:42+00:00] INFO: Processing directory[/home/vagrant/test/subtest] action create (vine_shared::default line 22)
[2013-01-03T17:49:42+00:00] INFO: directory[/home/vagrant/test/subtest] created directory /home/vagrant/test/subtest
[2013-01-03T17:49:42+00:00] INFO: directory[/home/vagrant/test/subtest] owner changed to 900
[2013-01-03T17:49:42+00:00] INFO: directory[/home/vagrant/test/subtest] group changed to 900
[2013-01-03T17:49:42+00:00] INFO: directory[/home/vagrant/test/subtest] mode changed to 644
...
When SSH'd into the Vagrant VM and run ls, I see question marks for the directory:
vagrant@vagrant:~$ ls -la test/
ls: cannot access test/.: Permission denied
ls: cannot access test/..: Permission denied
ls: cannot access test/subtest: Permission denied
total 0
d????????? ? ? ? ? ? .
d????????? ? ? ? ? ? ..
d????????? ? ? ? ? ? subtest
vagrant@vagrant:~$ sudo ls -la test/
total 12
drw-r--r-- 3 vagrant vagrant 4096 Jan 3 17:49 .
drwxr-xr-x 5 vagrant vagrant 4096 Jan 3 17:49 ..
drw-r--r-- 2 vagrant vagrant 4096 Jan 3 17:49 subtest
@lehrblogger
Copy link
Author

For future Googlers (including myself), I needed to be using 00755 instead of 0644 for the directory permissions. See http://tickets.opscode.com/browse/CHEF-174 for more info about the extra 0, and http://content.hccfl.edu/pollock/aunix1/filepermissions.htm for more info about file permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment