Bug description
postgresql_server__privs__host_var / __group_var cannot be used: as soon as it contains one entry, the run aborts while the role evaluates postgresql_server__privs__combined_var.
defaults/main.yml merges the privileges with combine_lod(unique_key="objs"), but objs is a list, as the role README documents it. combine_lod uses the value of the unique key as a dictionary key, and a list cannot be one:
TypeError: cannot use 'list' as a dict key (unhashable type: 'list')
Even with a hashable key, objs alone would not identify an entry: two grants on the same database to different roles would be merged into one.
Steps to reproduce
Run linuxfabrik.lfops.postgresql_server with the example from the role README:
postgresql_server__privs__host_var:
- privs:
- 'CONNECT'
type: 'database'
objs:
- 'database1'
roles:
- 'user1'
state: 'present'
The filter can also be called directly:
combine_lod([{'objs': ['database1'], 'roles': ['user1'], 'privs': ['CONNECT']}], unique_key='objs')
Expected behavior
The privileges are granted, and an entry can be overridden or revoked from the inventory like in the other combined variables.
Environment
LFOps main (c5ef30c), all platforms; the error is raised on the controller.
Additional context
Since no inventory can use the variable today, changing its format breaks nothing that works. Possible fixes:
- Take
objs and roles as comma-separated strings, as community.postgresql.postgresql_privs does, and merge on type, objs and roles. type then has to be mandatory, because combine_lod requires every key to be set.
- Let
combine_lod turn list values of a unique key into tuples, keep the documented list format and merge on type, objs and roles. This touches the plugin and its unit tests, and the order inside the lists becomes part of the identity.
- Add a mandatory
name subkey as the identity. Simplest, but the name means nothing to PostgreSQL.
Bug description
postgresql_server__privs__host_var/__group_varcannot be used: as soon as it contains one entry, the run aborts while the role evaluatespostgresql_server__privs__combined_var.defaults/main.ymlmerges the privileges withcombine_lod(unique_key="objs"), butobjsis a list, as the role README documents it.combine_loduses the value of the unique key as a dictionary key, and a list cannot be one:Even with a hashable key,
objsalone would not identify an entry: two grants on the same database to different roles would be merged into one.Steps to reproduce
Run
linuxfabrik.lfops.postgresql_serverwith the example from the role README:The filter can also be called directly:
Expected behavior
The privileges are granted, and an entry can be overridden or revoked from the inventory like in the other combined variables.
Environment
LFOps
main(c5ef30c), all platforms; the error is raised on the controller.Additional context
Since no inventory can use the variable today, changing its format breaks nothing that works. Possible fixes:
objsandrolesas comma-separated strings, ascommunity.postgresql.postgresql_privsdoes, and merge ontype,objsandroles.typethen has to be mandatory, becausecombine_lodrequires every key to be set.combine_lodturn list values of a unique key into tuples, keep the documented list format and merge ontype,objsandroles. This touches the plugin and its unit tests, and the order inside the lists becomes part of the identity.namesubkey as the identity. Simplest, but the name means nothing to PostgreSQL.