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
* 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:
parent
7753fa4219
commit
ec2e7cad3e
2 changed files with 9 additions and 7 deletions
|
@ -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).
|
|
@ -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'],
|
||||
|
|
Loading…
Reference in a new issue