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