Merge pull request #298 from reidmv/allow_specification_of_default_db_name
Allow specification of default database name
This commit is contained in:
commit
3476828518
6 changed files with 17 additions and 5 deletions
|
@ -292,6 +292,9 @@ This setting can be used to override the default postgresql service provider. If
|
|||
####`service_status`
|
||||
This setting can be used to override the default status check command for your PostgreSQL service. If not specified, the module will use whatever service name is the default for your OS distro.
|
||||
|
||||
####`default_database`
|
||||
This setting is used to specify the name of the default database to connect with. On most systems this will be "postgres".
|
||||
|
||||
####`inidb_path`
|
||||
Path to the `initdb` command.
|
||||
|
||||
|
@ -375,6 +378,9 @@ This setting can be used to override the default postgresql service provider. If
|
|||
####`service_status`
|
||||
This setting can be used to override the default status check command for your PostgreSQL service. If not specified, the module will use whatever service name is the default for your OS distro.
|
||||
|
||||
####`default_database`
|
||||
This setting is used to specify the name of the default database to connect with. On most systems this will be "postgres".
|
||||
|
||||
####`listen_addresses`
|
||||
This value defaults to `localhost`, meaning the postgres server will only accept connections from localhost. If you'd like to be able to connect to postgres from remote machines, you can override this setting. A value of `*` will tell postgres to accept connections from any remote machine. Alternately, you can specify a comma-separated list of hostnames or IP addresses. (For more info, have a look at the `postgresql.conf` file from your system's postgres package).
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ class postgresql::globals (
|
|||
$service_name = undef,
|
||||
$service_provider = undef,
|
||||
$service_status = undef,
|
||||
$default_database = undef,
|
||||
|
||||
$initdb_path = undef,
|
||||
$createdb_path = undef,
|
||||
|
|
|
@ -146,4 +146,5 @@ class postgresql::params inherits postgresql::globals {
|
|||
$pg_hba_conf_path = pick($pg_hba_conf_path, "${confdir}/pg_hba.conf")
|
||||
$pg_hba_conf_defaults = pick($pg_hba_conf_defaults, true)
|
||||
$postgresql_conf_path = pick($postgresql_conf_path, "${confdir}/postgresql.conf")
|
||||
$default_database = pick($default_database, 'postgres')
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ class postgresql::server (
|
|||
$service_name = $postgresql::params::service_name,
|
||||
$service_provider = $postgresql::params::service_provider,
|
||||
$service_status = $postgresql::params::service_status,
|
||||
$default_database = $postgresql::params::default_database,
|
||||
|
||||
$listen_addresses = $postgresql::params::listen_addresses,
|
||||
$ip_mask_deny_postgres_user = $postgresql::params::ip_mask_deny_postgres_user,
|
||||
|
|
|
@ -5,6 +5,7 @@ class postgresql::server::service {
|
|||
$service_provider = $postgresql::server::service_provider
|
||||
$service_status = $postgresql::server::service_status
|
||||
$user = $postgresql::server::user
|
||||
$default_database = $postgresql::server::default_database
|
||||
|
||||
$service_ensure = $ensure ? {
|
||||
present => true,
|
||||
|
@ -29,6 +30,7 @@ class postgresql::server::service {
|
|||
# prepared leading to a nasty race condition.
|
||||
postgresql::validate_db_connection { 'validate_service_is_running':
|
||||
run_as => $user,
|
||||
database_name => $default_database,
|
||||
sleep => 1,
|
||||
tries => 60,
|
||||
create_db_first => false,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# See README.md for more details.
|
||||
define postgresql::validate_db_connection(
|
||||
$database_host = undef,
|
||||
$database_name = 'postgres',
|
||||
$database_name = undef,
|
||||
$database_password = undef,
|
||||
$database_username = undef,
|
||||
$database_port = undef,
|
||||
|
@ -15,25 +15,26 @@ define postgresql::validate_db_connection(
|
|||
$create_db_first = true
|
||||
) {
|
||||
require postgresql::client
|
||||
include postgresql::params
|
||||
|
||||
$psql_path = $postgresql::params::psql_path
|
||||
|
||||
$cmd_init = "${psql_path} --tuples-only --quiet "
|
||||
$cmd_host = $database_host ? {
|
||||
default => "-h ${database_host} ",
|
||||
undef => ""
|
||||
undef => "",
|
||||
}
|
||||
$cmd_user = $database_username ? {
|
||||
default => "-U ${database_username} ",
|
||||
undef => ""
|
||||
undef => "",
|
||||
}
|
||||
$cmd_port = $database_port ? {
|
||||
default => "-p ${database_port} ",
|
||||
undef => ""
|
||||
undef => "",
|
||||
}
|
||||
$cmd_dbname = $database_name ? {
|
||||
default => "--dbname ${database_name} ",
|
||||
undef => ""
|
||||
undef => "--dbname ${postgresql::params::default_database} ",
|
||||
}
|
||||
$env = $database_password ? {
|
||||
default => "PGPASSWORD=${database_password}",
|
||||
|
|
Loading…
Reference in a new issue