1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Update influxdb_user.py Fixed Multiple No Privileges (#2499)

* Update influxdb_user.py

Fixed Multiple No Privileges

* Update influxdb_user.py

Fixed line spaces

* Update influxdb_user.py

Fixed whitespace

* Create 2499-influxdb_user-fix-multiple-no-privileges.yml 

Added changelog
This commit is contained in:
sgalea87 2021-05-17 07:33:40 +02:00 committed by GitHub
parent 5b77515308
commit ea200c9d8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- influxdb_user - fix bug where an influxdb user has no privileges for 2 or more databases (https://github.com/ansible-collections/community.general/pull/2499).

View file

@ -166,16 +166,16 @@ def set_user_grants(module, client, user_name, grants):
try:
current_grants = client.get_list_privileges(user_name)
parsed_grants = []
# Fix privileges wording
for i, v in enumerate(current_grants):
if v['privilege'] == 'ALL PRIVILEGES':
v['privilege'] = 'ALL'
current_grants[i] = v
elif v['privilege'] == 'NO PRIVILEGES':
del(current_grants[i])
if v['privilege'] != 'NO PRIVILEGES':
if v['privilege'] == 'ALL PRIVILEGES':
v['privilege'] = 'ALL'
parsed_grants.add(v)
# check if the current grants are included in the desired ones
for current_grant in current_grants:
for current_grant in parsed_grants:
if current_grant not in grants:
if not module.check_mode:
client.revoke_privilege(current_grant['privilege'],
@ -185,7 +185,7 @@ def set_user_grants(module, client, user_name, grants):
# check if the desired grants are included in the current ones
for grant in grants:
if grant not in current_grants:
if grant not in parsed_grants:
if not module.check_mode:
client.grant_privilege(grant['privilege'],
grant['database'],