amazon-web-serviceschef-infracookbook

Unable to create a file inside a cookbook


Am learning chef by self study,am unable create a file inside my chef cook book

Fallowing are my steps,which i've done in linux instance

  1. Created a Directoy(using mkdir command) named it as cookbooks
  2. went inside the directory (using cd cookbooks)
  3. generated cookbook (using chef generate cookbookt test-cookbook) and move inside the cookbook(using cd test-cookbook)
  4. created a recipe (chef generate recipe test-recipe) and came back in to my my directory i;e out of of test-cookbook(using cd ..)
  5. created a file using vi test-cookbook/recipes/test-recipe.rd, which looks like: file '/myfile' do content 'hello' action:create end
  6. i gave this command chef exec ruby -c test-cookbook/recipes/test-recipe.rb & the result is "Sytax ok"
  7. now i gave this command chef-client -zr "recipe[test-cookbook::test-rescipe], which is throwing me error:

    Missing Cookbooks:
    ------------------
    No such cookbook: test-cookbook
    

Solution

  • this happens since you did not configure chef-client correctly. you are missing the client.rb file and the settings cookboook_path within it.

    refer to this answer for full details