I wrote a simple chef script. There is a folder t1 in /DirectoryPath. Now I'm creating a new folder in /DirectoryPath/t5. But listDirectory() method gives same output, as if no new directory was created. I'm on MAC with chef 11.4
My script is like below
recipe.rb
def listDirectory()
ls = `ls ~/Delete`
return ls
end
log(listDirectory())
directory '/DirectoryPath/t5' do
action :create
end
log(listDirectory())
Output
Recipe: test::default
* log[t1] action write[2015-11-03T15:02:47-08:00] INFO: Processing log[t1] action write
[2015-11-03T15:02:47-08:00] INFO: t1
* directory[/DirectoryPath/t5] action create[2015-11-03T15:02:47-08:00] INFO: Processing directory[/DirectoryPath/t5] action create (test::default line 10)
[2015-11-03T15:02:47-08:00] INFO: directory[/DirectoryPath/t5] created directory /DirectoryPath/t5
- create new directory /DirectoryPath/t5
* log[t1] action write[2015-11-03T15:02:47-08:00] INFO: Processing log[t1] action write
[2015-11-03T15:02:47-08:00] INFO: t1
According to me 2nd log statement should show folders t1 and t5, but it is showing only t1. Can I know what could be the reason behind the command returning same result even if there was some change. And how do I avoid it?