Chef open source server v11.1.7
chef-client v12.5.1
If I have a directory resource like so…
Directory_create_path = "#{node['weblogic']['Home']}/config/MultiSolution/resources"
directory Directory_create_path do
owner node['weblogic']['user']
group node['weblogic']['group']
mode '0755'
recursive true
end
where the last 2 directories MultiSolution/resources do not exist and I expect Chef to create them.
Chef seems to create MultiSolution directory with root permission (incorrect) and the resources directory with the correct user/group permission as mentioned in the directory resource.
How do I tell chef to create all directories in the path (where needed, if dir does not exist of course) with the owner/group permissions?
You need to not use the recursive property in favor of managing each directory independently. recursive applies the same logic as mkdir -p, which is to say that it uses the default umask.
Right. I have a lot of directory resources to define, then, if I need to manage each parent/child dir separately.
Perhaps alternatively I can create the dir structure and execute a chown at the end of it, at least that way I wont go stir crazy trying to create all the sub-dirs etc.
You can use fancier code if you want them to all be the same:
base = ''
%W{#{node['weblogic']['Home']} config MultiSolution resources}.each do |part|
base = File.join(base, part)
directory base do
# Stuff here
end
end