blob: 0b06e2a77ad0457fc7a96439fdd98f1019adc1f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
execute "apt-get update -y"
execute "curl -sL https://deb.nodesource.com/setup | bash -"
packages = %w{
build-essential
curl
git-core
libcurl4-openssl-dev
libffi-dev
libpq-dev
libreadline-dev
libssl-dev
libxml2-dev
libxslt1-dev
libyaml-dev
nodejs
phantomjs
postgresql
postgresql-client-common
postgresql-contrib
python-software-properties
redis-server
zlib1g-dev
}
package packages
sql = "SELECT 1 FROM pg_roles WHERE rolname='ubuntu'"
create_user = "createuser -s -e -w ubuntu"
execute "psql postgres -tAc \"#{sql}\" | grep -q 1 || #{create_user}" do
user "postgres"
end
sql = "SELECT 1 FROM pg_roles WHERE rolname='ubuntu'"
execute "createdb" do
user "ubuntu"
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 /vagrant/.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
execute "cp .env.example .env.local" do
user "ubuntu"
cwd "/vagrant"
not_if { ::File.exist?("/vagrant/.env.local") }
end
["redis-server", "postgresql"].each do |service_name|
service service_name do
action [:enable, :start]
end
end
|