chef-cookbooks / ssh_known_hosts

Development repository for Chef Cookbook ssh_known_hosts
https://supermarket.chef.io/cookbooks/ssh_known_hosts
Apache License 2.0
72 stars 77 forks source link

Newbie question: Why can't the recipe see its own LWRP for entry? #35

Closed lonniev closed 9 years ago

lonniev commented 9 years ago

I strongly expect this is pilot error. I added the ssh_known_hosts recipe to the Cheffile for librarian-chef, added an include_recipe import for ssh_known_hosts to my dependent recipe, remembered to run librarian_chef update for the vagrant's directory, and received this when I tried to use the ssh_known_hosts_entry LWRP in my recipe. What did I overlook?

==> vb-tt-dev: NoMethodError
==> vb-tt-dev: -------------
==> vb-tt-dev: No resource or method named `ssh_known_hosts_entry' for `Chef::Recipe "default"'
==> vb-tt-dev: 
==> vb-tt-dev: 
==> vb-tt-dev: Cookbook Trace:
==> vb-tt-dev: ---------------
==> vb-tt-dev:   /tmp/vagrant-chef-2/chef-solo-1/cookbooks/ssh_known_hosts/recipes/default.rb:70:in `block in from_file'
==> vb-tt-dev: 
==> vb-tt-dev:   /tmp/vagrant-chef-2/chef-solo-1/cookbooks/ssh_known_hosts/recipes/default.rb:62:in `each'
==> vb-tt-dev:   /tmp/vagrant-chef-2/chef-solo-1/cookbooks/ssh_known_hosts/recipes/default.rb:62:in `from_file'
==> vb-tt-dev:   /tmp/vagrant-chef-2/chef-solo-1/cookbooks/get-gitrepos/recipes/default.rb:20:in `from_file'
lonniev commented 9 years ago

Looks like http://stackoverflow.com/questions/17330374/including-a-chef-lwrp-from-another-cookbook will probably fix my ignorance.

lonniev commented 9 years ago

That was it: don't include the recipe in one's default recipe and do add the depends line in one's metadata.rb for the recipe. Ok.

==> vb-tt-dev: [2014-12-01T16:03:48+00:00] INFO: file[ssh_known_hosts-github.com] created file /etc/ssh/ssh_known_hosts
==> vb-tt-dev: [2014-12-01T16:03:48+00:00] INFO: file[ssh_known_hosts-github.com] updated file contents /etc/ssh/ssh_known_hosts