diff options
Diffstat (limited to 'modules/postgresql/manifests/init.pp')
-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 |