我在初始引导的Chef-client运行期间使用Chef provided AWS cookbook(v2.7.2)在Ubuntu Server 14.04.02 LTS HVM ec2实例上创建和附加EBS卷。我托管自己的厨师服务器(12.1.0-1_amd64)。使用knife-ec2,我创建了aws实例并通过以下命令引导运行列表:
knife ec2 server create --region us-east-1 --availability-zone us-east-1a --node-name my-server --run-list "role[my-role]" --image ami-d05e75b8 --flavor c3.large --ebs-size 16 --ebs-volume-type gp2 --subnet subnet-mySubnetId --associate-public-ip --server-connect-attribute public_ip_address --ssh-user ubuntu --ssh-key my-pem --identity-file /path/to/my-pem.pem -y
但是,当创建和附加卷的配方执行时,卷成功创建,但无法附加到我的实例。发生以下错误:
Aws::EC2::Errors::InvalidInstanceIDNotFound: The instance ID 'i-36a93b84' does not exist
以下代码在我的食谱中(取自食谱页面上的示例):
include_recipe 'aws'
aws_ebs_volume "backup_volume" do
aws_access_key aws['aws_access_key_id']
aws_secret_access_key aws['aws_secret_access_key']
size 16
device "/dev/sdi"
availability_zone "us-east-1a"
action [ :create, :attach ]
end
我验证了' i-36a93b84'是实例刀-ec2创建的并且chef-client正在执行的id,因此它确实存在。此外,我验证了我在与实例相同的可用区域中创建卷。
我已经阅读了一些关于AWS's Eventual Consistency的帖子,但不知道如何在引导式厨师 - 客户端运行期间处理这个问题,因为配方在创建实例后立即运行。
有没有办法在knife-ec2创建aws服务器的时候创建一个额外的挂载,或者我是否尝试以非正统的方式附加卷?
配方中的Chef客户端输出:
Recipe: my-cookbook::backupvolume * aws_ebs_volume[backup_volume] action create[2015-07-17T11:57:05+00:00] INFO: Processing aws_ebs_volume[backup_volume] action create (my-cookbook::backupvolume line 49) [2015-07-17T11:57:05+00:00] DEBUG: Providers for generic aws_ebs_volume resource enabled on node include: [LWRP provider aws_ebs_volume from cookbook aws] [2015-07-17T11:57:05+00:00] DEBUG: Provider for action create on resource aws_ebs_volume[backup_volume] is LWRP provider aws_ebs_volume from cookbook aws [2015-07-17T11:57:05+00:00] DEBUG: Instance ID is i-36a93b84 [2015-07-17T11:57:05+00:00] DEBUG: Instance's availability zone is us-east-1a [2015-07-17T11:57:05+00:00] DEBUG: Created new volume vol-4842ecc4 [2015-07-17T11:57:05+00:00] DEBUG: Volume is creating [2015-07-17T11:57:08+00:00] INFO: Volume vol-4842ecc4 is available - create a volume with id= size=16 availability_zone=us-east-1a and update the node data with created volume's id * aws_ebs_volume[backup_volume] action attach[2015-07-17T11:57:08+00:00] INFO: Processing aws_ebs_volume[backup_volume] action attach (my-cookbook::backupvolume line 49) [2015-07-17T11:57:08+00:00] DEBUG: Providers for generic aws_ebs_volume resource enabled on node include: [LWRP provider aws_ebs_volume from cookbook aws] [2015-07-17T11:57:08+00:00] DEBUG: Provider for action attach on resource aws_ebs_volume[backup_volume] is LWRP provider aws_ebs_volume from cookbook aws [2015-07-17T11:57:08+00:00] DEBUG: Attaching vol-4842ecc4 as /dev/sdi ================================================================================ Error executing action `attach` on resource 'aws_ebs_volume[backup_volume]' ================================================================================ Aws::EC2::Errors::InvalidInstanceIDNotFound ------------------------------------------- The instance ID 'i-36a93b84' does not exist Cookbook Trace: --------------- /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:212:in `attach_volume' /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:70:in `block (2 levels) in class_from_file' /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:68:in `block in class_from_file' Resource Declaration: --------------------- # In /var/chef/cache/cookbooks/my-cookbook/recipes/backupvolume.rb 49: aws_ebs_volume "backup_volume" do 50: aws_access_key aws['aws_access_key_id'] 51: aws_secret_access_key aws['aws_secret_access_key'] 52: size 16 53: device "/dev/sdi" 54: description "TEST BACKUP" 55: availability_zone "us-east-1a" 56: action [ :create, :attach ] 57: end 58: Compiled Resource: ------------------ # Declared in /var/chef/cache/cookbooks/my-cookbook/recipes/backupvolume.rb:49:in `from_file' aws_ebs_volume("backup_volume") do action [:create, :attach] updated true retries 0 retry_delay 2 default_guard_interpreter :default declared_type :aws_ebs_volume cookbook_name "my-cookbook" recipe_name "backupvolume" aws_access_key "********" aws_secret_access_key "********" size 16 device "/dev/sdi" description "TEST BACKUP" availability_zone "us-east-1a" timeout 180 volume_type "standard" piops 0 end
这是stacktrace:
Aws::EC2::Errors::InvalidInstanceIDNotFound: aws_ebs_volume[backup_volume] (my-cookbook::backupvolume line 49) had an error: Aws::EC2::Errors::InvalidInstanceIDNotFound: The instance ID 'i-36a93b84' does not exist /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/seahorse/client/plugins/param_conversion.rb:22:in `call' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/aws-sdk-core/plugins/response_paging.rb:10:in `call' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/seahorse/client/plugins/response_target.rb:18:in `call' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/seahorse/client/request.rb:70:in `send_request' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/seahorse/client/base.rb:216:in `block (2 levels) in define_operation_methods' /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:212:in `attach_volume' /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:70:in `block (2 levels) in class_from_file' /opt/chef/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `call' /opt/chef/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `add_action' /opt/chef/embedded/apps/chef/lib/chef/provider.rb:175:in `converge_by' /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:68:in `block in class_from_file'
答案 0 :(得分:0)
问题是由于我自己的愚蠢。
数据库中的AWS凭据是针对旧的decomissioned AWS账户,但用于创建w / knife实例的AWS凭证是针对当前AWS账户的。
一旦他们将正确的密钥放入数据库中,就会成功创建并附加卷!
希望这有助于将来......