# Buggy code
def apply(self):
    create_delete_decision = {}
    modify = {}
    netapp_utils.ems_log_event("na_ontap_user", self.server)
    for application in self.parameters["applications"]:
        current = self.get_user(application)
        cd_action = self.na_helper.get_cd_action(current, self.parameters)
        if cd_action is not None:
            create_delete_decision[application] = cd_action
    if not create_delete_decision and self.parameters.get("state") == "present":
        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"]
        )
        modify = self.na_helper.get_modified_attributes(current, self.parameters)

    if self.na_helper.changed:
        if self.module.check_mode:
            pass
        else:
            if create_delete_decision:
                for cd_action in create_delete_decision:
                    if create_delete_decision[cd_action] == "create":
                        self.create_user(cd_action)
                    elif create_delete_decision[cd_action] == "delete":
                        self.delete_user(cd_action)
            elif modify:
                if self.parameters.get("lock_user"):
                    self.lock_given_user()
                else:
                    self.unlock_given_user()
            elif (
                not create_delete_decision
                and self.parameters.get("set_password") is not None
            ):
                self.change_password()
    self.module.exit_json(changed=self.na_helper.changed)


# 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 apply(self):
    create_delete_decision = {}
    modify = {}
    netapp_utils.ems_log_event("na_ontap_user", self.server)
    for application in self.parameters["applications"]:
        current = self.get_user(application)
        cd_action = self.na_helper.get_cd_action(current, self.parameters)
        if cd_action is not None:
            create_delete_decision[application] = cd_action
    if not create_delete_decision and self.parameters.get("state") == "present":
        if self.parameters.get("set_password") is not None:
            self.na_helper.changed = True
        current = self.get_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:
        if self.module.check_mode:
            pass
        else:
            if create_delete_decision:
                for cd_action in create_delete_decision:
                    if create_delete_decision[cd_action] == "create":
                        self.create_user(cd_action)
                    elif create_delete_decision[cd_action] == "delete":
                        self.delete_user(cd_action)
            elif modify:
                if self.parameters.get("lock_user"):
                    self.lock_given_user()
                else:
                    self.unlock_given_user()
            elif (
                not create_delete_decision
                and self.parameters.get("set_password") is not None
            ):
                # 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)