Chef EC2 EBS 卷使用 AWS Cookbook InvalidInstanceIDNotFound

Chef EC2 EBS Volume Using AWS Cookbook InvalidInstanceIDNotFound

我正在使用 Chef provided AWS cookbook (v2.7.2) 在初始 bootstrap 期间在 Ubuntu 服务器 14.04.02 LTS HVM ec2 实例上创建和附加 EBS 卷ped 主厨客户 运行。我正在托管我自己的厨师服务器 (12.1.0-1_amd64)。使用 knife-ec2,我通过以下命令创建 aws 实例和 bootstrap 运行list:

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' 是 knife-ec2 创建的实例的 ID,chef-client 正在执行,所以它确实存在。此外,我验证了我在与实例相同的可用区中创建卷。

我读过一些关于 AWS's Eventual Consistency 的帖子,但不知道如何在 bootstrap 主厨客户 运行 期间处理这个问题,因为食谱 运行s 在创建实例后立即开始。

有没有办法在 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

这是堆栈跟踪:

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'

这个问题是我自己的蠢事。

数据包中的 AWS 凭证用于旧的停用 AWS 账户,但用于创建带刀实例的 AWS 凭证用于当前 AWS 账户。

一旦他们将正确的密钥放入数据包中,卷就成功创建并附加了!

希望这对以后的人有帮助...