Vagrantfile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3. Vagrant.configure(2) do |config|
  4. config.ssh.forward_x11 = true
  5. config.vm.box = "ubuntu/xenial64"
  6. config.vm.network :forwarded_port, guest: 4444, host: 4444
  7. config.vm.provider "vmware" do |v|
  8. v.memory = 2048
  9. v.cpus = 2
  10. end
  11. config.vm.provider "virtualbox" do |v|
  12. v.memory = 2048
  13. v.cpus = 2
  14. end
  15. %w(.vimrc .gitconfig).each do |f|
  16. local = File.expand_path "~/#{f}"
  17. if File.exist? local
  18. config.vm.provision "file", source: local, destination: f
  19. end
  20. end
  21. [ #"echo 127.0.1.1 `cat /etc/hostname` >> /etc/hosts", work around a bug in official Ubuntu Xenial cloud images
  22. "apt-get update",
  23. "apt-get dist-upgrade -y",
  24. "apt-get -y install curl build-essential git tig vim john nmap libpq-dev libpcap-dev gnupg2 fortune postgresql postgresql-contrib",
  25. ].each do |step|
  26. config.vm.provision "shell", inline: step
  27. end
  28. [ "gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3",
  29. "curl -L https://get.rvm.io | bash -s stable",
  30. "source ~/.rvm/scripts/rvm && cd /vagrant && rvm install `cat .ruby-version`",
  31. "source ~/.rvm/scripts/rvm && cd /vagrant && gem install bundler",
  32. "source ~/.rvm/scripts/rvm && cd /vagrant && bundle",
  33. "mkdir -p ~/.msf4",
  34. ].each do |step|
  35. config.vm.provision "shell", privileged: false, inline: step
  36. end
  37. config.vm.provision "file", source: "config/database.yml.vagrant", destination: "~/.msf4/database.yml"
  38. 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';\""
  39. ["msf_dev_db", "msf_test_db"].each do |database|
  40. 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}"
  41. end
  42. end