【问题标题】:knife upload cookbook does not find the cookbook name in the path刀上传食谱在路径中找不到食谱名称
【发布时间】:2022-02-16 11:19:22
【问题描述】:

我正在尝试更新我的食谱并将其上传到我的 Chef 服务器。我正面临这个问题:

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.

查看带有 INFO 标记的第一行

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

上面的行使用的是刀配置:

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/' ]

进入该路径的是我的食谱以及我尝试上传的演示食谱。

我不知道路径有什么问题。一切看起来都很好,但我错过了一些东西。有什么建议么?

检查食谱列表

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

上面的列表显示了路径中的所有食谱,演示就在那里。

【问题讨论】:

  • 您的食谱是否存在于/home/centos/chef-repo/cookbooks/demo?当你这样做时sudo knife 是你当前的目录/home/centos/chef-repo/ 吗?
  • @vikingsteve 我更新了问题,是的,演示食谱在那里
  • @robert 为什么 sudo ??? (我敢打赌 sudo 将 ~expand 更改为 /root 并在 /root/chef-repo/cookbooks/ 内进行刀搜索)
  • @Tensibai。好吧,让我将 *.pem 权限更改为 644,然后我将尝试使用 sudo。我想是的,这是一个很好的观点。如果这有什么改变,我会告诉你的。
  • @Tensibai 你是对的!根据权限,我将所有 *.pem 密钥的权限(更改为 644)更改为 .chef 文件夹,以避免使用 sudo 执行,并且知道它的工作原理。是一件很容易的事,我没有意识到。谢谢你们的帮助。

标签: chef-infra chef-solo knife cookbook knife-solo


【解决方案1】:
cookbook_path  

在您的 knife.rb 中可能会导致相同的错误。

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2020-01-06
  • 2021-11-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-05
  • 1970-01-01
  • 1970-01-01
  • 2018-12-01
相关资源
最近更新 更多