Great information Alvaro! Thanks a lot. I assumed I couldn't use the time function in the machine name as it would mean it would have a different name when I next tried to do a vagrant halt but indeed your suggestion works perfectly and certainly meets my needs. Minor update for anyone else reading this; when specifying a group name it seemed to me that I needed to precede the group name with a '/', ie
vb.customize ["modifyvm", :id, "--groups", "/vagrant"] Thanks a bundle! On Jul 28, 2014 3:53 PM, "Alvaro Miranda Aguilera" <[email protected]> wrote: > ok, 3 replies for you: > > The one I would do: > > create a group. > > inside the virtualbox block, add this: > > vm_name = $version > memory = 2048 > core = 2 > group = "unique_name" > > config.vm.provider :virtualbox do |vb| > vb.name = vm_name + "." + Time.now.strftime("%y%m%d%H%M") > vb.customize ["modifyvm", :id, "--memory", memory] > vb.customize ["modifyvm", :id, "--cpus", core] > vb.customize ["modifyvm", :id, "--groups", group] > end > > This will create a group inside the virtualbox gui, and you will be able > to identity the VM. > > > > The one you did ask: > Vagrantfile is in ruby, plus you can read and write to the OS so you can > potentially do something like this > > create a file, put inside the timestamp > > then you can read that file and reuse the timestamp and add the version > you want > > that is IF you want to the same exact name to persist accross reboots. > > The one i will suggest related to what you ask: > if you don't need the same to persist across reboots (the same random > part) and can change, then you can go for something more simple, like: > > vm_name = $version > > vb.name = vm_name + "." + Time.now.strftime("%y%m%d%H%M") > > > > > > Alvaro. > > > > > > > On Tue, Jul 29, 2014 at 4:55 AM, POFlynn <[email protected]> wrote: > >> Got my Vagrant freak on and I'm loving it but now I want more.... So the >> team is building boxes locally using VirtualBox as a provider using >> chef/vagrant source from a Git repo, yaay. But they want to be able to >> build multiple boxes on their laptops. I initially told them to simply >> re-clone the repo into a different directory and vagrant up from there and >> that worked as the VB provider will put a timestamp in the machine name and >> thus each machine from each directory will have a unique name in >> VirtualBox. But then the team wanted the version of our s/w in the name (as >> they build machines from many sources and wanted to know which was which in >> the VirtualBox GUI) so I added a "vb.name = $version" type entry which >> gives a nice name with a version number but also drops the timestamp and >> thus prevents them from building the same versioned machine in another >> directory as that machine will have the same name. So I added a nicety but >> broke what is to them, a feature. >> >> So I guess really I'd like to be able to specify a machine name using the >> version of our s/w but the remainder of the machine name is random in some >> fashion (and persists across reboots). Am I asking too much? >> >> Thanks. >> >> -- >> 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]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Vagrant" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/vagrant-up/Dgq8xLS1DXs/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- 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]. For more options, visit https://groups.google.com/d/optout.
