Skip to content

Instantly share code, notes, and snippets.

@thinkbigthings
Last active December 16, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkbigthings/5362917 to your computer and use it in GitHub Desktop.
Save thinkbigthings/5362917 to your computer and use it in GitHub Desktop.
Starter vagrant file that creates a machine with Java and MySQL
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
export DEBIAN_FRONTEND=noninteractive
apt-get -q -y update
apt-get -q -y install emacs
apt-get -q -y install mysql-server
apt-get -q -y install mysql-client
# mysql_bootstrap.sql:
# create schema appdb; create user 'dbuser'@'%' identified by 'dbuserpassword'; grant all on appdb.* to 'dbuser'@'%';
mysqladmin -u root password root
mysql --user=root --password=root --host=localhost --port=3306 < /vagrant/mysql_boostrap.sql
SCRIPT
# gets maven
# wget http://mirror.cc.columbia.edu/pub/software/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
# gunzip apache-maven-3.0.5-bin.tar.gz
# tar -xvf apache-maven-3.0.5-bin.tar
# sudo mv apache-maven-3.0.5 /opt
# gets netbeans
# wget http://download.netbeans.org/netbeans/7.3/final/bundles/netbeans-7.3-javaee-linux.sh
# chmod 755 netbeans-7.3-javaee-linux.sh
# sudo ./netbeans-7.3-javaee-linux.sh --silent -J-Dnb-base.installation.location=/opt/netbeans-7.3
# rm netbeans-7.3-javaee-linux.sh
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "dev-ubuntu-12.04"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provision :shell, :inline => $script
# cloned from https://github.com/opscode-cookbooks/java
# modified ./cookbooks/java/attributes/default.rb... set default['java']['jdk_version'] = '7'
config.vm.provision :chef_solo do |chef|
chef.add_recipe "java"
end
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine
config.vm.network :forwarded_port, guest: 3306, host: 3309
config.ssh.forward_x11 = "false"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network :private_network, ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network :public_network
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
config.vm.provider :virtualbox do |vb|
# Don't boot with headless mode
vb.gui = false
# Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
#
# View the documentation for the provider you're using for more
# information on available options.
# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
#
# config.vm.provision :chef_solo do |chef|
# chef.cookbooks_path = "../my-recipes/cookbooks"
# chef.roles_path = "../my-recipes/roles"
# chef.data_bags_path = "../my-recipes/data_bags"
# chef.add_recipe "mysql"
# chef.add_role "web"
#
# # You may also specify custom JSON attributes:
# chef.json = { :mysql_password => "foo" }
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment