0

尝试设置厨师工作站

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>'
4

1 回答 1

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

更新:厨师服务器 12

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
于 2014-02-11T20:28:58.173 回答