<div dir="ltr"><div>Hello list,</div><div><br></div><div>I've been lurking for quite a few years now, but I have a ruby language question that most of you could probably solve in your sleep.</div><div><br></div><div>I'd like my vagrantfile to include a loop, into which I can pass variables from a "hash of hashes"(?)</div><div><br></div><div><a href="https://github.com/devopsgroup-io/vagrant-digitalocean/blob/master/README.md">Here</a> is the documentation for the vagrant plugin<br></div><div><br></div><div>Here is my code (the important parts anyway).</div><div><br></div><div><<<<<<<<<<<<<<<<<br>Vagrant.configure('2') do |config|<br><br> cluster = {<br> 0 => { <br> 'name' => 'backups', <br> 'image' => 'ubuntu-16-04-x64' <br> },<br> 1 => {<br> 'name' => 'client1',<br> 'image' => 'debian-9-x64'<br> },<br> 2 => {<br> 'name' => 'client2',<br> 'image' => 'debian-8-x64'<br> },<br> 3 => {<br> 'name' => 'client3',<br> 'image' => 'ubuntu-16-04-x64'<br> }<br> } <br></div><div><br></div><div> cluster.each do |i, machine|<br> config.vm.define "#{machine['name']}" do |machine_id|<br> machine_id.ssh.private_key_<wbr>path = '~/.ssh/id_rsa.digitalocean'<br> machine_id.vm.box = 'digital_ocean'<br><br><br> machine_id.vm.provider :digital_ocean do |provider, override|<br> override.vm.box_url = "<a href="https://github.com/devopsgroup-io/vagrant-digitalocean/raw/master/box/digital_ocean.box" target="_blank">https://github.com/<wbr>devopsgroup-io/vagrant-<wbr>digitalocean/raw/master/box/<wbr>digital_ocean.box</a>"<br> provider.token = `echo $DO_API_TOKEN`<br> provider.region = 'lon1'<br> provider.size = 's-1vcpu-1gb'<br> provider.image = "#{machine_id['image']}"<br> end<br> end<br> end<br>end</div><div>>>>>>>>>>>>>>>>></div><div><br></div><div>I'm trying to loop through "cluster" and pull out the "name" and "image" values, but with this code I just end up with</div><div><br></div><div>Vagrant:<br>* Unknown configuration section '[]'.<br><br></div><div>..which looks like it's hitting a syntax error somewhere.</div><div><br></div><div>Would anyone be able to point me in the right direction with this? It's been driving me "loopy" for a while now :)</div><div><br></div><div>Thanks in advance<br></div><div>-- <br><div class="gmail-m_-2933665596942985386gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">---<br><br>Jerry Steele<br>Telephone: +44 (0)<span>7492 910225</span><br><a href="http://www.ticktockhouse.co.uk" target="_blank">http://www.ticktockhouse.co.uk</a><br></div><div>GPG: 43A3A8C6</div><div dir="ltr"><br></div></div></div></div></div></div></div></div>
</div></div>