diff --git a/lib/ansible/modules/storage/netapp/na_ontap_user.py b/lib/ansible/modules/storage/netapp/na_ontap_user.py index 213b6cdfe9e..70fcb3df770 100644 --- a/lib/ansible/modules/storage/netapp/na_ontap_user.py +++ b/lib/ansible/modules/storage/netapp/na_ontap_user.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# (c) 2018, NetApp, Inc +# (c) 2018-2019, NetApp, Inc # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -304,8 +304,10 @@ class NetAppOntapUser(object): except netapp_utils.zapi.NaApiError as error: if to_native(error.code) == '13114': return False - else: - self.module.fail_json(msg='Error setting password for user %s: %s' % (self.parameters['name'], to_native(error)), + # if the user give the same password, instead of returning an error, return ok + if to_native(error.code) == '13214' and error.message.startswith('New password must be different than the old password.'): + return False + self.module.fail_json(msg='Error setting password for user %s: %s' % (self.parameters['name'], to_native(error)), exception=traceback.format_exc()) self.server.set_vserver(None) @@ -324,7 +326,8 @@ class NetAppOntapUser(object): if self.parameters.get('set_password') is not None: self.na_helper.changed = True current = self.get_user() - current['lock_user'] = self.na_helper.get_value_for_bool(True, current['lock_user']) + if current is not None: + current['lock_user'] = self.na_helper.get_value_for_bool(True, current['lock_user']) modify = self.na_helper.get_modified_attributes(current, self.parameters) if self.na_helper.changed: @@ -343,7 +346,8 @@ class NetAppOntapUser(object): else: self.unlock_given_user() elif not create_delete_decision and self.parameters.get('set_password') is not None: - self.change_password() + # if change password return false nothing has changed so we need to set changed to False + self.na_helper.changed = self.change_password() self.module.exit_json(changed=self.na_helper.changed) diff --git a/test/units/modules/storage/netapp/test_na_ontap_user.py b/test/units/modules/storage/netapp/test_na_ontap_user.py index 01a37f5af5b..56cca39e0d1 100644 --- a/test/units/modules/storage/netapp/test_na_ontap_user.py +++ b/test/units/modules/storage/netapp/test_na_ontap_user.py @@ -17,7 +17,7 @@ from ansible.modules.storage.netapp.na_ontap_user \ import NetAppOntapUser as my_module # module under test if not netapp_utils.has_netapp_lib(): - pytestmark = pytest.skip('skipping as missing required netapp_lib') + pytestmark = pytest.mark.skip('skipping as missing required netapp_lib') def set_module_args(args):