1

I am trying to update my cookbook and uploading this to my Chef Server. I am facing this issue:

sudo knife cookbook upload demo -VV
INFO: Using configuration from /home/centos/chef-repo/.chef/knife.rb
ERROR: Could not find cookbook demo in your cookbook path, skipping it
DEBUG: Cannot find a cookbook named demo; did you forget to add metadata to a cookbook? (https://docs.chef.io/config_rb_metadata.html) (Chef::Exceptions::CookbookNotFoundInRepo)
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/cookbook_loader.rb:127:in `[]'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife/cookbook_upload.rb:173:in `block in cookbooks_to_upload'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife/cookbook_upload.rb:170:in `each'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife/cookbook_upload.rb:170:in `cookbooks_to_upload'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife/cookbook_upload.rb:208:in `warn_about_cookbook_shadowing'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife/cookbook_upload.rb:96:in `run'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife.rb:443:in `block in run_with_pretty_exceptions'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife.rb:442:in `run_with_pretty_exceptions'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/knife.rb:219:in `run'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/knife.rb:156:in `run'
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/bin/knife:25:in `<top (required)>'
/bin/knife:58:in `load'
/bin/knife:58:in `<main>'
DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
DEBUG: Signing the request as devops
DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
DEBUG: Initiating GET to https://serveraddress/organizations/us-int-core/cookbooks?num_versions=all
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: Accept: application/json
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: X-Ops-Server-API-Version: 1
DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.1;
DEBUG: X-OPS-USERID: devops
DEBUG: X-OPS-TIMESTAMP: 2017-01-25T13:53:38Z
DEBUG: X-OPS-CONTENT-HASH: 2jmj7l5rSw0yVb...........=
DEBUG: X-OPS-AUTHORIZATION-1: j1fkjmn1FAS...........
DEBUG: X-OPS-AUTHORIZATION-2: g2TCxj1fkjm...........
DEBUG: X-OPS-AUTHORIZATION-3: PLbt7DY9LbFJ..........
DEBUG: X-OPS-AUTHORIZATION-4: RHIvVfQD6qve..........
DEBUG: X-OPS-AUTHORIZATION-5: Hvn50AjLwasd1Z........
DEBUG: X-OPS-AUTHORIZATION-6: murM3EwGJWic..........==
DEBUG: HOST: ip-172-20-88-20:443
DEBUG: X-REMOTE-REQUEST-ID: 33cf1aa9-31f3-43b0-89b9-........
DEBUG: ---- End HTTP Request Header Data ----
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 200 OK
DEBUG: server: openresty/1.11.2.1
DEBUG: date: Wed, 25 Jan 2017 13:54:12 GMT
DEBUG: content-type: application/json
DEBUG: content-length: 2
DEBUG: connection: close
DEBUG: x-ops-server-api-version: {"min_version":"0","max_version":"1","request_version":"1","response_version":"1"}
DEBUG: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=12.11.1+20161118001025
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
DEBUG: Content-Length validated correctly.
DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
Uploaded 0 cookbook.

Looking the first line with INFO tag

INFO: Using configuration from /home/centos/chef-repo/.chef/knife.rb

The line above is using that knife configuration it is:

cat /home/centos/chef-repo/.chef/knife.rb

log_level                :info
log_location             STDOUT
node_name                'devops'
client_key               '/home/centos/chef-repo/.chef/devops.pem'
validation_client_name   'us-int-core-validator'
validation_key           '/home/centos/chef-repo/us-int-core-validator.pem'
chef_server_url          'https://serveripaddress:443/organizations/us-int-core'
syntax_check_cache_path  '/home/centos/chef-repo/.chef/syntax_check_cache'
cookbook_path            [ '~/chef-repo/cookbooks/' ]

And the into that path are my cookbooks and also the demo cookbook I am trying to upload.

I do not know what is the issue with the path. Everything looks good but I am missing something. Any suggestions?

Checking the cookbook list

ll /home/centos/chef-repo/cookbooks/
total 28
drwxr-xr-x. 10 root root 4096 Jan 19 21:41 apache
-rwxr-xr-x.  1 root root  588 Jan 19 21:09 chefignore
drwxr-xr-x.  8 root root 4096 Jan 24 20:42 demo
drwxr-xr-x.  9 root root 4096 Jan 19 21:41 docker
drwxr-xr-x.  9 root root 4096 Jan 19 21:41 ntp

The list above shows all the cookbooks in the path and demo is right there.

Robert
  • 10,403
  • 14
  • 67
  • 117
  • Does your cookbook exist at `/home/centos/chef-repo/cookbooks/demo` ? And when you do `sudo knife` is your present directory `/home/centos/chef-repo/` ? – vikingsteve Jan 25 '17 at 14:10
  • @vikingsteve I updated the question and yes, the demo cookbook is there – Robert Jan 25 '17 at 14:13
  • @robert Why sudo ??? (I bet sudo change what ~expand to to /root and so knife search inside /root/chef-repo/cookbooks/) – Tensibai Jan 25 '17 at 14:23
  • @Tensibai. Well let me change the *.pem permission to 644 and I will try with sudo. I think so, that is a good point. I will let you know if that changes something. – Robert Jan 25 '17 at 14:26
  • knife and the rest of chef-dk has no reason to be run as root, your key and everything should belong to your user – Tensibai Jan 25 '17 at 14:27
  • Just tested: `sudo knife exec -E "puts ENV['HOME']"` returns `/root` – Tensibai Jan 25 '17 at 14:30
  • 1
    @Tensibai you were right !! Based on permission I changed the permission (to 644) to all my *.pem keys into the .chef folder in order to avoid the use of sudo execution and it's working know. Was something pretty easy and I didn't realized. Thank you guys for your help. – Robert Jan 25 '17 at 15:24

1 Answers1

0
cookbook_path  

in your knife.rb can result in the same error.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 16 '22 at 08:07