3
votes

I have LWRP resource defined in my Cookbook - as described on http://docs.getchef.com/chef/lwrps_custom.html#file-locations

So let's assume my cookbook name is some-name, so I have files (as you can guess this LWRP is based on https://github.com/sethvargo-cookbooks/users code):

./some-name/recipes/default.rb
./some-name/recipes/some-kind.rb
./some-name/providers/manage.rb
./some-name/resources/manage.rb

Contents of file ./some-name/recipes/some-kind.rb are:

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

While calling knife cookbook some-name upload 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 issue is my cookbook contain dash ("-") character. If I put no dashes into cookbook then everything is OK.

So the question: is there any way to use dash character in cookbook name when willing to use LWRPs? Some kind of escape?

1

1 Answers

7
votes

Hyphens become underscores in resource names, so that should be some_name_manage. This is because hyphens aren't allowed in Ruby method names.