# Buggy code
def change_password(self):
    """
    Changes the password

    :return:
        True if password updated
        False if password is not updated
    :rtype: bool
    """
    # self.server.set_vserver(self.parameters['vserver'])
    modify_password = netapp_utils.zapi.NaElement.create_node_with_children(
        "security-login-modify-password",
        **{
            "new-password": str(self.parameters.get("set_password")),
            "user-name": self.parameters["name"],
        },
    )
    try:
        self.server.invoke_successfully(modify_password, enable_tunneling=True)
    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)),
                exception=traceback.format_exc(),
            )

    self.server.set_vserver(None)
    return True


# Traceback (NaApiError)
TASK [system : create users] ***************************************************************************************************************
task path: /home/fgzx6022/Work/ansible-netapp/roles/system/tasks/users.yml:1
<cloud-nas-y00n-prd.cloud.620nm.net> ESTABLISH LOCAL CONNECTION FOR USER: fgzx6022
<cloud-nas-y00n-prd.cloud.620nm.net> EXEC /bin/sh -c 'echo ~fgzx6022 &amp;&amp; sleep 0'
<cloud-nas-y00n-prd.cloud.620nm.net> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /home/fgzx6022/.ansible/tmp/ansible-tmp-1534263161.63-27306778212749 `" &amp;&amp; echo ansible-tmp-1534263161.63-27306778212749="` echo /home/fgzx6022/.ansible/tmp/ansible-tmp-1534263161.63-27306778212749 `" ) &amp;&amp; sleep 0'
Using module file /home/fgzx6022/Work/python-env/ansible2.6/local/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_user.py
<cloud-nas-y00n-prd.cloud.620nm.net> PUT /home/fgzx6022/.ansible/tmp/ansible-local-14150fX3OxX/tmprB3obz TO /home/fgzx6022/.ansible/tmp/ansible-tmp-1534263161.63-27306778212749/na_ontap_user.py
<cloud-nas-y00n-prd.cloud.620nm.net> EXEC /bin/sh -c 'chmod u+x /home/fgzx6022/.ansible/tmp/ansible-tmp-1534263161.63-27306778212749/ /home/fgzx6022/.ansible/tmp/ansible-tmp-1534263161.63-27306778212749/na_ontap_user.py &amp;&amp; sleep 0'
<cloud-nas-y00n-prd.cloud.620nm.net> EXEC /bin/sh -c '/home/fgzx6022/Work/python-env/ansible2.6/bin/python /home/fgzx6022/.ansible/tmp/ansible-tmp-1534263161.63-27306778212749/na_ontap_user.py &amp;&amp; sleep 0'
<cloud-nas-y00n-prd.cloud.620nm.net> EXEC /bin/sh -c 'rm -f -r /home/fgzx6022/.ansible/tmp/ansible-tmp-1534263161.63-27306778212749/ > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_Y2tuA_/ansible_module_na_ontap_user.py", line 328, in change_password
enable_tunneling=True)
File "/home/fgzx6022/Work/python-env/ansible2.6/local/lib/python2.7/site-packages/netapp_lib/api/zapi/zapi.py", line 294, in invoke_successfully
raise NaApiError(code, msg)
NaApiError: NetApp API failed. Reason - 13214:New password must be different than the old password.

[WARNING]: Module did not set no_log for set_password

failed: [cloud-nas-y00n-prd.cloud.620nm.net] (item={u'application': u'ontapi', u'role_name': u'admin', u'name': u'vsphere-vsc'}) => {
"changed": false,
"invocation": {
"module_args": {
"application": "ontapi",
"authentication_method": "password",
"hostname": "cloud-nas-y00n-prd.cloud.620nm.net",
"https": false,
"lock_user": null,
"name": "vsphere-vsc",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"role_name": "admin",
"set_password": "#########",
"state": "present",
"username": "ansible",
"vserver": "cloud-nas-y00n-prd"
}
},
"item": {
"application": "ontapi",
"name": "vsphere-vsc",
"role_name": "admin"
},
"msg": "Error setting password for user vsphere-vsc: NetApp API failed. Reason - 13214:New password must be different than the old password."
}
to retry, use: --limit @/home/fgzx6022/Work/ansible-netapp/config.retry

# Fixed code
def change_password(self):
    """
    Changes the password

    :return:
        True if password updated
        False if password is not updated
    :rtype: bool
    """
    # self.server.set_vserver(self.parameters['vserver'])
    modify_password = netapp_utils.zapi.NaElement.create_node_with_children(
        "security-login-modify-password",
        **{
            "new-password": str(self.parameters.get("set_password")),
            "user-name": self.parameters["name"],
        },
    )
    try:
        self.server.invoke_successfully(modify_password, enable_tunneling=True)
    except netapp_utils.zapi.NaApiError as error:
        if to_native(error.code) == "13114":
            return False
        # 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)
    return True