I'm trying to import a SQL file into a postgresql DB I have created with puppetlab's postgresql module. My only issue (so far) is that I can't import a SQL file into the DB I've created:
# This is the database creation profile
class profiles::create_db {
# Install postgresql and configure access
class { 'postgresql::server':
listen_addresses => '127.0.0.1',
postgres_password => postgresql_password('postgres', 'secureFTW'),
}
# This creates the actual DB, user, sets password for that user and permissions
postgresql::server::db { "${::creationkey}":
user => 'user',
password => postgresql_password('user', 'secureFTW'),
}
postgresql_psql { 'create_postgresql':
command => '-f /opt/data/postgresql/create_postgresql.sql',
db => $::creationkey,
psql_user => 'user',
# unless => 'psql QUERY to check if this was run already once',
}
}
I get the following error:
Debug: Executing 'psql -d app_key -t -c "-f /opt/data/postgresql/create_postgresql.sql"'
Error: Error executing SQL; psql returned pid 9590 exit 1: ''
Error: /Stage[main]/Profiles::Create_db/Postgresql_psql[create_postgresql]/command: change from notrun to -f /opt/data/postgresql/create_postgresql.sql failed: Error executing SQL; psql returned pid 9590 exit 1: ''I have tried a few variations of the command but they all fail. Looking at the psql examples and all the error messages I get on this, I think the problem is the module surrounds my command in doublequotes when it tries to execute it. The SQL file is located in that path and file permissions are not an issue.
Anyone has been able to import a SQL file via this resource
postgreslq_psql?
-Cheers