Let's say we have two resources:
template 'template1' do owner 'root' group 'root' end template 'template2' do owner 'root' group 'root' end
I would like to reuse the code inside the resources. However, if I define proc in the recipe, you get a NoMethodError for owner
, group
, etc. Why is this happening? The lexical area is no different, right? As a result, I should use self.instance_eval &common_cfg
.
common_cfg = Proc.new { owner 'root' group 'root' } template 'template1' do common_cfg.call end template 'template2' do common_cfg.call end
source share