测试厨房 (chefdk)、Vagrant 和 Amazon VPC

Test Kitchen (chefdk), Vagrant and Amazon VPC

我正在尝试让 KitchenCI 在我的 Amazon VPC 中构建测试实例。我有这个工作,但是当 Vagrant 尝试连接到 ec2 实例时,它使用实例的外部 (public) IP 而不是它的内部 (VPC) IP。有什么办法可以在 Vagrant 中改变这个吗?

.kitchen.yml:

---
provisioner:
   name: chef_solo

platforms:
  - name: centos-6.5
    driver:
      name: vagrant
  - name: amazon
    driver:
      name: ec2
      image_id: ami-ed8e9284
      flavor_id: t2.medium
      aws_ssh_key_id: DevOps
      ssh_key: /Users/djimenez/.ssh/devops_rsa.pub
      availability_zone: us-east-1a
      subnet_id: subnet-1903a976
      require_chef_omnibus: true
      iam_profile_name: atc
      ebs_delete_on_termination: true
      security_group_ids: sg-7461ae1b

suites:
 <snip>

看来我需要将以下内容添加到我的 .kitchen.yml:

driver:
  name: ec2
  interface: private

docs 说:

interface

The place from which to derive the hostname for communicating with the instance. May be dns, public or private. If this is unset, the driver will derive the hostname by failing back in the following order:

  1. DNS Name
  2. Public IP Address
  3. Private IP Address

The default is unset.