Skip to content

Commit 3233f34

Browse files
committed
Fix port for extension
1 parent 94bb086 commit 3233f34

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

manifests/server/extension.pp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
# version may be set to a specific version, in which case the extension is updated using ALTER EXTENSION "extension" UPDATE TO 'version'
1010
# eg. If extension is set to postgis and version is set to 2.3.3, this will apply the SQL ALTER EXTENSION "postgis" UPDATE TO '2.3.3' to this database only.
1111
# version may be omitted, in which case no ALTER EXTENSION... SQL is applied, and the version will be left unchanged.
12-
#
12+
#
1313
# @param ensure Specifies whether to activate or deactivate the extension. Valid options: 'present' or 'absent'.
1414
# @param package_name Specifies a package to install prior to activating the extension.
1515
# @param package_ensure Overrides default package deletion behavior. By default, the package specified with package_name is installed when the extension is activated and removed when the extension is deactivated. To override this behavior, set the ensure value for the package.
16+
# @param port Port to use when connecting.
1617
# @param connect_settings Specifies a hash of environment variables used when connecting to a remote server.
1718
# @param database_resource_name Specifies the resource name of the DB being managed. Defaults to the parameter $database, if left blank.
1819
define postgresql::server::extension (
@@ -23,6 +24,7 @@
2324
String[1] $ensure = 'present',
2425
$package_name = undef,
2526
$package_ensure = undef,
27+
$port = undef,
2628
$connect_settings = postgresql::default('default_connect_settings'),
2729
$database_resource_name = $database,
2830
) {
@@ -57,6 +59,17 @@
5759
}
5860
}
5961

62+
#
63+
# Port, order of precedence: $port parameter, $connect_settings[PGPORT], $postgresql::server::port
64+
#
65+
if $port != undef {
66+
$port_override = $port
67+
} elsif $connect_settings != undef and has_key( $connect_settings, 'PGPORT') {
68+
$port_override = undef
69+
} else {
70+
$port_override = $postgresql::server::port
71+
}
72+
6073
postgresql_psql { "${database}: ${command}":
6174

6275
psql_user => $user,
@@ -65,6 +78,7 @@
6578
connect_settings => $connect_settings,
6679

6780
db => $database,
81+
port => $port_override,
6882
command => $command,
6983
unless => "SELECT 1 WHERE ${unless_mod}EXISTS (SELECT 1 FROM pg_extension WHERE extname = '${extension}')",
7084
}
@@ -90,6 +104,7 @@
90104
psql_path => $psql_path,
91105
connect_settings => $connect_settings,
92106
db => $database,
107+
port => $port_override,
93108
require => Postgresql_psql["${database}: ${command}"],
94109
}
95110

@@ -119,6 +134,7 @@
119134
}
120135
postgresql_psql { "${database}: ${alter_extension_sql}":
121136
db => $database,
137+
port => $port_override,
122138
psql_user => $user,
123139
psql_group => $group,
124140
psql_path => $psql_path,

0 commit comments

Comments
 (0)