Class: Escualo::Plugin::Postgre

Inherits:
Object
  • Object
show all
Defined in:
lib/escualo/plugin/postgre.rb

Instance Method Summary collapse

Instance Method Details

#check(ssh, options) ⇒ Object



19
20
21
# File 'lib/escualo/plugin/postgre.rb', line 19

def check(ssh, options)
  ssh.shell.exec!('psql --version').include? "psql (PostgreSQL) #{options.pg_version}"
end

#run(ssh, options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/escualo/plugin/postgre.rb', line 3

def run(ssh, options)
  pg_hba_conf = "/etc/postgresql/#{options.pg_version}/main/pg_hba.conf"

  ssh.shell.perform! %Q{
    apt-get install postgresql libpq-dev -y &&
    echo 'local   all             postgres                                peer' > #{pg_hba_conf} &&
    echo 'local   all             postgres                                peer' >> #{pg_hba_conf} &&
    echo 'local   all             all                                     password' >> #{pg_hba_conf} &&
    echo 'host    all             all             127.0.0.1/32            md5' >> #{pg_hba_conf} &&
    cd / &&
    sudo -u postgres PGDATABASE='' psql <<EOF
    create role $POSTGRESQL_DB_USERNAME with createdb login password '$POSTGRESQL_DB_PASSWORD';
EOF
  }, options
end