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) (#2529)

* 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

(cherry picked from commit ea200c9d8c)

Co-authored-by: sgalea87 <43749726+sgalea87@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2021-05-17 08:09:46 +02:00 committed by GitHub
parent 8ed5beb978
commit 64248acce6
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: try:
current_grants = client.get_list_privileges(user_name) current_grants = client.get_list_privileges(user_name)
parsed_grants = []
# Fix privileges wording # Fix privileges wording
for i, v in enumerate(current_grants): for i, v in enumerate(current_grants):
if v['privilege'] != 'NO PRIVILEGES':
if v['privilege'] == 'ALL PRIVILEGES': if v['privilege'] == 'ALL PRIVILEGES':
v['privilege'] = 'ALL' v['privilege'] = 'ALL'
current_grants[i] = v parsed_grants.add(v)
elif v['privilege'] == 'NO PRIVILEGES':
del(current_grants[i])
# check if the current grants are included in the desired ones # 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 current_grant not in grants:
if not module.check_mode: if not module.check_mode:
client.revoke_privilege(current_grant['privilege'], 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 # check if the desired grants are included in the current ones
for grant in grants: for grant in grants:
if grant not in current_grants: if grant not in parsed_grants:
if not module.check_mode: if not module.check_mode:
client.grant_privilege(grant['privilege'], client.grant_privilege(grant['privilege'],
grant['database'], grant['database'],