Skip to content

Commit face6c3

Browse files
committed
Replace create_resources for acls with iteration
1 parent ccc440d commit face6c3

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

REFERENCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,15 +846,15 @@ Default value: $postgresql::params::ip_mask_allow_all_users
846846

847847
##### `ipv4acls`
848848

849-
Data type: `Any`
849+
Data type: `Array[String[1]]`
850850

851851
Lists strings for access control for connection method, users, databases, IPv4 addresses;
852852

853853
Default value: $postgresql::params::ipv4acls
854854

855855
##### `ipv6acls`
856856

857-
Data type: `Any`
857+
Data type: `Array[String[1]]`
858858

859859
Lists strings for access control for connection method, users, databases, IPv6 addresses.
860860

manifests/server.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
$port = $postgresql::params::port,
101101
$ip_mask_deny_postgres_user = $postgresql::params::ip_mask_deny_postgres_user,
102102
$ip_mask_allow_all_users = $postgresql::params::ip_mask_allow_all_users,
103-
$ipv4acls = $postgresql::params::ipv4acls,
104-
$ipv6acls = $postgresql::params::ipv6acls,
103+
Array[String[1]] $ipv4acls = $postgresql::params::ipv4acls,
104+
Array[String[1]] $ipv6acls = $postgresql::params::ipv6acls,
105105

106106
$initdb_path = $postgresql::params::initdb_path,
107107
$createdb_path = $postgresql::params::createdb_path,

manifests/server/config.pp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,16 @@
8888
}
8989
}
9090

91-
# ipv4acls are passed as an array of rule strings, here we transform
92-
# them into a resources hash, and pass the result to create_resources
93-
$ipv4acl_resources = postgresql::postgresql_acls_to_resources_hash($ipv4acls,
94-
'ipv4acls', 10)
95-
create_resources('postgresql::server::pg_hba_rule', $ipv4acl_resources)
96-
97-
98-
# ipv6acls are passed as an array of rule strings, here we transform
99-
# them into a resources hash, and pass the result to create_resources
100-
$ipv6acl_resources = postgresql::postgresql_acls_to_resources_hash($ipv6acls,
101-
'ipv6acls', 102)
102-
create_resources('postgresql::server::pg_hba_rule', $ipv6acl_resources)
91+
# $ipv4acls and $ipv6acls are arrays of rule strings
92+
# They are converted into hashes we can iterate over to create postgresql::server::pg_hba_rule resources.
93+
(
94+
postgresql::postgresql_acls_to_resources_hash($ipv4acls, 'ipv4acls', 10) +
95+
postgresql::postgresql_acls_to_resources_hash($ipv6acls, 'ipv6acls', 102)
96+
).each | String $key, Hash $attrs| {
97+
postgresql::server::pg_hba_rule { $key:
98+
* => $attrs,
99+
}
100+
}
103101
}
104102

105103
if $listen_addresses {

0 commit comments

Comments
 (0)