/[adm]/puppet/modules/postgresql/manifests/init.pp
ViewVC logotype

Diff of /puppet/modules/postgresql/manifests/init.pp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1534 by misc, Tue Apr 19 11:05:20 2011 UTC revision 1744 by misc, Thu Jun 16 00:11:56 2011 UTC
# Line 92  class postgresql { Line 92  class postgresql {
92    
93      define remote_db_and_user($description = "",      define remote_db_and_user($description = "",
94                                $tag = "default",                                $tag = "default",
95                                  $callback_notify = "",
96                                $password ) {                                $password ) {
97    
98          @@postgresql::db_and_user { $name:          @@postgresql::db_and_user { $name:
99                                        callback_notify => $callback_notify,
100                                      tag => $tag,                                      tag => $tag,
101                                      description => $description,                                      description => $description,
102                                      password => $password                                      password => $password
103          }          }
104            # fetch the exported ressources that should have been exported
105            # once the db was created, and trigger a notify to the object passwed as callback_notify
106            Postgresql::Database_callback <<| name == $name |>>
107      }      }
108    
109      define remote_database($description = "",      define remote_database($description = "",
110                             $user = "postgresql",                             $user = "postgresql",
111                               $callback_notify = "",
112                             $tag = "default")                             $tag = "default")
113      {      {
114    
115            
116          @@postgresql::database { $name:          @@postgresql::database { $name:
117              description => $description,              description => $description,
118              user => $user,              user => $user,
119                callback_notify => $callback_notify,
120              tag => $tag,              tag => $tag,
121              require => Postgresql::User[$user]              require => Postgresql::User[$user]
122          }          }
123    
124            Postgresql::Database_callback <<| name == $name |>>
125      }      }
126    
127      define remote_user($password,      define remote_user($password,
# Line 123  class postgresql { Line 134  class postgresql {
134      }      }
135    
136      define db_and_user($description = "",      define db_and_user($description = "",
137                           $callback_notify = "",
138                         $password ) {                         $password ) {
139    
140          database { $name:          database { $name:
141                       callback_notify => $callback_notify,
142                     description => $description,                     description => $description,
143                     user => $name,                     user => $name,
144          }          }
# Line 133  class postgresql { Line 146  class postgresql {
146          user { $name:          user { $name:
147                 password => $password                 password => $password
148          }          }
149            
150        }
151    
152        define database_callback($callback_notify = '') {
153            # dummy declaration, so we can trigger the notify
154            exec { "callback $name":
155                cmd => "true",
156                notify => $callback_notify,
157            }
158      }      }
159    
160      # TODO convert it to a regular type ( so we can later change user and so on )      # TODO convert it to a regular type ( so we can later change user and so on )
161      define database($description="", $user="postgres") {      define database($description = "",
162                        $user = "postgres",
163                        $callback_notify = "") {
164          exec { "createdb -O $user -U postgres $name '$description'":          exec { "createdb -O $user -U postgres $name '$description'":
165              user => root,              user => root,
166              unless => "psql -A -t -U postgres -l | grep '^$name|'",              unless => "psql -A -t -U postgres -l | grep '^$name|'",
167              require => Service['postgresql'],              require => Service['postgresql'],
168          }          }
169    
170            # this is fetched by the manifest asking the database creation, once the db have been created
171            # FIXME proper ordering ?
172            @@postgresql::database_callback { $name:
173                callback_notify => $callback_notify,
174            }
175      }      }
176            
177      # TODO convert to a regular type, so we can later change password without erasing the      # TODO convert to a regular type, so we can later change password without erasing the

Legend:
Removed from v.1534  
changed lines
  Added in v.1744

  ViewVC Help
Powered by ViewVC 1.1.30