Skip to content

Commit 635fb50

Browse files
author
Daniel Schreiber
committed
Fix: allow multiple users/databases in postgresql_access resources
PostgreSQL pg_hba.conf allows to specify multiple databases and users in one entry. They are seperated by comma.
1 parent 20c1693 commit 635fb50

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This file is used to list changes made in the last 3 major versions of the postg
44

55
## Unreleased
66

7+
- Allow to configure multiple databases and users in one `pg_hba.conf` entry
8+
79
## 11.5.1 - *2023-06-26*
810

911
- Fix typo in documentation of `postgresql_extension` resource

libraries/access.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class PgHbaFile
7070

7171
attr_reader :entries
7272

73-
SPLIT_REGEX = %r{^(((?<type>local)\s+(?<database>[\w\-_]+)\s+(?<user>[\w\d\-_.$]+))|((?!local)(?<type>\w+)\s+(?<database>[\w\-_]+)\s+(?<user>[\w\d\-_.$]+)\s+(?<address>[\w\-.:\/]+)))\s+(?<auth_method>[\w-]+)(?<auth_options>(?:\s+#{AUTH_OPTION_REGEX})*)(?:\s*)(?<comment>#\s*.*)?$}.freeze
73+
SPLIT_REGEX = %r{^(((?<type>local)\s+(?<database>[\w\-_,]+)\s+(?<user>[\w\d\-_.$,]+))|((?!local)(?<type>\w+)\s+(?<database>[\w\-_,]+)\s+(?<user>[\w\d\-_.$,]+)\s+(?<address>[\w\-.:\/]+)))\s+(?<auth_method>[\w-]+)(?<auth_options>(?:\s+#{AUTH_OPTION_REGEX})*)(?:\s*)(?<comment>#\s*.*)?$}.freeze
7474
private_constant :SPLIT_REGEX
7575

7676
def initialize

test/cookbooks/test/recipes/access.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,11 @@
128128
ldapbasedn: '"dc=example, dc=net"',
129129
ldapsearchattribute: 'uid'
130130
end
131+
132+
postgresql_access 'access with multiple databases' do
133+
type 'host'
134+
database 'foo,bar'
135+
user 'john,doe'
136+
address '127.0.0.1/32'
137+
auth_method 'md5'
138+
end

0 commit comments

Comments
 (0)