Directory owner only set correctly on second run


#1

I am testing a cookbook using vagrant and chef 11.8.0

This is the relevant part of my recipe:

Chef::Log.info(“creating log dir: " + File.expand_path(”…", node[‘mongodb’][‘config’][‘logpath’]) + " for user: " + node[‘mongodb’][‘user’])
directory File.expand_path("…", node[‘mongodb’][‘config’][‘logpath’]) do
owner node[‘mongodb’][‘user’]
group 'root’
mode "0755"
action :create
end

which should create a directory, which belongs to the mongodb user.

This is the output if I run ‘vagrant up’

[2013-11-16T23:48:29+00:00] INFO: creating log dir: /logs/mongodb for user: mongodb

[2013-11-16T23:48:53+00:00] INFO: directory[/logs/mongodb] created directory /logs/mongodb
[2013-11-16T23:48:53+00:00] INFO: directory[/logs/mongodb] group changed to 0
[2013-11-16T23:48:53+00:00] INFO: directory[/logs/mongodb] mode changed to 755

This is the output if I run ‘vagrant provision’ after that run:

[2013-11-16T23:53:18+00:00] INFO: directory[/logs/mongodb] owner changed to 104

As you can see, it needs the second run to set the owner of the directory correctly.

Is there anything wrong with my approach, or might this be a bug?

Thanks,
Steve


#2

On Saturday, November 16, 2013 at 4:01 PM, Steve Hummingbird wrote:

I am testing a cookbook using vagrant and chef 11.8.0

This is the relevant part of my recipe:

Chef::Log.info (http://Log.info)(“creating log dir: " + File.expand_path(”…", node[‘mongodb’][‘config’][‘logpath’]) + " for user: " + node[‘mongodb’][‘user’])
directory File.expand_path("…", node[‘mongodb’][‘config’][‘logpath’]) do
owner node[‘mongodb’][‘user’]
group 'root’
mode "0755"
action :create
end

which should create a directory, which belongs to the mongodb user.

This is the output if I run ‘vagrant up’

[2013-11-16T23:48:29+00:00] INFO: creating log dir: /logs/mongodb for user: mongodb

[2013-11-16T23:48:53+00:00] INFO: directory[/logs/mongodb] created directory /logs/mongodb
[2013-11-16T23:48:53+00:00] INFO: directory[/logs/mongodb] group changed to 0
[2013-11-16T23:48:53+00:00] INFO: directory[/logs/mongodb] mode changed to 755

This is the output if I run ‘vagrant provision’ after that run:

[2013-11-16T23:53:18+00:00] INFO: directory[/logs/mongodb] owner changed to 104

As you can see, it needs the second run to set the owner of the directory correctly.

Is there anything wrong with my approach, or might this be a bug?

Thanks,
Steve

Are you sure nothing else is changing anything about that user during the chef run?


Daniel DeLeo