From 1b7307458f47b04d46371c243766da2e0a9d3ea0 Mon Sep 17 00:00:00 2001 From: Mark Haylock Date: Mon, 5 Jan 2015 13:08:32 +1300 Subject: [PATCH] Update 3.x to run db commands from the right dir --- manifests/db.pp | 4 ++-- manifests/init.pp | 1 + manifests/params.pp | 4 +++- manifests/service.pp | 3 ++- spec/defines/postgresql_db_spec.rb | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/manifests/db.pp b/manifests/db.pp index 7d50dda..92df3ad 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -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}'" } } diff --git a/manifests/init.pp b/manifests/init.pp index ee98195..15cea68 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -6,6 +6,7 @@ class postgresql( $ensure = $postgresql::params::ensure, + $bindir = $postgresql::params::bindir, $executable = $postgresql::params::executable, $host = $postgresql::params::host, diff --git a/manifests/params.pp b/manifests/params.pp index 6ef345a..8d48e13 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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 @@ -20,6 +21,7 @@ Ubuntu: { $executable = undef # only used on Darwin + $bindir = '/usr/bin' $datadir = '/var/lib/postgresql' $logdir = '/var/log/postgresql' $port = 5432 diff --git a/manifests/service.pp b/manifests/service.pp index 24b9a5b..0831868 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -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, @@ -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", } diff --git a/spec/defines/postgresql_db_spec.rb b/spec/defines/postgresql_db_spec.rb index 4ba016b..f3bc735 100644 --- a/spec/defines/postgresql_db_spec.rb +++ b/spec/defines/postgresql_db_spec.rb @@ -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