2014-06-24 2 views
4

AWC (vagrant-aws 플러그인 사용)에서 여러 EC2 인스턴스가있는 환경을 프로비저닝하고 Vgrant에서 읽기 위해 JSON 구성 파일을 사용하려고합니다.Vagrant를 사용하는 여러 EC2 인스턴스

macp-3:vagrant-aws sans$ cat scripts/aws.json 
{ 
    "env": "dops", 
    "access_key": "XXXXXXXXXXXXXXXX", 
    "secret_key": "hfgy5ejfkprg2432432beqo2r", 
    "region": "eu-west-1", 
    "availability_zone": "a", 
    "subnet_id": "subnet-0b766860", 
    "security_groups": [ 
     "sg-53t48c34", 
     "sg-11668f7e", 
     "sg-4a6c8525", 
     "sg-75168c1e" 
    ], 
    "ssh_username": "ubuntu", 
    "keypair": "Xdops_testKey", 
    "ssh_private_key": "/Users/sans/.ssh/id_rsa", 
    "ec2s": { 
     "dops-agg-001": { 
      "ami_id": "ami-838675f7", 
      "instance_type": "m3.medium", 
      "elastic_ip": "ture", 
      "tags": { 
       "Name": "dops-agg-001", 
       "Role": "sql-aggr", 
       "ServiceType": "database", 
       "NopeType": "mem_master", 
       "CostCentre": "QA" 
      } 
     }, 
     "dops-nag-001": { 
      "ami_id": "ami-838675f7", 
      "instance_type": "m3.medium", 
      "elastic_ip": "ture", 
      "tags": { 
       "Name": "dops-nag-001", 
       "Role": "monitoring", 
       "ServiceType": "controller", 
       "NopeType": "nagios", 
       "CostCentre": "QA" 
      } 
     } 
    } 
} 

이 내가 가지고 올 한 Vagrantfile입니다 : : 아래는 JSON 파일입니다

# -*- mode: ruby -*- 
# vi: set ft=ruby : 

aws_cfg = (JSON.parse(File.read("scripts/aws.json"))) 

Vagrant.configure("2") do |config| 

    config.vm.box = "dummy" 
    config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box" 

    aws_cfg['ec2s'].each do |node| 
     node_name = node[0] 
     node_value = node[1] 

     # Node specific configuration 
     config.vm.define node_name do |config2| 
      ec2_tags = node_value['tags'] 

      # Spining up EC2 instances 
      config2.vm.provider :aws do |ec2, override| 
       ec2.access_key_id = aws_cfg['access_key'] 
       ec2.secret_access_key = aws_cfg['secret_key'] 
       ec2.keypair_name = aws_cfg['keypair'] 
       ec2.region = aws_cfg['region'] 
       ec2.availability_zone = aws_cfg['region']+aws_cfg['availability_zone'] 
       ec2.subnet_id = aws_cfg['subnet_id'] 
       ec2.security_groups = aws_cfg['security_groups'] 
       # 
       ec2.ami = node_value['ami_id'] 
       ec2.instance_type = node_value['instance_type'] 
       ec2.elastic_ip = node_value['elastic_ip'] 
       # 
       ec2.tags = { 
        'Name'   => ec2_tags['Name'], 
        'Role'   => ec2_tags['Role'], 
        'ServiceType' => ec2_tags['ServiceType'], 
        'NopeType'  => ec2_tags['NopeType'], 
        'CostCentre' => ec2_tags['CostCentre'] 
       } 
       # 
       override.ssh.username = "ubuntu" 
       override.ssh.private_key_path = "/Users/sans/.ssh/id_rsa" 
      end 

      # Final Puppet provisioning 
      #config2.vm.provision :puppet do |ppt| 
      # ppt.options = "--verbose --debug" 
      # ppt.manifests_path = "puppet/manifests" 
      # ppt.manifest_file = "nodes.pp" 
      # ppt.module_path = "puppet/modules" 
      #end 
     end 
    end 
end 

그것은 대신에, 괜찮 작업하지만, 병렬 상자를 회전하려고 한 별 -one :

macp-3:vagrant-aws sans$ vagrant up --provider=aws 
Bringing machine 'dops-agg-001' up with 'aws' provider... 
Bringing machine 'dops-mon-001' up with 'aws' provider... 
[fog][WARNING] Unable to load the 'unf' gem. Your AWS strings may not be properly encoded. 
==> dops-mon-001: HandleBoxUrl middleware is deprecated. Use HandleBox instead. 
==> dops-mon-001: This is a bug with the provider. Please contact the creator 
==> dops-agg-001: HandleBoxUrl middleware is deprecated. Use HandleBox instead. 
==> dops-mon-001: of the provider you use to fix this. 
.... 
.... 

나는 Vagrantfile에서 반복적으로 문제가 있다고 생각합니까? 아무도 나에게 무슨 단서가 나올지 말해 줄 수 있니? 베스트!

답변

1

이 질문은 answered in a Google Group입니다.

솔루션 :

--[no-]parallel - 프로 바이더가 지원하는 경우 병렬로 여러 컴퓨터를 가져와.