From c8e64a1e09409a49d6ba360d0bfa90eeaf1c0e99 Mon Sep 17 00:00:00 2001 From: Simon Hoenscheid Date: Wed, 21 Jun 2023 17:38:30 +0200 Subject: [PATCH] inirial server instance define --- manifests/server_instance.pp | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 manifests/server_instance.pp diff --git a/manifests/server_instance.pp b/manifests/server_instance.pp new file mode 100644 index 0000000000..f173083662 --- /dev/null +++ b/manifests/server_instance.pp @@ -0,0 +1,53 @@ +# lint:ignore:140chars +# @param instace_name +# @param initdb_settings +# @param config_settings +# @param service_settings +# @param passwd_settings +# @param roles Specifies a hash from which to generate postgresql::server::role resources. +# @param config_entries Specifies a hash from which to generate postgresql::server::config_entry resources. +# @param pg_hba_rules Specifies a hash from which to generate postgresql::server::pg_hba_rule resources. + +# lint:endignore:140chars +define postgresql::server_instance ( + String $instace_name = $name, + Hash $initdb_settings = {}, + Hash $config_settings = {}, + Hash $service_settings = {}, + Hash $passwd_settings = {}, + Hash $roles = {}, + Hash $config_entries = {}, + Hash $pg_hba_rules = {}, +) { + postgresql::server::instance::initdb { $instace_name: + * => $initdb_settings, + } + postgresql::server::instance::config { $instace_name: + * => $config_settings, + } + postgresql::server::instance::service { $instace_name: + * => $service_settings, + } + postgresql::server::instance::passwd { $instace_name: + * => $passwd_settings, + } + + $roles.each |$rolename, $role| { + postgresql::server::role { $rolename: + * => $role, + } + } + + $config_entries.each |$entry, $value| { + postgresql::server::config_entry { $entry: + ensure => bool2str($value =~ Undef, 'absent', 'present'), + value => $value, + } + } + + $pg_hba_rules.each |String[1] $rule_name, Postgresql::Pg_hba_rule $rule| { + postgresql::server::pg_hba_rule { $rule_name: + * => $rule, + } + } +}