尝试设置厨师工作站
knife configure -i
以前它工作但现在它不工作我无法创建knife.rb它说以下错误:
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/config_fetcher.rb:53:in `realpath': Not a directory - /home/ubuntu/.chef/knife.rb (Errno::ENOTDIR)
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/config_fetcher.rb:53:in `realpath'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/config_fetcher.rb:53:in `config_missing?'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/knife.rb:350:in `block in locate_config_file'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/knife.rb:348:in `each'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/knife.rb:348:in `locate_config_file'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/knife.rb:418:in `configure_chef'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/knife/configure.rb:65:in `configure_chef'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/knife.rb:173:in `run'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/application/knife.rb:135:in `run'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/bin/knife:25:in `<top (required)>'
from /usr/bin/knife:23:in `load'
from /usr/bin/knife:23:in `<main>'
答案 0 :(得分:5)
我怀疑“.chef”目录丢失了。试试这个:
mkdir ~/.chef
首先从我的厨师服务器下载管理员和验证密钥
ssh myusername@chefserver sudo cat /etc/chef-server/admin.pem > ~/.chef/admin.pem
ssh myusername@chefserver sudo cat /etc/chef-server/chef-validator.pem > ~/.chef/chef-validator.pem
生成〜/ .chef / knife.rb 文件时引用这些文件:
knife configure --server-url https://chefserver \
--user admin \
--key ~/.chef/admin.pem \
--validation-client-name chef-validator \
--validation-key ~/.chef/chef-validator.pem
Chef 12不再创建默认的“admin”用户。相反,您必须创建一个用户并将其与组织关联。
创建一个名为“myuser”的用户并保存密钥:
ssh myusername@chefserver sudo chef-server-ctl user-create myuser myName mySurname myname@blah.com XXXXXX > ~/.chef/myuser.pem
创建一个名为“demo”的组织,将“myuser”添加为管理员并保存验证者密钥:
ssh myusername@chefserver sudo chef-server-ctl org-create demo "Demo organisation" -a myuser > ~/.chef/demo-validator.pem
并生成刀配置文件:
knife configure --server-url https://chefserver/organizations/demo \
--validation-client-name demo-validator \
--validation-key ~/.chef/demo-validator.pem \
--user myuser \
--key ~/.chef/myuser.pem
最后,Chef 12尊重SSL证书。以下命令创建信任关系:
knife ssl fetch
或者,您可以禁用SSL证书验证:
echo "ssl_verify_mode :verify_none" >> ~/.chef/knife.rb