Skip to content

andyl/vagrant_base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vagrant Virtual Machines

This repo provides machines for development. Host machine can be your desktop (linux, mac, windows) or a bare-metal linux server in the datacenter.

Goals

Fast developer onboarding and operational flexibility:

  • flexible filesharing, port-forwarding, DNS & network configuration
  • simple to clone/copy/backup your whole machine
  • you can move your VM between desktop and datacenter
  • you can run many independent VMs on a production host

Our VM images are pre-loaded with language runtimes (Ruby, NodeJS, Python), editors (vim), databases (SqLite, Postgres, Redis), etc. The machine images are extensible and customizable.

This tooling is optimized for research and software development. For production, use Docker containers.

Getting Started

To get started, install Git, Vagrant and VirtualBox 7.0 on your host. Then to create a new virtual machine:

git clone https://github.com/andyl/VVM
cd VVM/<subdir>
vagrant up
vagrant ssh 

The first time you run the vagrant up command, a large (~2.5GB) machine image will be downloaded. After that, creating new machines from this image takes a minute or two.

Packaged Machine Images

Find pre-packaged machine images on our Vagrant Cloud

Machine Profiles:

  • base - the simplest base machine
  • full - has language runtimes and editors, databases and Docker support

Machine images are updated periodically. To get the latest version:

cd VVM/packaged_full
vagrant box update

Ansible for Provisioning

Machine provisioning is done with Ansible. Study the Ansible Roles repo, the playbooks under the ANSIBLE directory, and the roles for installing software components.

The Ansible provisioner will create a read-only copy of the ANSIBLE directory in your working directory. (the same directory that holds the Vagrantfile) The ANSIBLE directory contains the ansible configuration file and a default playbook. This directory is re-written every time the provisioner runs.

If you want to customize the Ansible provisioning process, copy the ANSIBLE directory to another directory (like ansible), then edit the Vagrantfile to change the provisioning_path.

How to create a new Packaged Machine

First create a custom-configured live VM. Then run these commands:

# get the name of the base-box you want to package
vboxmanage list vms
vagrant ssh -c util/x-ansible/bin/boxprep
vagrant package --base <YOURBOX>

Your new base box will be written to package.box. You can use this new base box like any other Vagrant box. You can share your base box publically on Vagrant Cloud, or keep it local for private use.

To share on the Vagrant Cloud, visit their website and use their publishing tools.

Support

Contact Andy for support. Here are some things we can try together:

  • custom base boxes for streamlined provisioning
  • VM customzation for performance
  • mounting source directories to use GUI editors on host machine
  • development & test consoles
  • moving a VM from your desktop to the datacenter
  • pair-programming from your desktop VM across the firewall

Please post bugs and questions to our Issue Tracker.

Appendix A: Working with Docker

We like Docker for service deployment, and publish a suite of reusable docker services at Casmacc.io.

Do a quick test on a Docker-enabled host:

TERMINAL1> docker run -p 3060:80   casmacc/html_helloworld
TERMINAL2> docker run -p 3061:3090 casmacc/sinatra_helloworld
TERMINAL3> docker run -p 3062:4000 casmacc/phoenix_helloworld
TERMINAL4> curl localhost:3060
TERMINAL4> curl localhost:3061
TERMINAL4> curl localhost:3062

Appendix B: Working with Bare-Metal Hosts (BMH)

VMs can run in a Bare-Metal host in a datacenter.

We can get a bare-metal server with 16 cores and 96GB ram for ~$50 month. With this capacity, we could scale a VM up or down as needed for demos and experiments.

Note that both Google Compute Engine and Azure support a Nested Virtualization option that allows you to run Virtual Box. The Nested Virtualization machines run about $100/month for a machine with decent performance. AWS also has bare metal servers that cost in the range of $5-7 per hour.

Configuring the Bare-Metal Host

The bare-metal host should run Ubuntu 18.04 and be provisioned with: git, docker, vagrant and virtualbox. The BMH reqires a fixed IP address.

Setup a DNS entry to link your root-doman with your IP address, and add a wildcard subdomain entry that points to the same IP.

SSH Access

Setup your VM for ssh access on a unique port. Then:

ssh <host> -p <VM-port>

Nginx Proxy

Use the Casmacc Nginx-Proxy container to route subdomains (like intern.bugmark.tech) to guest VMs. See the README Notes for configuration information.

Appendix C: Binary Large Objects

We use a handful of pre-compiled executables, packages and tar files. These are large binary objects, not well suited for management with Git. For now we're simply posting the objects onto a webserver with rsync, and making the objects available for download during Ansible provisioning. The files are currently served here.

Appendix D: Collaboration

The full image is configured with tools for remote collaboration and pair-programming.

SSH-CHAT

Connect to the SSH-Chat server from the command line. Run sshchat.

Note: you can setup a project-specific ssh-chat service using SSH-Chat Docker

TMATE Terminal Sharing

Session host:

  • start a tmate session tmate_start
  • publish the session address tmate_address
  • the session address is auto-published onto SSH-Chat

Session guest:

  • enter the ssh command with session address on your command line

WORMHOLE File Transfer

Sender:

  • type wormhole send <filename>
  • note the wormhole code

Receiver:

  • get the wormhole code from the sender
  • type wormhole receive <code>

Appendix E: Host/Guest Shared Files

The host directory is mounted on the guest at /vagrant.

If you want to share other directories, edit the Vagrantfile and follow the synced-folder guide.

Appendix F: Remote Shared Files

If your VM is running on a bare-metal host in a datacenter, you can use sshfs to mount a VM filesystem locally.

mkdir ./mountpoint
sshfs [user@]<BARE-METAL-DOMAIN> ./mountpoint -p <VM-port>

Appendix G: Collaboration on a Mac Host

You can use SSH-Chat and Tmate on your Mac host.

This is useful if you'd like help with setting up your VM.

SSH-Chat just works, open a terminal then $ ssh casmacc.net -p 9000.

To install Tmate, open a terminal then $ brew install tmate.

To start Tmate, type $ tmate. Then from within tmate, type:

$ echo -e $(tmate show-messages) "\r" | ssh casmacc.net -p 9000

Your partner will be able to find the attachment code on sshchat and connect.

Appendix H: Virtual Machines and File-Watchers

Oftentimes you'll use test-runners and build tools on your VM that are built on file-watchers like grunt and guard.

Unfortunatly the guest OS will not be notified when a file is changed in a folder shared with the host.

To resolve this problem, install plugin vagrant-notify-forwarder.

$ vagrant plugin install vagrant-notify-forwarder

Reload your VM after installing the plugin...

Appendix I: VM Performance Tips

Fast DNS Lookups

If DNS resolution is slow, try specifying a Google nameserver in /etc/resolve.conf:

nameserver 8.8.8.8

Then restart the network:

sudo systemctl restart NetworkManager

Appendix J: Resources

About

Vagrant Virtual Machines

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages