Allowed Characters in a Chef's Cookbook with LWRP

I have an LWRP resource defined in my Cookbook - as described at

So, let's assume my cookbook name is some name, so I have the files (as you can guess, this LWRP is based on the code):



File contents. / some -name / recipes / some-kind.rb:

some-name_manage "some-kind" do
  data_bag "some-kind"


While calling the nightly cookbook some name load I get:

FATAL: Cookbook file recipes/some-kind.rb has a ruby syntax error: 
FATAL: /path/to/chef-repo/cookbooks/some-name/recipes/some-kind.rb:2: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '(' 
FATAL: some-name_manage "some-kind" do
FATAL:                   ^
FATAL: /path/to/chef-repo/cookbooks/some-name/recipes/some-kind.rb:2: syntax error, unexpected keyword_do, expecting keyword_end
FATAL: /path/to/chef-repo/cookbooks/some-name/recipes/some-kind.rb:8: syntax error, unexpected keyword_end, expecting $end


The problem is my cookbook contains a dash ("-") character. If I haven't put a dash in the cookbook, then everything will be fine.

So the question is, is there a way to use the dash character in the cookbook name when you want to use LWRP? Some kind of escape?


source to share

1 answer

Hyphens become underscores in resource names, so it should be some_name_manage

. This is because dashes are not allowed in Ruby method names.



All Articles