Skip to content

Commit 2534ef7

Browse files
author
Brent Cook
committed
switch to inline provisioning, use official ubuntu vagrant box
1 parent 4ade689 commit 2534ef7

File tree

3 files changed

+61
-127
lines changed

3 files changed

+61
-127
lines changed

Vagrantfile

+43-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,49 @@
22
# vi: set ft=ruby :
33

44
Vagrant.configure(2) do |config|
5-
config.vm.box = "phusion/ubuntu-14.04-amd64"
5+
config.ssh.forward_x11 = true
6+
config.vm.box = "ubuntu/trusty64"
7+
# TODO: find a minimal image that keeps up-to-date and
8+
# supports multiple providers
9+
#config.vm.box = "phusion/ubuntu-14.04-amd64"
610
config.vm.network :forwarded_port, guest: 4444, host: 4444
7-
config.vm.provision :chef_apply do |chef|
8-
chef.version = "latest"
9-
chef.install = "force"
10-
chef.recipe = IO.read("scripts/shell/provision.rb")
11+
config.vm.provider "vmware" do |v|
12+
v.memory = 2048
13+
v.cpus = 2
14+
end
15+
config.vm.provider "virtualbox" do |v|
16+
v.memory = 2048
17+
v.cpus = 2
18+
end
19+
%w(.vimrc .gitconfig).each do |f|
20+
local = File.expand_path "~/#{f}"
21+
if File.exist? local
22+
config.vm.provision "file", source: local, destination: f
23+
end
24+
end
25+
26+
[ #"echo 127.0.1.1 `cat /etc/hostname` >> /etc/hosts", work around a bug in official Ubuntu Xenial cloud images
27+
"apt-get update",
28+
"apt-get dist-upgrade -y",
29+
"apt-get -y install curl build-essential git tig vim john nmap libpq-dev libpcap-dev gnupg fortune postgresql postgresql-contrib",
30+
].each do |step|
31+
config.vm.provision "shell", inline: step
32+
end
33+
34+
[ "gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3",
35+
"curl -L https://get.rvm.io | bash -s stable",
36+
"source ~/.rvm/scripts/rvm && cd /vagrant && rvm --install .ruby-version",
37+
"source ~/.rvm/scripts/rvm && cd /vagrant && gem install bundler",
38+
"source ~/.rvm/scripts/rvm && cd /vagrant && bundle",
39+
"mkdir -p ~/.msf4",
40+
].each do |step|
41+
config.vm.provision "shell", privileged: false, inline: step
42+
end
43+
config.vm.provision "file", source: "config/database.yml.vagrant", destination: "~/.msf4/database.yml"
44+
45+
config.vm.provision "shell", inline: "sudo -u postgres psql postgres -tAc \"SELECT 1 FROM pg_roles WHERE rolname='vagrant'\" | grep -q 1 || sudo -u postgres createuser -s -e -w vagrant && sudo -u postgres psql -c \"ALTER USER vagrant with ENCRYPTED PASSWORD 'vagrant';\""
46+
47+
["msf_dev_db", "msf_test_db"].each do |database|
48+
config.vm.provision "shell", inline: "sudo -u postgres psql -lqt | awk '{ print $1 }' | grep -w #{database} | wc -l | grep -q 1 || sudo -u postgres createdb --owner vagrant #{database}"
1149
end
1250
end

config/database.yml.vagrant

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
development: &pgsql
2+
adapter: postgresql
3+
database: msf_dev_db
4+
username: vagrant
5+
password: vagrant
6+
host: localhost
7+
port: 5432
8+
pool: 200
9+
timeout: 5
10+
11+
production: &production
12+
<<: *pgsql
13+
14+
test:
15+
<<: *pgsql
16+
database: msf_test_db
17+
username: vagrant
18+
wassword: vagrant

scripts/shell/provision.rb

-122
This file was deleted.

0 commit comments

Comments
 (0)