到目前为止,我已经成功安装了Chef-server,chef-manage(UI位),并且使knife ssl check
正常工作。
现在,我正在运行以下命令
knife ec2 server create -r 'role[webserver]' -I ami-0970010f37c4f9c8d -f t2.micro --region ap-southeast-2
我已将我的访问密钥和秘密密钥保存在knife.rb文件中,如下所示:
# See https://docs.getchef.com/config_rb_knife.html for more information on knife configuration options
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "tuser"
client_key "#{current_dir}/tuser.pem"
chef_server_url "https://3.227.234.41/organizations/testdemo"
cookbook_path ["#{current_dir}/../cookbooks"]
knife[:aws_access_key_id] = "XXXXXXXXXXXXXX"
knife[:aws_secret_access_key] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
不幸的是,我收到以下错误:
INFO: Using configuration from C:/Users/hp/.chef/knife.rb
DEBUG: Checking if we need to accept Chef license to bootstrap node
DEBUG: Reading products and relationships...
DEBUG: Successfully read products and relationships
DEBUG: License acceptance required for chef version: 15
DEBUG: Searching for the following licenses: ["infra-client", "inspec"]
DEBUG: Found license chef_infra_client at C:/Users/hp/.chef/accepted_licenses/chef_infra_client
DEBUG: Found license inspec at C:/Users/hp/.chef/accepted_licenses/inspec
DEBUG: Missing licenses remaining: []
DEBUG: All licenses present
DEBUG: Using AWS region ap-southeast-2
DEBUG: Setting up AWS connection using aws_access_key_id: AKIAXXXXXXXXXXXXXXXX aws_secret_access_key: cW0YXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX aws_session_token:
Traceback (most recent call last):
10: from C:/opscode/chef-workstation/bin/knife:383:in `<main>'
9: from C:/opscode/chef-workstation/bin/knife:383:in `load'
8: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/bin/knife:24:in `<top (required)>'
7: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/application/knife.rb:163:in `run'
6: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/knife.rb:229:in `run'
5: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/knife.rb:485:in `run_with_pretty_exceptions'
4: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/local_mode.rb:42:in `with_server_connectivity'
3: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/knife.rb:486:in `block in run_with_pretty_exceptions'
2: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/knife/bootstrap.rb:566:in `run'
1: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/knife-ec2-1.0.36/lib/chef/knife/ec2_server_create.rb:594:in `plugin_validate_options!'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/knife-ec2-1.0.36/lib/chef/knife/ec2_server_create.rb:1185:in `create_key_pair': undefined method `delete' for nil:NilClass (NoMethodError)
以下命令也会产生错误
PS C:\Users\hp\chef-repo> knife ec2 server create -I ami-0970010f37c4f9c8d -f t2.micro --region ap-southeast-2 -VVV
错误输出:
INFO: Using configuration from C:/Users/hp/.chef/knife.rb
DEBUG: Checking if we need to accept Chef license to bootstrap node
DEBUG: Reading products and relationships...
DEBUG: Successfully read products and relationships
DEBUG: License acceptance required for chef version: 15
DEBUG: Searching for the following licenses: ["infra-client", "inspec"]
DEBUG: Found license chef_infra_client at C:/Users/hp/.chef/accepted_licenses/chef_infra_client
DEBUG: Found license inspec at C:/Users/hp/.chef/accepted_licenses/inspec
DEBUG: Missing licenses remaining: []
DEBUG: All licenses present
DEBUG: Using AWS region ap-southeast-2
DEBUG: Setting up AWS connection using aws_access_key_id: AKIAXXXXXXXXXXXXXXXX aws_secret_access_key: cW0YXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX aws_session_token:
Traceback (most recent call last):
10: from C:/opscode/chef-workstation/bin/knife:383:in `<main>'
9: from C:/opscode/chef-workstation/bin/knife:383:in `load'
8: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/bin/knife:24:in `<top (required)>'
7: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/application/knife.rb:163:in `run'
6: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/knife.rb:229:in `run'
5: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/knife.rb:485:in `run_with_pretty_exceptions'
4: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/local_mode.rb:42:in `with_server_connectivity'
3: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/knife.rb:486:in `block in run_with_pretty_exceptions'
2: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/knife/bootstrap.rb:566:in `run'
1: from C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/knife-ec2-1.0.36/lib/chef/knife/ec2_server_create.rb:594:in `plugin_validate_options!'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/knife-ec2-1.0.36/lib/chef/knife/ec2_server_create.rb:1185:in `create_key_pair': undefined method `delete' for nil:NilClass (NoMethodError)
任何想法是什么问题?另外,我们可以像Ansible一样使用yaml文件代替命令行吗?
错误在这里报告:
ec2_server_create.rb:1185:在`create_key_pair'中:
您还应该指定一个密钥对,以SSH进入EC2