Skip to content

Commit 6e44c27

Browse files
jordanbreen28vaol
jordanbreen28
authored andcommitted
(CONT-950) - Array of $listen_addresses
This commit adds functionality to allow an array of $listen_addresses to be specified as a string containing a comma-seperated list of addresses, which was removed unintentioanlly in puppetlabs#1397. Fixes puppetlabs#1426.
1 parent 8f0a50c commit 6e44c27

File tree

4 files changed

+38
-29
lines changed

4 files changed

+38
-29
lines changed

lib/puppet/provider/postgresql_conf/parsed.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# simple string and numeric values don't need to be enclosed in quotes
2222
val = if h[:value].is_a?(Numeric)
2323
h[:value].to_s
24+
elsif h[:value].is_a?(Array)
25+
# multiple listen_addresses specified as a string containing a comma-speparated list
26+
h[:value].join(', ')
2427
else
2528
h[:value]
2629
end

manifests/server.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
Optional[String[1]] $service_status = $postgresql::params::service_status,
108108
String[1] $default_database = $postgresql::params::default_database,
109109
Hash $default_connect_settings = $postgresql::globals::default_connect_settings,
110-
Optional[String[1]] $listen_addresses = $postgresql::params::listen_addresses,
110+
Optional[Variant[String[1], Array[String[1]]]] $listen_addresses = $postgresql::params::listen_addresses,
111111
Variant[String[1], Stdlib::Port, Integer] $port = $postgresql::params::port,
112112
String[1] $ip_mask_deny_postgres_user = $postgresql::params::ip_mask_deny_postgres_user,
113113
String[1] $ip_mask_allow_all_users = $postgresql::params::ip_mask_allow_all_users,

manifests/server/instance/config.pp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,33 @@
3535
# @param extra_systemd_config Adds extra config to systemd config file, can for instance be used to add extra openfiles. This can be a multi line string
3636
# lint:endignore:140chars
3737
define postgresql::server::instance::config (
38-
String[1] $ip_mask_deny_postgres_user = $postgresql::server::ip_mask_deny_postgres_user,
39-
String[1] $ip_mask_allow_all_users = $postgresql::server::ip_mask_allow_all_users,
40-
Optional[String[1]] $listen_addresses = $postgresql::server::listen_addresses,
41-
Variant[String[1], Stdlib::Port, Integer] $port = $postgresql::server::port,
42-
Array[String[1]] $ipv4acls = $postgresql::server::ipv4acls,
43-
Array[String[1]] $ipv6acls = $postgresql::server::ipv6acls,
44-
Variant[String[1], Stdlib::Absolutepath] $pg_hba_conf_path = $postgresql::server::pg_hba_conf_path,
45-
Variant[String[1], Stdlib::Absolutepath] $pg_ident_conf_path = $postgresql::server::pg_ident_conf_path,
46-
Variant[String[1], Stdlib::Absolutepath] $postgresql_conf_path = $postgresql::server::postgresql_conf_path,
47-
Optional[Stdlib::Filemode] $postgresql_conf_mode = $postgresql::server::postgresql_conf_mode,
48-
Variant[String[1], Stdlib::Absolutepath] $recovery_conf_path = $postgresql::server::recovery_conf_path,
49-
Boolean $pg_hba_conf_defaults = $postgresql::server::pg_hba_conf_defaults,
50-
String[1] $user = $postgresql::server::user,
51-
String[1] $group = $postgresql::server::group,
52-
Optional[String[1]] $version = $postgresql::server::_version,
53-
Boolean $manage_pg_hba_conf = $postgresql::server::manage_pg_hba_conf,
54-
Boolean $manage_pg_ident_conf = $postgresql::server::manage_pg_ident_conf,
55-
Boolean $manage_recovery_conf = $postgresql::server::manage_recovery_conf,
56-
Boolean $manage_postgresql_conf_perms = $postgresql::server::manage_postgresql_conf_perms,
57-
String[1] $datadir = $postgresql::server::datadir,
58-
Optional[String[1]] $logdir = $postgresql::server::logdir,
59-
String[1] $service_name = $postgresql::server::service_name,
60-
Boolean $service_enable = $postgresql::server::service_enable,
61-
Optional[String[1]] $log_line_prefix = $postgresql::server::log_line_prefix,
62-
Optional[String[1]] $timezone = $postgresql::server::timezone,
63-
Optional[String] $password_encryption = $postgresql::server::password_encryption,
64-
Optional[String] $extra_systemd_config = $postgresql::server::extra_systemd_config,
38+
String[1] $ip_mask_deny_postgres_user = $postgresql::server::ip_mask_deny_postgres_user,
39+
String[1] $ip_mask_allow_all_users = $postgresql::server::ip_mask_allow_all_users,
40+
Optional[Variant[String[1], Array[String[1]]]] $listen_addresses = $postgresql::server::listen_addresses,
41+
Variant[String[1], Stdlib::Port, Integer] $port = $postgresql::server::port,
42+
Array[String[1]] $ipv4acls = $postgresql::server::ipv4acls,
43+
Array[String[1]] $ipv6acls = $postgresql::server::ipv6acls,
44+
Variant[String[1], Stdlib::Absolutepath] $pg_hba_conf_path = $postgresql::server::pg_hba_conf_path,
45+
Variant[String[1], Stdlib::Absolutepath] $pg_ident_conf_path = $postgresql::server::pg_ident_conf_path,
46+
Variant[String[1], Stdlib::Absolutepath] $postgresql_conf_path = $postgresql::server::postgresql_conf_path,
47+
Optional[Stdlib::Filemode] $postgresql_conf_mode = $postgresql::server::postgresql_conf_mode,
48+
Variant[String[1], Stdlib::Absolutepath] $recovery_conf_path = $postgresql::server::recovery_conf_path,
49+
Boolean $pg_hba_conf_defaults = $postgresql::server::pg_hba_conf_defaults,
50+
String[1] $user = $postgresql::server::user,
51+
String[1] $group = $postgresql::server::group,
52+
Optional[String[1]] $version = $postgresql::server::_version,
53+
Boolean $manage_pg_hba_conf = $postgresql::server::manage_pg_hba_conf,
54+
Boolean $manage_pg_ident_conf = $postgresql::server::manage_pg_ident_conf,
55+
Boolean $manage_recovery_conf = $postgresql::server::manage_recovery_conf,
56+
Boolean $manage_postgresql_conf_perms = $postgresql::server::manage_postgresql_conf_perms,
57+
String[1] $datadir = $postgresql::server::datadir,
58+
Optional[String[1]] $logdir = $postgresql::server::logdir,
59+
String[1] $service_name = $postgresql::server::service_name,
60+
Boolean $service_enable = $postgresql::server::service_enable,
61+
Optional[String[1]] $log_line_prefix = $postgresql::server::log_line_prefix,
62+
Optional[String[1]] $timezone = $postgresql::server::timezone,
63+
Optional[String] $password_encryption = $postgresql::server::password_encryption,
64+
Optional[String] $extra_systemd_config = $postgresql::server::extra_systemd_config,
6565
) {
6666
if ($manage_pg_hba_conf == true) {
6767
# Prepare the main pg_hba file

spec/unit/provider/postgresql_conf/parsed_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,16 @@
136136
)
137137
end
138138

139-
it 'quotes addresses' do
139+
it 'quotes single string address' do
140140
expect(provider.to_line(name: 'listen_addresses', value: '0.0.0.0', comment: nil, record_type: :parsed)).to eq(
141141
"listen_addresses = '0.0.0.0'",
142142
)
143143
end
144+
145+
it 'quotes an array of addresses' do
146+
expect(provider.to_line(name: 'listen_addresses', value: ['0.0.0.0', '127.0.0.1'], comment: nil, record_type: :parsed)).to eq(
147+
"listen_addresses = '0.0.0.0, 127.0.0.1'",
148+
)
149+
end
144150
end
145151
end

0 commit comments

Comments
 (0)