|
103 | 103 | # @param grants Specifies a hash from which to generate postgresql::server::grant resources. |
104 | 104 | # @param config_entries Specifies a hash from which to generate postgresql::server::config_entry resources. |
105 | 105 | # @param pg_hba_rules Specifies a hash from which to generate postgresql::server::pg_hba_rule resources. |
| 106 | +# @param extensions Specifies a hash from which to generate postgresql::server::extension resources. |
| 107 | +# The hash keys are database names, and the values are hashes of extension names to extension parameters. |
106 | 108 | # |
107 | 109 | # @param backup_enable Whether a backup job should be enabled. |
108 | 110 | # @param backup_options A hash of options that should be passed through to the backup provider. |
|
189 | 191 | Hash[String[1], Hash] $grants = {}, |
190 | 192 | Hash[String, Any] $config_entries = {}, |
191 | 193 | Postgresql::Pg_hba_rules $pg_hba_rules = {}, |
| 194 | + Hash[String, Hash] $extensions = {}, |
192 | 195 |
|
193 | 196 | Boolean $backup_enable = $postgresql::params::backup_enable, |
194 | 197 | Hash $backup_options = {}, |
|
238 | 241 | } |
239 | 242 | } |
240 | 243 |
|
| 244 | + # Create databases first if not already defined |
| 245 | + $extensions.each |$database, $extensions_hash| { |
| 246 | + if $database != 'postgres' and ! defined(Postgresql::Server::Database[$database]) { |
| 247 | + # The database resource doesn't exist, create it |
| 248 | + postgresql::server::database { $database: |
| 249 | + dbname => $database, |
| 250 | + } |
| 251 | + } |
| 252 | + } |
| 253 | + |
| 254 | + $extensions.each |$database, $extensions_hash| { |
| 255 | + $extensions_hash.each |$extension_name, $extension_params| { |
| 256 | + postgresql::server::extension { "${database}:${extension_name}": |
| 257 | + database => $database, |
| 258 | + * => $extension_params, |
| 259 | + } |
| 260 | + } |
| 261 | + } |
| 262 | + |
| 263 | + |
241 | 264 | if $backup_enable { |
242 | 265 | case $backup_provider { |
243 | 266 | 'pg_dump': { |
|
0 commit comments