master
1execute "apt-get update -y"
2execute "curl -sL https://deb.nodesource.com/setup | bash -"
3
4packages = %w{
5 build-essential
6 curl
7 git-core
8 libcurl4-openssl-dev
9 libffi-dev
10 libpq-dev
11 libreadline-dev
12 libssl-dev
13 libxml2-dev
14 libxslt1-dev
15 libyaml-dev
16 nodejs
17 phantomjs
18 postgresql
19 postgresql-client-common
20 postgresql-contrib
21 python-software-properties
22 redis-server
23 zlib1g-dev
24}
25
26package packages
27
28sql = "SELECT 1 FROM pg_roles WHERE rolname='ubuntu'"
29create_user = "createuser -s -e -w ubuntu"
30execute "psql postgres -tAc \"#{sql}\" | grep -q 1 || #{create_user}" do
31 user "postgres"
32end
33
34sql = "SELECT 1 FROM pg_roles WHERE rolname='ubuntu'"
35execute "createdb" do
36 user "ubuntu"
37 not_if { "psql postgres -tAc \"#{sql}\" | grep -q 1" }
38end
39
40git "/usr/local/rbenv" do
41 repository "https://github.com/sstephenson/rbenv.git"
42end
43
44file "/etc/profile.d/rbenv.sh" do
45 content <<-CONTENT
46export RBENV_ROOT="/usr/local/rbenv"
47export PATH="/usr/local/rbenv/bin:$PATH"
48eval "$(rbenv init -)"
49CONTENT
50end
51
52directory "/usr/local/rbenv/plugins"
53git "/usr/local/rbenv/plugins/ruby-build" do
54 repository "https://github.com/sstephenson/ruby-build.git"
55end
56
57ruby_version = `cat /vagrant/.ruby-version`.strip
58bash "install_ruby" do
59 user "root"
60 not_if { ::Dir.exist?("/usr/local/rbenv/versions/#{ruby_version}") }
61 code <<-EOH
62source /etc/profile.d/rbenv.sh
63rbenv install #{ruby_version}
64rbenv global #{ruby_version}
65EOH
66end
67
68bash "install_bundler" do
69 user "root"
70 code <<-EOH
71source /etc/profile.d/rbenv.sh
72gem install bundler --no-ri --no-rdoc
73EOH
74end
75
76execute "cp .env.example .env.local" do
77 user "ubuntu"
78 cwd "/vagrant"
79 not_if { ::File.exist?("/vagrant/.env.local") }
80end
81
82["redis-server", "postgresql"].each do |service_name|
83 service service_name do
84 action [:enable, :start]
85 end
86end