/vagrant

Going to put random vagrant-related stuff here.

Primary LanguageRuby

Vagrant?

Vagrant is a 'wrapper' for many different virtual machine providers, in other words, it is a single solution to spin up virtual machines from the command line with programs like virtualbox, or cloud-based services like amazon's EC2 or VMWare's vSphere. Easily bootstrap and provision machines with a single command! Please, developers, make your life easy. Check it out! http://vagrantup.com.

Welcome to a new way of using vagrant, flexible and fully parameterized.

Vagrantfile

This file would normally be auto-generated by Vagrant, but with some heavy-duty ruby lifting, this Vagrantfile has been fully abstracted to an external file called shelters.yaml. Anything you need, from a default box to provisioner settings to AWS account information has been coded into this vagrant file and is used in an as-needed logical way. Feel free to poke around, please comment or contribute.

shelters.yaml

This is the file you should primarily be editing. You no longer need to edit the Vagrantfile directly. (And I suggest you do not unless you really know what you are doing, you may get unexpected results). Below I've outlined the basic settings you will need to configure:
aws_access_key_id: your AWS access key id, you can find this in your AWS settings.
aws_ami: The amazon linux AMI you want to use.
aws_keypair_name: You will need to generate a keypair with AWS and then name it. That you put here.
aws_private_key_path: I suggest placing this in the current directory.
aws_secret_access_key: Found in the AWS settings right under the access key id.
aws_security_groups: If you are using security groups in EC2, this will be the group you are using.
box: The default box you want to use for bringing up virtual machines. (find some at vagrantbox.es)
box_url: The URL of your default box.
private_key_path: the path to the private key you are using (if any) for vagrant.

Vagrant Installation Instructions

Mac Users:

Note: The ruby version Macs ship with will NOT work with the vagrant-aws plugin, I strongly recommend following the instructions below.
  1. Install VirtualBox: VirtualBox-4.2.14.dmg
  2. Install Command Line Tools for Xcode, you will need your Apple ID.
  3. Install git Git for Mac
  4. Install RVM for installing Ruby (backslash included):
    \curl -L https://get.rvm.io | bash
  5. Configure RVM for use:
    source ~/.rvm/scripts/rvm
  6. Install ruby:
    rvm install 1.9.3
  7. Install Vagrant-1.2.2.dmg
  8. Install vagrant-aws plugin:
    vagrant plugin install vagrant-aws
  9. Clone my vagrant_shelters repo:
    git clone https://github.com/jedmunds/vagrant/
  10. cd into the directory:
    cd vagrant_shelters
  11. Edit the shelters.yaml file to include your local paths rather than mine.
  12. Run vagrant up environment, where environment is a name in the shelters.yaml file or a custom VM name. For instance:
    vagrant up confluence
  13. If you want to bring up machines with AWS, append --provider=aws to your 'vagrant someCommand someEnvironment' commands, and it should just 'work'.
    vagrant up confluence --provider=aws

Windows Users:

Note: This is not for the faint of heart, as you may encounter one or two (or seven) errors along the way.
  1. Install VirtualBox: VirtualBox-4.2.12.exe No other version will work!
  2. Install ruby: Ruby 2.0.0 (x64) and select 'add ruby binaries to PATH.
  3. Install Vagrant: Vagrant for Windows
  4. Install MinGW, checking all boxes during installation: MinGW Linux Commands
  5. Install git for Windows: Git for Windows
  6. Clone my repo:
    git clone https://github.com/jedmunds/vagrant.git
  7. cd into my repo directory
    cd vagrant
  8. Install vagrant-aws plugin:
    vagrant plugin install vagrant-aws
  9. Edit the shelters.yaml file to include your local paths rather than mine.
  10. Run vagrant up environment, where environment is a name in the shelters.yaml file or a custom VM name. For instance:
    vagrant up confluence
  11. If you want to bring up machines with AWS, append --provider=aws to your 'vagrant someCommand someEnvironment' commands, and it should just 'work'.
    vagrant up confluence --provider=aws

Windows Debugging

'Vagrant up' yields an error, and won't get very far at all.

This is probably due to a bad virtualbox version, did you install the SPECIFIC version vagrant needs? 4.2.12

'It looks like it's working, but it hangs for a long time at "Waiting for VM to boot. This can take a few minutes. . ."

Shake your first at windows for having such a crappy system clock, and fix yours.
Control Panel > System > Date and Time > Internet Time > Change Settings > srbsldc > Update now.
This could also be because you don't have the proper private key for your vagrant machine, in which case you will
need to Ctrl-C and then manually run 'vagrant ssh'

Vagrant tells me I don't have an ssh client installed! Help!

99% chance this is because you changed the install directory of MinGW. If you changed it to something other than C:\MinGW\, probably C:\Program Files\MinGW, you will have to manually add the binaries in there to your Windows path. I strongly recommend you uninstall it and reinstall it in C:\MinGW\ If that is not the issue, try to use the 'ssh' command from cmd.exe. If that does not work, you did something horribly wrong with the MinGW installation.

FAQ

Will the Vagrantfile work by itself? No, with such heavy parameterization the Vagrantfile needs the shelters.yaml file to work (at all)

What's with all the weird-looking code in your Vagrantfile? Vagrantfiles are written in ruby, and all the weird-looking code is just 'extra' ruby.

Why should I use your Vagrantfile? I'll just write my own! Please do! Playing with vagrant is fun, and I don't intend to deprive anyone of the opportunity. However, for those that want a working, cross-platform, scalable solution, I suggest at least skimming over my Vagrantfile.