Ask Your Question
0

postgresql template

asked 2015-10-08 17:41:44 -0500

tim.eapen gravatar image

I am using the puppet/postgresql module to install, configure and create my postgresql databases.

I am installing the contrib package and would like to enable the "uuid-ossp" extension. The catch for me is I would like to enable this extension in the 'template1' database. I would then use the 'template1' db as the source for all dbs that I create.

I couldn't find any hooks in this module to help me modify the 'template1' db. Is this possible?

I know that if I have a postgresql install already I can do the following:

psql -d template1 -c 'create extension "uuid-ossp";'
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-10-09 19:43:52 -0500

lupin gravatar image

Hi,

Here's a stuff that seems to work.

class { '::postgresql::server': }

postgresql::server::db { 'template2':
  istemplate => 'true',
  user       => 'templateuser',
  password   => 'templatepass',
} -> 

postgresql::server::extension { 'uuid-ossp':
  ensure   => 'present',
  database => 'template2',
  package_name => 'postgresql-contrib',
} -> 

postgresql::server::db { 'deriveddb':
  user       => 'templateuser',
  password   => 'templatepass',
  template   => 'template2',
}

Probably there's stuff that can be tweak to make 'template1' usable.

Lupin

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-10-08 17:41:44 -0500

Seen: 260 times

Last updated: Oct 09 '15