I'm trying to use directory resource under Chef LWRP, but unable to access the attribute inside the resource block, is there a way to do it. Or am I totally wrong and need different approach to achieve this.
my-cookbook/providers/default.rb
use_inline_resources
action :setup do
directory node["#{@new_resource.name}"] do
action :create
not_if {node["#{@new_resource.name}"].include? "test"}
end
end
The @new_resource.name on the line not_if {node["#{@new_resource.name}"].include? "test"} is evaluated as nilClass,
while it gets properly evaluated in directory node["#{@new_resource.name}"] do line
Thanks
At last, found it
When referring to variable inside another resource, we need to access it without @.
Thanks to @stajkowski (GitHub)