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 
<https://forge.puppetlabs.com/puppetlabs/postgresql#custom-resource-postgresql_psql>
?

-Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/2acf951c-3359-434a-9566-49a59f3c1783%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to