2
votes

I have a chef custom resource myresource.rb

resource_name :myresource
property :artifact_id, String
property :group_id, String

action :create do
  Chef::Log.info("Package #{artifact_id} Group #{group_id}")
end

and i call it from coobook like this.

myresource 'myresource' do
  artifact_id "artefict"
  group_id "group"
end

but i get following error on that logging:

NameError: undefined local variable or method `artifact_id'

Any idea what might be wrong? I have also tried:

Chef::Log.info("Package #{:artifact_id} Group #{:group_id}")

Though this does not throw an error, it outputs:

Package artifact_id Group group_id

which is not correct.

1

1 Answers

2
votes

I solved it. Since Chef version 14, you have to refer to property with resource.property_name, not just property_name. I was a bit confused before, as they were using both types in Chef Custom Resource Docs, probably they didn't update the entire documentation with the new approach yet.