Last active
August 29, 2015 14:21
-
-
Save mgedmin/a9628b1e2eaa8b4d2f93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--memory", "1024"] | |
end | |
# My ~/.ssh/config has | |
# | |
# Host vagrantbox | |
# HostName 127.0.0.1 | |
# User vagrant | |
# Port 2992 | |
# UserKnownHostsFile /dev/null | |
# StrictHostKeyChecking no | |
# PasswordAuthentication no | |
# IdentityFile ~/.vagrant.d/insecure_private_key | |
# IdentitiesOnly yes | |
# | |
config.vm.network :forwarded_port, guest: 22, host: 2992 | |
# | |
# Provisioning: | |
# - allow ssh root@vagrantbox | |
# | |
config.ssh.shell = 'bash' # https://github.com/mitchellh/vagrant/issues/1673 | |
config.vm.provision "shell", inline: <<-END | |
# Make it possible to ssh root@vagrantbox. | |
install -d -m 700 /root/.ssh | |
cp /home/vagrant/.ssh/authorized_keys /root/.ssh/ | |
# Install my locale. | |
if ! locale -a | grep -q lt_LT.utf8; then | |
locale-gen lt | |
fi | |
# Install my dotfiles. Cost: ~30 seconds. You can skip this: | |
# ``SKIP_DOTFILES=1 vagrant up``. | |
if ! [ -d /home/vagrant/dotfiles ] && [ -z '#{ENV['SKIP_DOTFILES']}' ]; then | |
if ! [ -x /usr/bin/git ]; then | |
DEBIAN_FRONTEND=noninteractive apt-get install -y git | |
fi | |
su - vagrant -c 'git clone https://github.com/mgedmin/dotfiles' | |
su - vagrant -c 'dotfiles/install.sh' | |
fi | |
# Install pov-admin-tools. Cost: ~3 minutes. You can skip this: | |
# ``SKIP_POV=1 vagrant up``. | |
if [ -z '#{ENV['SKIP_POV']}' ]; then | |
glob_exists() { [[ -f $1 ]]; } | |
if ! glob_exists /etc/apt/sources.list.d/pov-ppa-*.list; then | |
add-apt-repository -y ppa:pov/ppa | |
apt-get update | |
fi | |
if ! [ -x /usr/sbin/new-changelog-entry ]; then | |
DEBIAN_FRONTEND=noninteractive apt-get install -y pov-admin-tools | |
fi | |
fi | |
END | |
# Now you can do | |
# | |
# vagrant package --output ./mg --vagrantfile Vagrantfile.minimal | |
# vagrant box add mg-trusty64 ./mg | |
# | |
# and then you can 'vagrant init mg-trusty64 && vagrant up', which will be | |
# faster than re-provisioning this. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment