Why can't chef resolve my cookbooks? -
Why can't chef resolve my cookbooks? -
intro learning chef automate server management @ work. downloaded chefdk 3.0 here , trying build first cookbook using chef.
important using in windows environment testing purpose, expect fail since windows not have iptables, not expect fail saying can't find cookbook. i've tried using windows cookbook , works.
the problem able create cookbook , run it, not able reference dependencies supermarket.
i have tried 2 alternatives:
alternative 1
i used next command create cookbook
chef generate cookbook learn_chef_httpd
(from this tutorial)
i able finish tutorial , test referencing cookbook, chose simple_iptables
i added line
cookbook 'simple_iptables', '~> 0.7.0'
to berksfile, described in supermarket.
then added these lines default.rb file:
include_recipe 'simple_iptables' # allow http, https simple_iptables_rule "http" rule [ "--proto tcp --dport 80", "--proto tcp --dport 443" ] jump "accept" end
and run cookbook using:
chef-client --local-mode --runlist 'recipe[learn_chef_httpd]'
the problem chef doesn't find cookbook
chef::exceptions::cookbooknotfound ---------------------------------- cookbook simple_iptables not found. if you're loading simple_iptables anoth er cookbook, create sure configure dependency in metadata
i tried adding metadata:
depends 'simple_iptables', '~> 0.7.0'
but still error:
error resolving cookbooks run list: missing cookbooks: no such cookbook: simple_iptables
alternative 2
i still trying create work tried making "the berkshelf way", created new cookbook.
berks cookbook test
and added line
cookbook 'simple_iptables', '~> 0.7.0'
to berksfile, described in supermarket.
then added these lines default.rb file:
include_recipe 'simple_iptables' # allow http, https simple_iptables_rule "http" rule [ "--proto tcp --dport 80", "--proto tcp --dport 443" ] jump "accept" end
executed berks install:
berks install
and ran it:
chef-client --local-mode --runlist 'recipe[test]'
the same error came back
chef::exceptions::cookbooknotfound ---------------------------------- cookbook simple_iptables not found. if you're loading simple_iptables anoth er cookbook, create sure configure dependency in metadata
i tried adding metadata:
depends 'simple_iptables', '~> 0.7.0'
but still error:
error resolving cookbooks run list: missing cookbooks: no such cookbook: simple_iptables
i looked @ ~/berkshelf folder , cookbooks there.
** alternative 3 **
i started centos 6.5 ec2 instance on amazon, installed ruby 2.1.3 , chef. created ~/chef-repo/cookbooks folder
i created cookbook using berkshelf, ran
bundle install
added reference/code in other alterantives then
berks install
and ran same way did lastly time.
i got same issues.
what missing? need create work?
make sure have configured chef_repo_path
described in docs.
basically local-mode
needs know find cookbooks, roles, environments, info bags, etc. sadly, documentation not super clear on where/how set chef_repo_path
here's can tell code.
ifclient.rb
found , contains cookbook_path
, chef_repo_path
= "#{cookbook_path}/.."
if knife.rb
found , contains cookbook_path
, chef_repo_path = "#{cookbook_path}/.."
chef can seek divine path. the code search pwd
upward looking directory called cookbooks
. if finds it, cookbooks/..
set chef_repo_path. if else fails, pwd
used chef_repo_path
if using berkshelf, best bet berks vendor
in order single directory of cookbooks need. can point chef_repo_path parent of cookbooks
directory holds vendored cookbooks.
mind you, that's 10 minutes of digging in source code, may not have quite right.
chef chef-recipe berkshelf
Comments
Post a Comment