LoginSignup
5
5

More than 5 years have passed since last update.

vagrantでサイズの異なるdigital_oceanのホストを複数生成する

Posted at

vagrantでdigital_oceanを使ってサイズの異なる複数のホストを生成する例

以下のとおり

Vagrantfile
Vagrant.configure('2') do |config|

  config.vm.provider :digital_ocean do |provider, override|
    override.ssh.private_key_path = '~/.ssh/id_rsa'
    override.vm.box               = 'digital_ocean'
    override.vm.box_url           = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"
    provider.private_networking   = true
    provider.client_id            = 'abc'
    provider.api_key              = 'xyz'
    provider.image                = 'CentOS 6.5 x64'
    provider.region               = 'Singapore 1'
    provider.ca_path              = '/path/to/ca'
    provider.ssh_key_name         = 'keyname'
  end

  hosts=[]
  (1..3).each {|x| hosts.push({"name"=>"cass#{x}", "size"=>"4GB"}) }
  (1..1).each {|x| hosts.push({"name"=>"spv#{x}" , "size"=>"2GB"}) }
  (1..2).each {|x| hosts.push({"name"=>"node#{x}", "size"=>"2GB"}) }

  hosts.each do |host|
    config.vm.define host["name"] do |server|
      config.vm.hostname          = host["name"]
      config.vm.provider :digital_ocean do |provider|
        provider.size = host["size"]
      end
    end
  end

end
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5