Reputation: 17261
I am stuck trying to create my first lwrp
I have created a very basic resource + provider at:
resources/rack_site.rb
providers/rack_site.rb
I've been trying to test the 'rack_site' resource within a recipe of the same cookbook, but it fails with an error about resource not found. I tried moving both files into a cookbook which I added as dependency, but still fails.
What must be done to use a custom resource into a recipe?
Upvotes: 3
Views: 1002
Reputation: 9584
This got me too. You can access the LWRP by prepending the cookbook name from your metadata.rb
and an underscore to the resource name. For example if the rack site resource is in the Foo cookbook: foo_rack_site
.
Upvotes: 6
Reputation: 26997
Chef uses the name of the cookbook (as defined in the metadata.rb
) to prefix LWRPs. For example, if your cookbook was named acme-nginx
, and you have a resource named rack_site.rb
, the associated LWRP in the recipe DSL is acme_nginx_rack_site
. For example:
acme_nginx_rack_site 'foo' do
# ...
end
Chef will automatically convert characters which are not valid for Ruby methods to an underscore (including dashes).
Upvotes: 8