provision multiple servers in a single VM using vagrant - vagrant

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!!

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.

Related

Skip/Ignore boot errors for vagrant up

Hi Guys I have a situation where I don't want use vagrant user or any other user for ssh. Whenever I do vagrant up the VM's boots and I get the below error for ssh. Its because of timeout as it is unable to find vagrant user. By default when we do vagrant up the vagrants checks for vm to boot and it does the same by sshing. Is there is way where I can ignore this bootstrap error or skip the ssh step? I did an extensive search and unable to find any documentation regarding the same. The reason I need this is because I have multiple VM which needs to be started one by one. I need to skip this error or ignore the below error so that all the VM's are started.
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within the
configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that Vagrant
had when attempting to connect to the machine. These errors are
usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes. Verify
that authentication configurations are also setup properly, as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

How can I use vagrant on an existing machine?

I have:
a machine on amazon I can ssh to
Vagrantfile and resources it uses to automate a process.
How can I tell my vagrant to use the machine I have? (I don't want to spin a new machine)
currently doing stuff manually.
also cannot use docker (project requirement).
I found this awesome vagrant plugin that answers my needs
https://github.com/tknerr/vagrant-managed-servers
You can't
Basically, vagrant needs a box to create the VM to work with. You would not be able to create a base box from your running EC2 instance (vagrant package only works with VirtualBox)
You would be able to spin new EC2 instance from a specific EC2 box (or create a box yourself for the EC2 provider) but for your existing instance, you'll need to continue working with ssh

Remote Access to Linode

Hi I am a cloud Hosting in Linode with 2 different images
using the Remote Access ssh root#149.152.231.117
I always connect to the first image (My Ubuntu 14.04 LTS Profile).
Would be possible to connect to another images ?
You can only boot into one disk at a time. Whichever disk your configuration profile is pointing to, looks like Ubuntu 14.04 in this case, is what you are booting.
You would need to reboot into another disk to run their distro. To have multiple VMs running at the same time would require multiple Linodes.
The exception here is if you choose to boot Ubuntu and then create a Docker container with a different distro. Then you can log into both.

Unable to access MongoDB within a container within a Docker Machine instance from Windows

I am running Windows 7 on my desktop at work and I am signed in to a regular user account on the VPN. To develop software, we are to normally open a Dev VM and work from in there however recently I've been assigned a task to research Docker and Mongo DB. I have very limited access to what I can install on the main machine.
Here lies my problem:
Is it possible for me to connect to a MongoDB instance inside a container inside the docker machine from Windows and make changes? I would ideally like to use a GUI tool such as Mongo Management Studio to make changes to a Mongo database within a container.
By inspecting the Mongo container, it has the ports listed as: 0.0.0.0:32768 -> 27017/tcp
and docker-machine ip (vm name) returns 192.168.99.111.
I have commented out the 127.0.0.1 binding host ip within the mongod.conf file also.
From what I have researched so far, most users resolve their problem by connecting to their docker-machine IP with the port they've set with -p or been given with -P. Unfortunately for me, trying to connect with 192.168.99.111:32768 does not work.
I am pretty stumped and quite new to this environment. I am able to get inside the container with bash and manipulate the database there however I'm wondering if I can do this within Windows.
Thank you if anyone can help.
After reading Smutje's advice to ping the VM IP and testing it out to no avail, I attempted to find a pingable IP which would hopefully move me closer to my goal.
By doing "ifconfig" within the Boot2Docker VM (but not inside the container), I was able to locate another IP listed under eth0. This IP looks something like 134.36.xxx.xxx to me and is pingable. With the Mongo container running I can now access the database from within Mongo Management Studio by connecting to 134.36.xxx.xxx:32768 and manipulate the data from there.
If you have the option of choosing the operating system for your dev VM, go with Ubuntu and setup docker with all of the the containers you want to test on that. Either way, you will need to have a VM for testing docker on windows since it uses VirtualBox if i'm not mistaken. Instead, setup an Ubuntu VM and do all of your testing on that.

Using vagrant on EC2

I need to setup a web server and a database server on EC2.
It should be easy to migrate to another service provider later.
Currently, I have a web server and a database server, each running on separate EC2 micro instances with software installed there remotely.
Can we run a vagrant box on these micro instances with pre-installed and pre-configured softwares like LAMP stack and use that instead. So I will end with 2 vagrant boxes , one for web server another for database server.
Amazon provides already means to copy an instance but it is copied to another EC2 instance only probably .. If there is need to move to some other provider, it will be same process of re-installing all. So, an own virtual box installed on Amazon's virtual box is what i was looking into..
I don't know how good or bad it is.. I doubt if this will affect performance as well. Please share your views. Target is to have env prepared locally and have flexibility to deploy it on any service provider easily.
Running vagrant inside your AWS box is probably not the right solution. Have you looked into the Vagrant AWS provider?
That will allow you to setup and provision your AWS boxes with Vagrant and Puppet or Chef... if you are using Puppet or Chef to provision your servers then you will have a very portable "scripted" install for your servers that can easily be moved to another provider at a later date...
So running a virtual machine, on another virtual machine probably isn't the best. But if you want to install Vagrant on Amazon Linux you can do:
wget https://releases.hashicorp.com/vagrant/2.2.4/vagrant_2.2.4_x86_64.rpm
sudo rpm -ivh vagrant_2.2.4_x86_64.rpm
The RPM is the Centos version from the downloads page here: https://www.vagrantup.com/downloads.html
But then you cannot install virtualbox to run a VM. So it doesn't actually work anyways.

Resources