Skip to content

postgresql_access Resource fails when multiple databases or users are specified #750

@schrd

Description

@schrd

👻 Brief Description

pg_hba.conf specification allows to use multiple users and databases in one line, separated by commas. It fails in the second converge when these are specified in a postgresql_access resource.

🥞 Cookbook version

11.5.1

👩‍🍳 Chef-Infra Version

17.10

🎩 Platform details

Debian 11

Steps To Reproduce

Add the following code to the recipe:

postgresql_access 'access with multiple databases' do                           
  type 'host'                                                                   
  database 'foo,bar'                                                            
  user 'john,doe'                                                               
  address '127.0.0.1/32'                                                        
  auth_method 'peer'                                                            
end                                                                                                                                                                                                            

It produces in the first converge the following valid output:

host    foo,bar                         john,doe                        127.0.0.1/32            peer

In the second converge it fails with the following error:

         NoMethodError
         -------------
         undefined method `named_captures' for nil:NilClass
         
         Cookbook Trace: (most recent call first)
         ----------------------------------------
         /opt/kitchen/cache/cookbooks/postgresql/libraries/access.rb:155:in `block in split_entries'
         /opt/kitchen/cache/cookbooks/postgresql/libraries/access.rb:155:in `map!'
         /opt/kitchen/cache/cookbooks/postgresql/libraries/access.rb:155:in `split_entries'
         /opt/kitchen/cache/cookbooks/postgresql/libraries/access.rb:89:in `read!'
         /opt/kitchen/cache/cookbooks/postgresql/libraries/access.rb:139:in `read'
         /opt/kitchen/cache/cookbooks/postgresql/resources/access.rb:66:in `block in class_from_file'

🚓 Expected behavior

postgresql_access resource should accept all valid pg_hba.conf options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions