Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 113 lines (94 sloc) 2.856 kb
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
dep('application deployable') {
  setup {
    unmeetable! "This dep has to be run as root." unless shell('whoami') == 'root'
  }

  requires [
    'benhoskings:system',
    'testpilot:ruby dependencies',
    'ivanvanderbyl:ruby.src',
    'benhoskings:user setup for provisioning',
    'testpilot:core dependencies',
    'testpilot:build essential installed',
    'testpilot:nodejs installed',
    'benhoskings:core software',
    'benhoskings:passwordless sudo',
    'postgresql.managed'
  ]
}

dep('application deployed', :domain){
  setup {
    unmeetable! "This dep cannot be run as root." if shell('whoami') == 'root'
  }

  requires [
    'testpilot:core dependencies',
    'benhoskings:secured ssh logins',
    'user can write to usr local',
    'ivanvanderbyl:running.nginx',
    'postgres access',
    'vhost enabled.nginx',
    'profile setup',
    'bundler.gem',
    'testpilot:java installed'
  ]

}

dep('postgresql.managed') {
  installs ['postgresql-9.1', 'postgresql-server-dev-9.1', 'postgresql-contrib']
  provides %w(pg pg_config pg_createcluster
pg_ctlcluster pg_dropcluster pg_dump pg_dumpall pg_lsclusters
pg_restore pg_upgradecluster)
}

dep('postgresql-dev.managed') {
  requires 'postgresl major release sources'

  installs [
    'postgresql-server-dev-9.2',
    'postgresql-contrib-9.2',
    'libpq-dev'
  ]
  provides []
}

dep('postgresl major release sources') {
  def release
    shell('lsb_release --codename --short')
  end

  met? {
    File.exists?('/etc/apt/sources.list.d/pgdg.list') &&
    !!(File.read('/etc/apt/sources.list.d/pgdg.list') =~ /#{release}/)
  }

  meet {
    cmd = <<-LOL
if [ -f /etc/apt/sources.list.d/pitti-postgresql-$(lsb_release --codename --short).list ] ]; then
rm /etc/apt/sources.list.d/pitti-postgresql-$(lsb_release --codename --short).list
fi
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release --codename --short)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
apt-get update
apt-get install pgdg-keyring
LOL

  shell(cmd, :sudo => true)
  }
}

dep 'postgres access', :username do
  requires 'postgresql.managed'
  met? { !sudo("echo '\\du' | #{which 'psql'}", :as => 'postgres').split("\n").grep(/^\W*\b#{username}\b/).empty? }
  meet { sudo "createuser -SdR #{username}", :as => 'postgres' }
end

dep('profile setup', :deploy_to) do
  deploy_to.default("current")

  def user
    shell('whoami')
  end

  def dot_profile_path
    File.expand_path("~/.profile")
  end

  def current_path
    path = deploy_to.to_s.gsub(/\/$/, '')
    if path =~ /^\~/
      path = File.expand_path(path)
    end
    path
  end

  met? {
    dot_profile_path.p.grep(/console/)
  }

  meet { render_erb 'profile/dot.profile.erb', :to => dot_profile_path, :sudo => false }
end
Something went wrong with that request. Please try again.