How can I use vagrant on an existing machine? - vagrant

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

Related

Remote Vagrant Dev Server

I am a web developer and I am currently using Vagrant + VirtualBox to run my projects. I have a Proliant server at home that I am not using at the moment. I was thinking, is there any way I could use it instead of the VM, so I could run my projects remotely?
P.S: Can you think about any other cool use cases for this server?
Vagrant is design to work with VMs or containers when using a docker provider but not bare metal server simply because the goal is to be able to build, use, destroy and rebuild environment programmatically so using a base-metal server break the main use case.
The possible course of action is to install the hypervisor on your personal server and then configure your Vagrantfile to use the remote provider instead of the local. You'll have as a direct benefit the ability to create a lot of instance since your server will most likely have more resources than your local laptop/desktop workstation.

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.

provision multiple servers in a single VM using 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.

What are the advantages of using Chef-server with Vagrant v/s Chef-Solo with Vagrant?

I've done some read-up on Vagrant with Chef-Server v/s Vagrant with Chef-solo and have found blogs talking about the usage of the same. I've failed to find anybody summarizing the advantages of either approach. So, here's my question.
I understand that Vagrant cannot spin up virtual machines on a remote machine. This means running "vagrant up" on a particular machine will spin up VMs on that machine alone.
First of all, is this understanding right?
If yes, what’s the point of using a chef server to provision the server?
I feel that if I’m using Vagrant, using chef solo is the way to go and chef
server isn’t adding any value.
Do you think I’m missing something?
Vagrant is used for spin up VMs and you can provision those VMs with the help of chef recipes or via any other provisioning method. https://docs.vagrantup.com/v2/provisioning/index.html
Now, Difference between Chef Server and Chef-Solo:
Chef Server works in Client Server Architecture. You can control or manage all your nodes (VMs launched by Vagrant) with the help of Chef Server. In a particular VM, you can search for other nodes with the help of Chef Server.
Chef-Solo works in Solo mode means, you can provision only single node and you can not get any information about the other nodes. However several techniques exists to overcome such situations like chef-solo-search.

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