postgresql_lwrp icon indicating copy to clipboard operation
postgresql_lwrp copied to clipboard

Server hba_configuration not overwritable

Open j15e opened this issue 5 years ago • 1 comments

The README states :

Server attributes are starting from ["postgresql"]["defaults"] and used as default attributes for postgresql provider. You should not override this defaults, you can pass your settings to provider instead.

Okay fine for config flags - but I think there is a problem with the hba configurations if we follow that thinking. We can't overwrite defaults hba permissions the recipe provide.

The hba_configuration configuration is merged with the defaults, not overwritten :

https://github.com/express42/postgresql_lwrp/blob/6b8d583d668caf42d7f96bb0cdbcb7bcb43cf49f/resources/default.rb#L53-L54

So you can't actually remove or replace any of the defaults entries from pg_hba.conf. I think theses configurations setup should be a || not | with the resource specific config.

In the examples where it looks to me like the provided hba_configuration inside the postgresql 'main' do block should be the ending result :

  hba_configuration(
    [
      { type: 'host', database: 'all', user: 'all', address: '192.168.0.0/24', method: 'md5' },
      { type: 'host', database: 'replication', user: 'postgres', address: '192.168.0.2/32', method: 'trust' }
    ]
  )

But I end up with that config plus all the defaults :

https://github.com/express42/postgresql_lwrp/blob/6b8d583d668caf42d7f96bb0cdbcb7bcb43cf49f/attributes/server.rb#L55-L60

j15e avatar Apr 03 '19 18:04 j15e

Hey @j15e

Thanks for pointing that out! I'll take a look at the problem during the next week! Will post an update or questions here.

dragonsmith avatar Apr 06 '19 08:04 dragonsmith