I think it should be machine[‘image’] instead of machine_id[‘image’]<br><div class="gmail_quote"><div dir="ltr">On Thu, 1 Feb 2018 at 00:00, Jerry Steele <<a href="mailto:ticktockhouse@gmail.com">ticktockhouse@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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" target="_blank">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_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/devopsgroup-io/vagrant-digitalocean/raw/master/box/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="m_1502060909177533922gmail-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>
_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/pipermail/chat-lrug.org</a><br>
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/options.cgi/chat-lrug.org</a><br>
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
</blockquote></div>