Skip to content

server::database: make user/group/psql_path/default_db configureable #1492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions manifests/server/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,27 @@
# @param locale Overrides the locale during creation of the database.
# @param istemplate Defines the database as a template if set to true.
# @param connect_settings Specifies a hash of environment variables used when connecting to a remote server.
# @param psql_path Specifies the path to the psql command.
# @param default_db Specifies the name of the default database to connect with. On most systems this is 'postgres'.
# @param user Overrides the default PostgreSQL super user and owner of PostgreSQL related files in the file system.
# @param group Overrides the default postgres user group to be used for related files in the file system.
# @param port Specifies the port for the PostgreSQL server to listen on.
define postgresql::server::database (
Optional[String[1]] $comment = undef,
String[1] $dbname = $title,
Optional[String[1]] $owner = undef,
Optional[String[1]] $tablespace = undef,
String[1] $template = 'template0',
Optional[String[1]] $encoding = $postgresql::server::encoding,
Optional[String[1]] $locale = $postgresql::server::locale,
Boolean $istemplate = false,
Hash $connect_settings = $postgresql::server::default_connect_settings,
Optional[String[1]] $comment = undef,
String[1] $dbname = $title,
Optional[String[1]] $owner = undef,
Optional[String[1]] $tablespace = undef,
String[1] $template = 'template0',
Optional[String[1]] $encoding = $postgresql::server::encoding,
Optional[String[1]] $locale = $postgresql::server::locale,
Boolean $istemplate = false,
Hash $connect_settings = $postgresql::server::default_connect_settings,
String[1] $user = $postgresql::server::user,
String[1] $group = $postgresql::server::group,
Stdlib::Absolutepath $psql_path = $postgresql::server::psql_path,
String[1] $default_db = $postgresql::server::default_database,
Stdlib::Port $port = $postgresql::server::port
) {
$user = $postgresql::server::user
$group = $postgresql::server::group
$psql_path = $postgresql::server::psql_path
$default_db = $postgresql::server::default_database

# If possible use the version of the remote database, otherwise
# fallback to our local DB version
if 'DBVERSION' in $connect_settings {
Expand All @@ -35,9 +40,9 @@

# If the connection settings do not contain a port, then use the local server port
if 'PGPORT' in $connect_settings {
$port = undef
$port_override = undef
} else {
$port = $postgresql::server::port
$port_override = $port
}

# Set the defaults for the postgresql_psql resource
Expand All @@ -46,7 +51,7 @@
psql_user => $user,
psql_group => $group,
psql_path => $psql_path,
port => $port,
port => $port_override,
connect_settings => $connect_settings,
}

Expand Down