Well, I ended up coming up with a pretty simple workaround. In the
Vagrantfile that I package with my MySQL box, I added the following:
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
vb.name = "mysql_shared"
end
This will force the name to get set to *mysql_shared*. Assuming that no
machines are up and running, when I launch a multi-machine setup in one
project, the web and database machines will fire up. If I launch a
multi-machine in a second project, Vagrant will complain that a machine
with the name *mysql_shared* already exists. This will be an *indicator *for
me to manually start the web machine for that project (i.e. *vagrant up web*).
With this setup, I can share a single database machine instead of having
multiple running. This will help reduce the number of resources used by my
host. I hope others will find this tip useful.
-Ryan
On Friday, February 6, 2015 at 9:13:34 AM UTC-8, Ryan Flores wrote:
>
> I'm guessing that the answer to this is no. However, I thought I'd ask.
>
> I have two different projects, each with their own Vagrantfile. Both
> projects are setup using a Multi-Machine setup: one machine is for a
> dedicated MySQL server, and the other is for a Web app. I was hoping to
> have both projects share the MySQL machine to save on resources. In both
> Vagrantfiles, I have the following three lines:
>
> config.vm.define "mysql" do |mysql|
> mysql.vm.box = "toople/ubuntu-12.04-x64-mysql"
> end
>
> For my MySQL box, it comes packaged with its own Vagrantfile, which
> contains the following:
>
> Vagrant::Config.run do |config|
> # This Vagrantfile is auto-generated by `vagrant package` to contain
> # the MAC address of the box. Custom configuration should be placed in
> # the actual `Vagrantfile` in this box.
> config.vm.base_mac = "0800272A4B9E"
> end
>
>
> # Load include vagrant file if it exists after the auto-generated
> # so it can override any of the settings
> include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__
> )
> load include_vagrantfile if File.exist?(include_vagrantfile)
>
> which in turn makes a call to *include/_Vagrantfile*, which contains:
>
> Vagrant.configure("2") do |config|
> config.ssh.username = "toople"
> config.ssh.private_key_path = File.expand_path("../vagrant_rsa",
> __FILE__)
>
> config.vm.host_name = "toople-mysql"
> config.vm.network "private_network", ip: "192.168.56.150"
> config.vm.network "forwarded_port", guest: 22, host: 2250
>
> config.vm.synced_folder ".", "/vagrant", disabled: true
>
> config.vm.provider "virtualbox" do |vb|
> vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
> end
> end
>
>
> When I run *vagrant up* for both projects, I notice two things happening
> after trying to launch the machines for the second project:
>
>
> - A separate MySQL machine gets instantiated (which I can see when I
> open the VirtualBox Manager)
> - The second MySQL machine fails to run, due to a port conflict, which
> I already know why
>
> For the second point, the conflict could have been prevented if a separate
> MySQL instance simply wasn't created. The names of the instances are:
>
>
> - toopleorg_mysql_1423179272232_38130, and
> - enviromerica-portal_mysql_1421359987097_44764
>
> Is there a config setting to tell Vagrant to only create one MySQL
> machine? My guess is no, but like to know what others have done to get
> around this problem, if any.
>
> Thanks in advance,
> Ryan
>
--
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.