From b422c59ada632b5905b9fc06b8fb37ed299f3979 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Wed, 12 Dec 2018 09:43:37 -0800 Subject: [PATCH] Amends #47040 - influxdb_user - Prevents potential accidental password changes to blank (#49084) * Amends #47040 - Prevents potential accidental password changes to blank * Added changelog fragment --- .../fragments/49084-influxdb_user-default-password-fix.yaml | 3 +++ lib/ansible/modules/database/influxdb/influxdb_user.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/49084-influxdb_user-default-password-fix.yaml diff --git a/changelogs/fragments/49084-influxdb_user-default-password-fix.yaml b/changelogs/fragments/49084-influxdb_user-default-password-fix.yaml new file mode 100644 index 0000000000..81188af66c --- /dev/null +++ b/changelogs/fragments/49084-influxdb_user-default-password-fix.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - influxdb_user - An unspecified password now sets the password to blank, except on existing users. This previously caused an unhandled exception. diff --git a/lib/ansible/modules/database/influxdb/influxdb_user.py b/lib/ansible/modules/database/influxdb/influxdb_user.py index a1196c1960..8813d3edaf 100644 --- a/lib/ansible/modules/database/influxdb/influxdb_user.py +++ b/lib/ansible/modules/database/influxdb/influxdb_user.py @@ -157,7 +157,7 @@ def main(): state = module.params['state'] user_name = module.params['user_name'] - user_password = module.params['user_password'] or '' + user_password = module.params['user_password'] admin = module.params['admin'] influxdb = influx.InfluxDb(module) client = influxdb.connect_to_influxdb() @@ -167,7 +167,7 @@ def main(): if user: changed = False - if not check_user_password(module, client, user_name, user_password): + if not check_user_password(module, client, user_name, user_password) and user_password is not None: set_user_password(module, client, user_name, user_password) changed = True @@ -183,6 +183,7 @@ def main(): module.exit_json(changed=changed) else: + user_password = user_password or '' create_user(module, client, user_name, user_password, admin) if state == 'absent':