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

[PR #6111/3fb1ff0b backport][stable-5] Fix influxdb_user grants in check mode (#6213)

Fix influxdb_user grants in check mode (#6111)

* Fix influxdb_user grants in check mode

When running in check mode, `influxdb_user` will return error when the user doesn't exist yet, instead of reporting `changed` state.

* Update changelogs/fragments/6111-influxdb_user-check-mode.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 3fb1ff0b72)

Co-authored-by: Petr Tichý <petr@pex.com>
This commit is contained in:
patchback[bot] 2023-03-22 13:16:09 +01:00 committed by GitHub
parent 3e740112a0
commit e3a12f1e54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- influxdb_user - fix running in check mode when the user does not exist yet (https://github.com/ansible-collections/community.general/pull/6111).

View file

@ -168,8 +168,14 @@ def drop_user(module, client, user_name):
def set_user_grants(module, client, user_name, grants):
changed = False
current_grants = []
try:
current_grants = client.get_list_privileges(user_name)
except influx.exceptions.InfluxDBClientError as e:
if not module.check_mode or 'user not found' not in e.content:
module.fail_json(msg=e.content)
try:
parsed_grants = []
# Fix privileges wording
for i, v in enumerate(current_grants):