Add a - between the su and postgres so that we inherit the Postgres user's environment and don't try to run the command with /root as the working directory.

This commit is contained in:
Nick Chappell 2014-08-24 12:25:06 -07:00
parent f9f7cc5ad9
commit cb477311a9

View file

@ -134,7 +134,7 @@ class icinga2::server::install::execs inherits icinga2::server {
exec { 'postgres_schema_load':
user => 'root',
path => '/usr/bin:/usr/sbin:/bin/:/sbin',
command => "su postgres -c 'export PGPASSWORD='${db_password}' && psql -U ${db_user} -h localhost -d ${db_name} < ${server_db_schema_path}' && export PGPASSWORD='' && touch /etc/icinga2/postgres_schema_loaded.txt",
command => "su - postgres -c 'export PGPASSWORD='${db_password}' && psql -U ${db_user} -h localhost -d ${db_name} < ${server_db_schema_path}' && export PGPASSWORD='' && touch /etc/icinga2/postgres_schema_loaded.txt",
creates => "/etc/icinga2/postgres_schema_loaded.txt",
require => Class['icinga2::server::install::packages'],
}