1

これまでのところ、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)

-- HumayunM の提案どおり、 --ss-key オプションを試してみましたが、うまくいかないようです。

指示:

PS C:\Users\hp\chef-repo> knife ec2 server create -I ami-0970010f37c4f9c8d -f t2.micro --region ap-southeast-2 -S Test2AWS.pem -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:
ERROR: The key pair 'Test2AWS.pem' does not exist
DEBUG: C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.94.1/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.94.1/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:20:in `call'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.94.1/lib/aws-sdk-core/plugins/idempotency_token.rb:17:in `call'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.94.1/lib/aws-sdk-core/plugins/param_converter.rb:24:in `call'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.94.1/lib/aws-sdk-core/plugins/response_paging.rb:10:in `call'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.94.1/lib/seahorse/client/plugins/response_target.rb:23:in `call'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.94.1/lib/seahorse/client/request.rb:70:in `send_request'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/aws-sdk-ec2-1.156.0/lib/aws-sdk-ec2/client.rb:35503:in `run_instances'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/knife-ec2-1.0.36/lib/chef/knife/ec2_server_create.rb:995:in `create_ec2_instance'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/knife-ec2-1.0.36/lib/chef/knife/ec2_server_create.rb:321:in `plugin_create_instance!'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/lib/chef/knife/bootstrap.rb:571:in `run'
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'
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'
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'
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'
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'
C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.10.12-universal-mingw32/bin/knife:24:in `<top (required)>'
C:/opscode/chef-workstation/bin/knife:383:in `load'
C:/opscode/chef-workstation/bin/knife:383:in `<main>'

そしてファイルも存在します:

PS C:\Users\hp\chef-repo> ls .\Test2AWS.pem


    Directory: C:\Users\hp\chef-repo


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        21-May-20   6:43 PM           1692 Test2AWS.pem

反復 3: コマンドを使用

指示:

PS>knife ec2 server create  -r 'role[webserver]' -I ami-0970010f37c4f9c8d -f t2.micro --region ap-southeast-2 -S Test2AWS -i Test2AWS.pem --connection-user ec2-user -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:

Waiting for EC2 to create the instance
Instance ID: i-05d0c4bda0435e609
Flavor: t2.micro
Image: ami-0970010f37c4f9c8d
Region: ap-southeast-2
Availability Zone: ap-southeast-2b
AWS Tags: Name: i-05d0c4bda0435e609
SSH Key: Test2AWS
T2/T3 Unlimited: Disabled

Public DNS Name: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
Public IP Address: 13.211.81.106
Private DNS Name: ip-172-31-12-62.ap-southeast-2.compute.internal
Private IP Address: 172.31.12.62

Waiting for sshd access to become available
SSH Target Address: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com(public_dns_name)
DEBUG: No ssh gateway found, making a direct connection
DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com
.DEBUG: ssh timed out: ec2-13-211-81-106.ap-southeast-2.compute.amazonaws.com

注:私には何の役割もありません。コマンド ラインで 1 つのコマンドを使用しているだけです。私はシェフにとても慣れていません。

問題は何ですか?また、コマンドラインの代わりに、Ansible のように yaml ファイルを使用できますか?

4

1 に答える 1