Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chef: Insufficient permissions creating a directory in C:

I'm experiencing an error while trying to create a directory in C:\Program Files using Chef. I am running chef from a powershell environment as Administrator, so there shouldn't be any restrictions as to what actions I can perform.

recipes/default.rb

directory node['app']['unzip_path'] do
  action :create
end

attributes/default.rb

default['app']['unzip_path'] = 'C:/Program files/App'

I'm getting this error:

[2013-06-25T01:51:13+00:00] FATAL: Chef::Exceptions::InsufficientPermissions: directory[C:/Program files/App] (app::agent line 15) had an error: Chef::Exceptions::InsufficientPermissions: Cannot create directory[C:/Program files/App] at C:/Program files/App due to insufficient permissions

Additional question: Does chef-solo run as the user running the powershell command or is it running as a special "chef" user

like image 279
BrianJakovich Avatar asked Oct 04 '22 17:10

BrianJakovich


1 Answers

Following up on BrianJakovich's answer. The mkdir_p call should preserve idempotence in either case, but using a ruby block will probably be better since it will run at the convergence phase:

ruby_block "hack to mkdir on windows" do
    block do
        FileUtils.mkdir_p node['app']['unzip_path']
    end
end
like image 52
yoniLavi Avatar answered Oct 07 '22 18:10

yoniLavi