From 898ec291b0bec80ac1377ce6f7a3efaff2e8de2f Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Mon, 7 Jan 2019 09:25:36 -0800 Subject: [PATCH] Backport/2.7/49084 (#49973) * influxdb_user: Fixed default password behavior (#47040) (cherry picked from commit 1eed8900ed58d4ca857eba885e758a4cbced5fba) * Amends #47040 - influxdb_user - Prevents potential accidental password changes to blank (#49084) * Amends #47040 - Prevents potential accidental password changes to blank * Added changelog fragment (cherry picked from commit b422c59ada632b5905b9fc06b8fb37ed299f3979) --- .../fragments/49084-influxdb_user-default-password-fix.yaml | 3 +++ lib/ansible/modules/database/influxdb/influxdb_user.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) 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 00000000000..81188af66c0 --- /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 52a2057006a..3ec22ef6ab7 100644 --- a/lib/ansible/modules/database/influxdb/influxdb_user.py +++ b/lib/ansible/modules/database/influxdb/influxdb_user.py @@ -166,11 +166,12 @@ def main(): if state == 'present': if user: - if check_user_password(module, client, user_name, user_password): + if user_password is None or check_user_password(module, client, user_name, user_password): module.exit_json(changed=False) else: set_user_password(module, client, user_name, user_password) else: + user_password = user_password or '' create_user(module, client, user_name, user_password, admin) if state == 'absent':