Vagrant run command: Where, what and why? - vagrant

Following this tutorial on the Vagrant website, I was able to get a virtual machine up and running very easily, but now I'm trying to create a different virtual machine by forking a repository linked below.
The README in this repository tells me to do this:
$ git clone git://github.com/honza/django-chef.git
$ cd django-chef
# add yourself to the "users" array in the Vagrantfile
$ sudo echo "127.0.0.1 example.example.com" >> /etc/hosts
$ vagrant up
$ fab vagrant:honza bootstrap # replace with your name
$ vagrant ssh
$ run # ME (doctordoder): This command is not found?
"Then open your browser to http://example.example.com:3456."
The difference being that the other tutorial stops at vagrant up, and then the website is available.
When I tried to do these extra steps with this more difficult repository, I got this (I did these commands after I had already ran vagrant up in the django-chef directory successfuly):
Where is this so called "run" command in vagrant? Why do I need it? And why is it unavailable to me?

Because it's not a vagrant command :) It's a custom command that's put in by the chef provisioner.
I scanned the source code of the repository and you can find a .erb template in the following folder:
django-chef/cookbooks/example/templates/default/bashrc.erb [line 23]
within this file there is a custom function defined named "run". This function will execute the "runserver" command form django (link)
The file
django-chef/cookbooks/example/recipes/default.rb [line 23]
is responsible for updating the .bashrc file on the guest machine and that's why you can call the "run" command from inside the guest machine.
So basically you are looking at the wrong place.

Related

vagrant invalid option was specified

I am trying to install in on my laptop while running on Windows 8. I have downloaded and installed vagrant and Virtualbox and currently am trying to download vagrant box using
vagrant init tsawler/wafs; vagrant up --provider virtualbox
and i get this error,
C:\Users\patrick\Documents\website>vagrant init tsawler/wafs; vagrant up --provider virtualbox
An invalid option was specified. The help for this command is available below.
Usage: vagrant init [options] [name [url]]
Options:
-f, --force Overwrite existing Vagrantfile
-m, --minimal Create minimal Vagrantfile (no help comment
s)
--output FILE Output path for the box. '-' for stdout
-h, --help Print this help
I have tried to add the -f or --force option after the init but still get the same result. Is there a setting that missing?
Sometimes, multiple commands on the same line may not get parsed correctly, and running them separately usually works. Try these.
C:\Users\patrick\Documents\website>vagrant init tsawler/wafs C:\Users\patrick\Documents\website>vagrant up
Run command prompt with Administrative privileges.

No synced vagrant folder to be found

I am trying to work through the "Getting Started" section at the vagrant site. I run through the two commands they show:
$ vagrant init hashicorp/precise32
$ vagrant up
All seems to go well. I then run these two commands:
$ vagrant ssh
$ lsb_release -a
The result shows I'm running on Ubuntu 12.04, precise. So far so good.
However, when I do an 'ls' the only thing in the directory is a postinstall.sh file. I thought I should have been in the same directory as the Vagrantfile.
Sorry for such a newbie question. I'm sure its something basic I messed up.
I'm doing this on an Ubuntu 14.10 box with Virtualbox 4.3.22 and Vagrant 1.7.2 installed.
Thanks
By default, Vagrant will share your project directory (the directory with the Vagrantfile) to /vagrant on the guest machine.

Alias setup -bash: vm: command not found

In the Build Larabook from scratch Laracast tutorial, it is required to synchronize the local folder of the app with the virtual machine (Homestead) and vice versa.
To simplify development, the tutorial recommends to create the following alias:
ssh vagrant#127.0.0.1 -p 2222
by placing alias vm="ssh vagrant#127.0.0.1 -p 2222" in an ~/.aliases file, which I did.
This lets the narrator simply type the vm command from the local app folder to launch the virtual machine.
When I try to do so, I get -bash: vm: command not found
Did I miss something?

Vagrant 'box could not be found' error

I've installed Vagrant and VirtualBox to simulate Hadoop management (Apache Ambari). According to its installing documentation, i've done everything to create a vm (with 'vagrant up' command). I've installed manually lucid32 box file and placed it to the directory but it still says:
There are errors in the configuration of this machine. Please fix
the following errors and try again:
vm:
* The box 'lucid32' could not be found.
What am i doing wrong?
I was able to get a box up using the latest install following this process.
# From your home directory, install the template box
vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
# From your project directory
vagrant init lucid32
vagrant up
Using Apache Ambari:
# clone from GitHub
git clone https://github.com/u39kun/ambari-vagrant.git
# Append these entries to ambari-vagrant/append-to-etc-hosts.txt
# ubuntu 12.4 hosts
192.168.12.101 u1201.ambari.apache.org u1201
192.168.12.102 u1202.ambari.apache.org u1202
192.168.12.103 u1203.ambari.apache.org u1203
192.168.12.104 u1204.ambari.apache.org u1204
192.168.12.105 u1205.ambari.apache.org u1205
192.168.12.106 u1206.ambari.apache.org u1206
192.168.12.107 u1207.ambari.apache.org u1207
192.168.12.108 u1208.ambari.apache.org u1208
192.168.12.109 u1209.ambari.apache.org u1209
192.168.12.110 u1210.ambari.apache.org u1210
# Modify your hosts file
sudo cat ambari-vagrant/append-to-etc-hosts.txt >> /etc/hosts
# Get up and running
cd ambari-vagrant/ubuntu12.4
vagrant up
There was a problem with the configuration of Vagrant. The error message(s)
are printed below:
vm:
* The box 'hashicorp/precise64' could not be found.
For me, this was a simple matter of using too old a version of vagrant (version 1.0.1).
Download the latest from: https://www.vagrantup.com/downloads.html
And then:
$ sudo dpkg -i vagrant_1.8.5_x86_64.deb

Vagrant: how to edit files on the Vagrant server?

I'm following these instructions for setting up a Django app on Vagrant.
I have successfully completed them and started Django, but: how can I now edit the Django files within my usual text editor, TextMate?
I guess I can ssh and use vi to edit them from the command line, but I thought the point of Vagrant was to be able to use my usual editing tools.
I'm just not sure where the Django files are physically located.
Apologies if this question is off-topic, I'll happily post it elsewhere, if editors can let me know where is best.
That web site is exactly the same place I started a few months ago.
Since I've learned more about Vagrant since then, I've created my own GitHub repo. You can download it here:
https://github.com/FlipperPA/djangovagrant
The way it is setup:
git clone the repo to a local directory on your machine
cd into that directory
run "vagrant up"
the directory you run "vagrant up" in is mapped to /vagrant on the guest virtual machine
Here is a working example of the way one might do it:
cd $home
git clone https://github.com/FlipperPA/djangovagrant.git
cd djangovagrant
vagrant up
vagrant ssh djangovm
cd /vagrant
django-admin.py startproject django_project
cd django_project
python manage.py runserver [::]:8000
You will then see the Django Project build on your local machine in the "djangovagrant" folder you created by the clone command above. You can you Textmate, Sublime, or any text editor you like to edit the files locally, and they'll be mapped to the guest VM.
I hope this helps - good luck.
Vagrant always synchronizes the files in the project you set up with your PC.
So whenever you ssh into the vagrant, (usually) in /vagrant directory you can see all the files you have in the root folder of your project (directory where Vagrantfile ruby script is)
Now you can use your text editor and save the file in a folder you want (for convenience, always save new files inside the project directory). now mirroring your directory structure around the /vagrant directory you can see the file being saved in the appropriate folder in your guest machine.
For e.g if you created and saved a file in your project root folder then you can see it appear in /vagrant directory.

Resources