forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use vagrant and chef-apply to provision a dev box.
- Loading branch information
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
Vagrant.configure(2) do |config| | ||
config.vm.box = "bento/ubuntu-14.04" | ||
config.vm.provision :chef_apply do |chef| | ||
chef.version = "latest" | ||
chef.install = "force" | ||
chef.recipe = IO.read("provision.rb") | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
execute "apt-get update -y" | ||
execute "apt-get upgrade -y" | ||
|
||
package [ | ||
"build-essential", | ||
"curl", | ||
"git-core", | ||
"libcurl4-openssl-dev", | ||
"libffi-dev", | ||
"libreadline-dev", | ||
"libsqlite3-dev", | ||
"libssl-dev", | ||
"libxml2-dev", | ||
"libxslt1-dev", | ||
"libyaml-dev", | ||
"python-software-properties", | ||
"sqlite3", | ||
"zlib1g-dev", | ||
] | ||
|
||
bash "install postgres" do | ||
user "root" | ||
not_if { ::File.exist?("/etc/apt/sources.list.d/pgdg.list") } | ||
code <<-SCRIPT | ||
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list | ||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc \ | ||
| apt-key add - | ||
apt-get update -y | ||
apt-get install -y postgresql-9.4 libpq-dev \ | ||
postgresql-contrib-9.4 postgresql-client-common | ||
SCRIPT | ||
end | ||
|
||
sql = "SELECT 1 FROM pg_roles WHERE rolname='vagrant'" | ||
create_user = "createuser -s -e -w vagrant" | ||
execute "psql postgres -tAc \"#{sql}\" | grep -q 1 || #{create_user}" do | ||
user "postgres" | ||
end | ||
|
||
sql = "SELECT 1 FROM pg_roles WHERE rolname='vagrant'" | ||
execute "createdb" do | ||
user "vagrant" | ||
not_if { "psql postgres -tAc \"#{sql}\" | grep -q 1" } | ||
end | ||
|
||
git "/usr/local/rbenv" do | ||
repository "https://github.com/sstephenson/rbenv.git" | ||
end | ||
|
||
file "/etc/profile.d/rbenv.sh" do | ||
content <<-CONTENT | ||
export RBENV_ROOT="/usr/local/rbenv" | ||
export PATH="/usr/local/rbenv/bin:$PATH" | ||
eval "$(rbenv init -)" | ||
CONTENT | ||
end | ||
|
||
directory "/usr/local/rbenv/plugins" | ||
git "/usr/local/rbenv/plugins/ruby-build" do | ||
repository "https://github.com/sstephenson/ruby-build.git" | ||
end | ||
|
||
ruby_version = `cat .ruby-version`.strip | ||
bash "install_ruby" do | ||
user "root" | ||
not_if { ::Dir.exist?("/usr/local/rbenv/versions/#{ruby_version}") } | ||
code <<-EOH | ||
source /etc/profile.d/rbenv.sh | ||
rbenv install #{ruby_version} | ||
rbenv global #{ruby_version} | ||
EOH | ||
end | ||
|
||
bash "install_bundler" do | ||
user "root" | ||
code <<-EOH | ||
source /etc/profile.d/rbenv.sh | ||
gem install bundler --no-ri --no-rdoc | ||
EOH | ||
end | ||
|
||
["postgresql"].each do |service_name| | ||
service service_name do | ||
action [:enable, :start] | ||
end | ||
end |