Chef 工作站无法找到 knife.rb,除非在 "chef-repo" 中
Chef workstation is unable to find knife.rb unless in "chef-repo"
当我运行knife node list
而在/home/ec2-user
它抱怨
"WARNING: No knife configuration file found
ERROR: Your private key could not be loaded from /etc/chef/client.pem
Check your configuration file and ensure that your private key is readable"
当我运行knife node list
而在/home/ec2-user/chef-repo
它执行成功
chef-repo
目录包含 .chef/knife.rb
我的 knife.rb
位于 /home/ec2-user/chef-repo/.chef/knife.rb
我的knife.rb
内容:
log_level :info
log_location STDOUT
node_name 'admin'
client_key '/home/ec2-user/chef-repo/.chef/admin.pem'
validation_client_name 'chef-validator'
validation_key '/home/ec2-user/chef-repo/.chef/chef-validator.pem'
chef_server_url 'https://XX.XX.XX.XX:443'
syntax_check_cache_path '/home/ec2-user/chef-repo/.chef/syntax_check_cache'
cookbook_path [ '~/chef-repo/cookbooks/cookbooks' ]
如果您想要 "global per-user" 配置,请将 KNIFE_HOME 环境变量设置为您的 .chef
目录,或者将 copy/symlink 您的 knife.rb 设置为
/home/ec2-user/.chef/knife.rb
规格:
https://github.com/chef/chef/blob/master/spec/unit/workstation_config_loader_spec.rb#L51
实施:https://github.com/chef/chef/blob/master/lib/chef/workstation_config_loader.rb#L97-L124
当我运行
knife node list
而在/home/ec2-user
它抱怨"WARNING: No knife configuration file found
ERROR: Your private key could not be loaded from /etc/chef/client.pem Check your configuration file and ensure that your private key is readable"当我运行
knife node list
而在/home/ec2-user/chef-repo
它执行成功
chef-repo
目录包含.chef/knife.rb
我的 knife.rb
位于 /home/ec2-user/chef-repo/.chef/knife.rb
我的knife.rb
内容:
log_level :info
log_location STDOUT
node_name 'admin'
client_key '/home/ec2-user/chef-repo/.chef/admin.pem'
validation_client_name 'chef-validator'
validation_key '/home/ec2-user/chef-repo/.chef/chef-validator.pem'
chef_server_url 'https://XX.XX.XX.XX:443'
syntax_check_cache_path '/home/ec2-user/chef-repo/.chef/syntax_check_cache'
cookbook_path [ '~/chef-repo/cookbooks/cookbooks' ]
如果您想要 "global per-user" 配置,请将 KNIFE_HOME 环境变量设置为您的 .chef
目录,或者将 copy/symlink 您的 knife.rb 设置为
/home/ec2-user/.chef/knife.rb
规格: https://github.com/chef/chef/blob/master/spec/unit/workstation_config_loader_spec.rb#L51
实施:https://github.com/chef/chef/blob/master/lib/chef/workstation_config_loader.rb#L97-L124