diff options
author | Michael Scherer <misc@mageia.org> | 2011-06-16 00:11:56 +0000 |
---|---|---|
committer | Michael Scherer <misc@mageia.org> | 2011-06-16 00:11:56 +0000 |
commit | 235ac528cb0b5ab00e68a769a01a5951d3d7823a (patch) | |
tree | b74876d2d4fa394643030b67665533e2c474ee68 /modules/postgresql/manifests | |
parent | a7f6af35324c3d30e75d16c636cb8e137f175dbf (diff) | |
download | puppet-235ac528cb0b5ab00e68a769a01a5951d3d7823a.tar puppet-235ac528cb0b5ab00e68a769a01a5951d3d7823a.tar.gz puppet-235ac528cb0b5ab00e68a769a01a5951d3d7823a.tar.bz2 puppet-235ac528cb0b5ab00e68a769a01a5951d3d7823a.tar.xz puppet-235ac528cb0b5ab00e68a769a01a5951d3d7823a.zip |
add a callback system on database creation, so we can then exec a script
to fill the db ( for forum, wiki, and others web application )
Diffstat (limited to 'modules/postgresql/manifests')
-rw-r--r-- | modules/postgresql/manifests/init.pp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/modules/postgresql/manifests/init.pp b/modules/postgresql/manifests/init.pp index 99a68787..5729487c 100644 --- a/modules/postgresql/manifests/init.pp +++ b/modules/postgresql/manifests/init.pp @@ -92,25 +92,36 @@ class postgresql { define remote_db_and_user($description = "", $tag = "default", + $callback_notify = "", $password ) { @@postgresql::db_and_user { $name: + callback_notify => $callback_notify, tag => $tag, description => $description, password => $password } + # fetch the exported ressources that should have been exported + # once the db was created, and trigger a notify to the object passwed as callback_notify + Postgresql::Database_callback <<| name == $name |>> } define remote_database($description = "", - $user = "postgresql", + $user = "postgresql", + $callback_notify = "", $tag = "default") { + + @@postgresql::database { $name: description => $description, user => $user, + callback_notify => $callback_notify, tag => $tag, require => Postgresql::User[$user] } + + Postgresql::Database_callback <<| name == $name |>> } define remote_user($password, @@ -123,9 +134,11 @@ class postgresql { } define db_and_user($description = "", + $callback_notify = "", $password ) { database { $name: + callback_notify => $callback_notify, description => $description, user => $name, } @@ -133,15 +146,32 @@ class postgresql { user { $name: password => $password } + + } + + define database_callback($callback_notify = '') { + # dummy declaration, so we can trigger the notify + exec { "callback $name": + cmd => "true", + notify => $callback_notify, + } } # TODO convert it to a regular type ( so we can later change user and so on ) - define database($description="", $user="postgres") { + define database($description = "", + $user = "postgres", + $callback_notify = "") { exec { "createdb -O $user -U postgres $name '$description'": user => root, unless => "psql -A -t -U postgres -l | grep '^$name|'", require => Service['postgresql'], } + + # this is fetched by the manifest asking the database creation, once the db have been created + # FIXME proper ordering ? + @@postgresql::database_callback { $name: + callback_notify => $callback_notify, + } } # TODO convert to a regular type, so we can later change password without erasing the |