-
Notifications
You must be signed in to change notification settings - Fork 92
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_user module doesn't close db connection #431
Comments
@boosterKRD hi, thanks for reporting the issue! |
@Andersson007 I implemented changes locally and tested-> all works fine. |
@boosterKRD brilliant, thanks! Just a fyi: you'll see integration/unit tests mentioned in the guide. I don't think you need to add any tests in this particular case.
|
closed via #436 |
SUMMARY
There is no closing connection to DB in postgresql_user.py. Because of this, when using loops/with_items and etc, the number of connections is constantly growing until the loop ends or it becomes more than the DB connection-limit parameter (if there are more elements in the array, then users connection-limit )
ISSUE TYPE
COMPONENT NAME
postgresql_user
EXPECTED RESULTS
After each iteration of the loop connection to DB must be closed as it is done in other modules (postgresql_membership, postgresql_query).
Two lines have to be added to
community.postgresql/plugins/modules/postgresql_user.py
Line 1071 in 04c04c4
cursor.close()
db_connection.close()
STEPS TO REPRODUCE
db_users:
{ username: 'test1', actions: 'LOGIN,INHERIT'}
...
...
{ username: 'test10', actions: 'LOGIN,INHERIT'}
name: Create users
postgresql_user:
login_host: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
login_user: 'your_user_db'
db: 'postgres'
login_password: 'your_db_pass'
name: '{{ item.username }}'
password: 'md56771d07fa780767a22d0092372bd41ab'
role_attr_flags: '{{ item.actions }}'
conn_limit: '{{ item.conn_limit }}'
state: 'present'
with_list: '{{ db_users }}'
loop_control:
pause: 5
become_user: 'postgres'
The text was updated successfully, but these errors were encountered: