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

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>
This commit is contained in:
Petr Tichý 2023-03-22 07:38:31 +01:00 committed by GitHub
parent bf8f2950b4
commit 3fb1ff0b72
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

@ -174,8 +174,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):