-1

Can we use vagrant to provision multiple services in a single virtual machine , say tomcat and mysql. but a service should get installed in VM as per user input something like "vagrant up mysql".

I have already been looked in to Mutiple VM deployment using vagrant but here what i want is to have services in same VM based on user input. Is there a way to do that?

Thanks!!

priyank
  • 857
  • 2
  • 18
  • 35
  • The first argument of vagrant up is the machine name.. What is the target of your command? – GianArb Apr 15 '15 at 13:54
  • @yash, Is possible you use in same Vagrantfile, but in differents machines. – acfreitas Apr 15 '15 at 18:02
  • @GianArb : I just gave the example like we use machine name while doing vagrant up , in the same way or in other way can we do this for services installed in same machine , may be something like setting up variables in vagrantfile and then passing the variable in vagrant up.would be very helpful if u can give pointers on this. thanks in advance.. – priyank Apr 16 '15 at 04:29
  • I don't understand the use case but in my opinion you can try to install all service in your VM and you can start/stop them with vagrant ssh -c "sudo service mysql stop" – GianArb Apr 16 '15 at 07:44
  • Hi GianArb , sorry if my question is not clear. Let me try to rephrase the usecase here: I want to install services say mysql and tomcat in a single VM. Both services will get start doing "vagrant up" but what if I need to start only mysql not tomcat vice versa. Is there a way I can give user input when starting the vagrant machine, so that it only installs one service based on user input. really appreciate any help on this.. – priyank Apr 16 '15 at 08:32

1 Answers1

0

Since all those machines are virtual and you sometimes want to have only mysql there, sometimes only tomcat and sometimes both, just use multi-machine:

http://docs.vagrantup.com/v2/multi-machine/

Then you will be able to start your machine, for example, like this:

vagrant up mysql
vagrant up tomcat
vagrant up both

You can configure them to have the same IP and never start all of them at once. This should work for you.

Aleksander Wons
  • 3,611
  • 18
  • 29