Skip to content

Instantly share code, notes, and snippets.

@turtlemonvh
Created August 8, 2016 18:27
Show Gist options
  • Save turtlemonvh/2f40fa7ca0acaaabaf6a6ecb0ee556c7 to your computer and use it in GitHub Desktop.
Save turtlemonvh/2f40fa7ca0acaaabaf6a6ecb0ee556c7 to your computer and use it in GitHub Desktop.
Example vagrant file

Example vagrantfile

With ssh config adding, data directory mounted, provision script setup. 2 CPUs and 4 GB of RAM.

Create a setup bash script at provision/setup.sh and it will be run.

# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# https://vagrantcloud.com/ubuntu
config.vm.box = "ubuntu/xenial64"
config.vm.network "private_network", type: "dhcp"
# Forward ports
config.vm.network "forwarded_port", guest: 8080, host: 8080 # web server
config.vm.network "forwarded_port", guest: 5432, host: 5432 # Postgres
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
# If true, then any SSH connections made will enable agent forwarding.
config.ssh.forward_agent = true
# Share additional folders to the guest VM.
config.vm.synced_folder "data", "/data"
# Bash provision script
config.vm.provision "shell", path: "provision/setup.sh"
# Upload user's ssh key into box so it can be used for downloading stuff from stash
ssh_key_path = "~/.ssh/"
config.vm.provision "shell", inline: "mkdir -p /home/vagrant/.ssh"
config.vm.provision "file", source: "#{ ssh_key_path + 'id_rsa' }", destination: "/home/vagrant/.ssh/id_rsa"
config.vm.provision "file", source: "#{ ssh_key_path + 'id_rsa.pub' }", destination: "/home/vagrant/.ssh/id_rsa.pub"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment