I'm trying to bring up some DO boxes in vagrant
# vim: ft=ruby
Vagrant.configure('2') do |config|
cluster = {
0 => {
'name' => 'backups',
'image' => 'ubuntu-16-04-x64'
},
1 => {
'name' => 'client1',
'image' => 'debian-9-x64'
},
2 => {
'name' => 'client2',
'image' => 'debian-8-x64'
},
3 => {
'name' => 'client3',
'image' => 'ubuntu-16-04-x64'
}
}
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook/site.yml"
ansible.host_vars = {
}
end
cluster.each do |i, machine|
config.vm.define "#{machine['name']}" do |machine_id|
machine_id.ssh.private_key_path = '~/.ssh/id_rsa.digitalocean'
machine_id.vm.box = 'digital_ocean'
machine_id.vm.hostname = "#{machine_id['name']}"
machine_id.image = "#{machine_id['image']}"
machine_id.vm.provider :digital_ocean do |provider, override|
override.vm.box_url =
"https://github.com/devopsgroup-io/vagrant-digitalocean/raw/master/box/digital_ocean.box"
provider.token = `echo $DO_API_TOKEN`
provider.region = 'lon1'
provider.size = 's-1vcpu-1gb'
end
end
end
end
As you can see, the variables will be the hostname and the image used for
each box. I found something like the obvoe online and have tried to adapt
it, but I've had massive problems. I'm still a bit new to Ruby, and am
having some problems with the syntax. At this point, I get errors like:
vm:
* The hostname set for the VM should only contain letters, numbers,
hyphens or dots. It cannot start with a hyphen or dot.
Vagrant:
* Unknown configuration section '[]'.
* Unknown configuration section 'image='.
Obviously the interpolation is not working. Any idea where to start with
this? I think I just need a bit of extra knowledge to work out where I'm
going wrong with both Vagrant and loops in Ruby.
Thanks
Jerry
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vagrant-up/41cb870c-179f-4dd8-bf1f-14090a410f57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.