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:
parent
bf8f2950b4
commit
3fb1ff0b72
2 changed files with 8 additions and 0 deletions
2
changelogs/fragments/6111-influxdb_user-check-mode.yaml
Normal file
2
changelogs/fragments/6111-influxdb_user-check-mode.yaml
Normal 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).
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue