|
| 1 | +# lint:ignore:140chars |
| 2 | +# @param instace_name |
| 3 | +# @param initdb_settings |
| 4 | +# @param config_settings |
| 5 | +# @param service_settings |
| 6 | +# @param passwd_settings |
| 7 | +# @param roles Specifies a hash from which to generate postgresql::server::role resources. |
| 8 | +# @param config_entries Specifies a hash from which to generate postgresql::server::config_entry resources. |
| 9 | +# @param pg_hba_rules Specifies a hash from which to generate postgresql::server::pg_hba_rule resources. |
| 10 | + |
| 11 | +# lint:endignore:140chars |
| 12 | +define postgresql::server_instance ( |
| 13 | + String $instace_name = $name, |
| 14 | + Hash $initdb_settings = {}, |
| 15 | + Hash $config_settings = {}, |
| 16 | + Hash $service_settings = {}, |
| 17 | + Hash $passwd_settings = {}, |
| 18 | + Hash $roles = {}, |
| 19 | + Hash $config_entries = {}, |
| 20 | + Hash $pg_hba_rules = {}, |
| 21 | +) { |
| 22 | + postgresql::server::instance::initdb { $instace_name: |
| 23 | + * => $initdb_settings, |
| 24 | + } |
| 25 | + postgresql::server::instance::config { $instace_name: |
| 26 | + * => $config_settings, |
| 27 | + } |
| 28 | + postgresql::server::instance::service { $instace_name: |
| 29 | + * => $service_settings, |
| 30 | + } |
| 31 | + postgresql::server::instance::passwd { $instace_name: |
| 32 | + * => $passwd_settings, |
| 33 | + } |
| 34 | + |
| 35 | + $roles.each |$rolename, $role| { |
| 36 | + postgresql::server::role { $rolename: |
| 37 | + * => $role, |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + $config_entries.each |$entry, $value| { |
| 42 | + postgresql::server::config_entry { $entry: |
| 43 | + ensure => bool2str($value =~ Undef, 'absent', 'present'), |
| 44 | + value => $value, |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + $pg_hba_rules.each |String[1] $rule_name, Postgresql::Pg_hba_rule $rule| { |
| 49 | + postgresql::server::pg_hba_rule { $rule_name: |
| 50 | + * => $rule, |
| 51 | + } |
| 52 | + } |
| 53 | +} |
0 commit comments