-
Notifications
You must be signed in to change notification settings - Fork 96
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
Add Features for renaming users in the postgresql_user module #815
Comments
@azdfzshffg thanks for the suggestion! is this something you'd like to tackle? |
I don’t have the dev skills to contribute directly 😞, so I’m hoping someone in the community can take this on. It’d be a great improvement for managing PostgreSQL users with Ansible! 🙏 |
Imho this does not fit into how automation is used. Where does the information about renaming a role from one name into another name come from. And what happens upon re-running the playbook - is the original role created every time, then renamed? What if the new role already exists? Either your state demands that a role exists, or that it does not exist. |
I also tried formulating a safe/idempotent scenario in my head but ran into many problems. This seems like an ad-hoc/manual operation that once has taken effect then you'll probably need to revise your relevant playbooks (to account for the user renaming and any old references to it) |
Hi, and thanks a lot for your feedback! 😊 I’m having a bit of trouble understanding the concerns here. From what I see, this "rename" logic is already handled in other modules, like postgresql_db, where it's explained here: Ansible Documentation - postgresql_db module
Wouldn't it make sense to apply the same logic here? It also feels like there's a missing feature compared to postgresql_db. What do you think? 😊 |
I'd rather say that having this in the |
@azdfzshffg that was my first reaction when I thought of tackling this feature, but as @andreasscherbaum brought up, I think this is a "footgun" :D Playbooks should be safe/idempotent and they don't play well with ad-hoc/once-off operations like these. I'd argue also that it doesn't make sense for |
@azdfzshffg @andreasscherbaum @gspanos , great discussion here, thanks! Those
Or if you're sure it exists, just run postgresql_query |
Don't forget to start a transaction, keep it open and also write lock the tables. Otherwise another CI pipeline might attempt to do the same task in parallel. |
Closing the issue then (though if anybody disagree, feel free to raise your concerns). |
SUMMARY
Currently, the community.postgresql.postgresql_user module does not support renaming a user. This feature would allow renaming a PostgreSQL user directly within the module instead of requiring a separate SQL query.
ISSUE TYPE
Feature Idea
COMPONENT NAME
community.postgresql.postgresql_user
ADDITIONAL INFORMATION
This feature would simplify user management by allowing a direct rename operation without needing to execute a raw SQL query (ALTER ROLE old_name RENAME TO new_name;).
It would be useful for maintaining consistency in PostgreSQL role management, especially in automated deployments.
Example of expected usage:
This would improve usability and reduce the need for raw SQL queries in playbooks.😊
Thanks
The text was updated successfully, but these errors were encountered: