Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #36 from mhaylock/fix_3x_db_commands_for_nonstanda…
Browse files Browse the repository at this point in the history
…rd_homebrew_location

Update 3.x to run db commands from the right dir
  • Loading branch information
dgoodlad committed Jan 6, 2015
2 parents 79d49db + 1b73074 commit 78ee719
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions manifests/db.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

exec { "postgresql-db-${name}":
command => join([
'createdb',
"${postgresql::bindir}/createdb",
"-p${postgresql::port}",
'-E UTF-8',
"-O ${postgresql::user}",
$name
], ' '),
unless => "psql -aA -p${postgresql::port} -t -l | cut -d \\| -f 1 | grep -w '${name}'"
unless => "${postgresql::bindir}/psql -aA -p${postgresql::port} -t -l | cut -d \\| -f 1 | grep -w '${name}'"
}
}
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class postgresql(
$ensure = $postgresql::params::ensure,

$bindir = $postgresql::params::bindir,
$executable = $postgresql::params::executable,

$host = $postgresql::params::host,
Expand Down
4 changes: 3 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Darwin: {
include boxen::config

$executable = "${boxen::config::homebrewdir}/bin/postgres"
$bindir = "${boxen::config::homebrewdir}/bin"
$executable = "${bindir}/postgres"
$datadir = "${boxen::config::datadir}/postgresql-9.3"
$logdir = "${boxen::config::logdir}/postgresql-9.3"
$port = 15432
Expand All @@ -20,6 +21,7 @@

Ubuntu: {
$executable = undef # only used on Darwin
$bindir = '/usr/bin'
$datadir = '/var/lib/postgresql'
$logdir = '/var/log/postgresql'
$port = 5432
Expand Down
3 changes: 2 additions & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$service = $postgresql::params::service,
$enable = $postgresql::params::enable,

$bindir = $postgresql::params::bindir,
$datadir = $postgresql::params::datadir,
$host = $postgresql::params::host,
$port = $postgresql::params::port,
Expand All @@ -27,7 +28,7 @@
}

exec { 'init-postgresql-db':
command => "initdb -E UTF-8 ${datadir}",
command => "${bindir}/initdb -E UTF-8 ${datadir}",
creates => "${datadir}/PG_VERSION",
}

Expand Down
4 changes: 2 additions & 2 deletions spec/defines/postgresql_db_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
should include_class("postgresql")

should contain_exec("postgresql-db-#{title}").with({
:command => "createdb -p15432 -E UTF-8 -O testuser #{title}",
:unless => "psql -aA -p15432 -t -l | cut -d \\| -f 1 | grep -w '#{title}'"
:command => "/test/boxen/homebrew/bin/createdb -p15432 -E UTF-8 -O testuser #{title}",
:unless => "/test/boxen/homebrew/bin/psql -aA -p15432 -t -l | cut -d \\| -f 1 | grep -w '#{title}'"
})
end
end

0 comments on commit 78ee719

Please sign in to comment.