Browse Source

Land #6556, include Vagrant development environment provisioner

Brent Cook 3 years ago
parent
commit
6d094a18c0
No account linked to committer's email address
3 changed files with 69 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. 50
    0
      Vagrantfile
  3. 18
    0
      config/database.yml.vagrant

+ 1
- 0
.gitignore View File

@@ -84,3 +84,4 @@ data/meterpreter/ext_server_pivot.*.dll
84 84
 # Avoid checking in metakitty, the source for
85 85
 # https://rapid7.github.io/metasploit-framework. It's an orphan branch.
86 86
 /metakitty
87
+.vagrant

+ 50
- 0
Vagrantfile View File

@@ -0,0 +1,50 @@
1
+# -*- mode: ruby -*-
2
+# vi: set ft=ruby :
3
+
4
+Vagrant.configure(2) do |config|
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"
10
+  config.vm.network :forwarded_port, guest: 4444, host: 4444
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}"
49
+  end
50
+end

+ 18
- 0
config/database.yml.vagrant View File

@@ -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

Loading…
Cancel
Save