-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
postgresql_privs fails with schema name which contain '-' (dash) character #438
Comments
Files identified in the description: If these files are incorrect, please update the |
@peterkrawiec1 the postgresql modules have been moved from community.general to their own collections a long time ago; I've moved your issue to the correct repository. |
Apologies @felixfontein and thank you for moving it across! |
The postgresql collection comes with some parsing magic to detect if the identifier (e.g. schema name) is already quoted, and add quotes if necessary. def pg_quote_identifier(*names) -> str:
return '.'.join('"' + name.replace('"', '""') + '"' for name in names) to be used like schema: "{{ random_unicode1|pg_quote_identifier }}" # results in '"schema_name"'
table: "{{ random_unicode2|pg_quote_identifier(random_unicode3) }}" # results in '"schema_name"."table_name"' |
Thank you @betanummeric . Interestingly, it actually only fails if the schema name contains a hyphen and the privs to be applied are on And so, the privs would get correctly applied in this case: - db: test
type: sequence
objs: ALL_IN_SCHEMA
privs: SELECT,USAGE
schema: test-schema
state: present but would fail in this one: - db: test
type: table
objs: ALL_IN_SCHEMA
privs: SELECT,UPDATE,INSERT
schema: test-schema
state: present |
Has anyone had a chance to look into the above please? |
I'm personally not a user, so for me it's hard to participate. If anyone wanna raise a PR, here's the Quick start guide. UPDATE: pinged folks on Matrix in the postgresql room |
Thank you @Andersson007! |
@peterkrawiec1 What version of the community.postgresql collection are you using? Version 2.3.2 includes #382 which hopefully already fixes your issue. |
@peterkrawiec1 just in case the GH notification has drown in emails, please take a look at the question, thanks |
Thanks @Andersson007 ! That's exactly what happened! Apologies @betanummeric for missing your message - I'm using |
Summary
Task with module postgresql_privs fails with syntax error when it's trying to apply privileges to group roles on schema with a name which contain '-' (dash) character.
Issue Type
Bug Report
Component Name
postgresql_privs
Ansible Version
Community.general Version
Configuration
$ ansible-config dump --only-changed
OS / Environment
MacOS Ventura 13.2.1
Steps to Reproduce
Expected Results
Group role privileges applied to all objects as per
roles
block.Sample of the output should be:
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: