# Buggy code
def run(self, tmp=None, task_vars=None):
    if task_vars is None:
        task_vars = dict()

    result = super(ActionModule, self).run(tmp, task_vars)

    if "msg" in self._task.args:
        if "fail" in self._task.args and boolean(self._task.args["fail"]):
            result["failed"] = True
            result["msg"] = self._task.args["msg"]
        else:
            result["msg"] = self._task.args["msg"]
    # FIXME: move the LOOKUP_REGEX somewhere else
    elif (
        "var" in self._task.args
    ):  # and not utils.LOOKUP_REGEX.search(self._task.args['var']):
        results = self._templar.template(self._task.args["var"], convert_bare=True)
        if results == self._task.args["var"]:
            results = "VARIABLE IS NOT DEFINED!"
        result[self._task.args["var"]] = results
    else:
        result["msg"] = "here we are"

    # force flag to make debug output module always verbose
    result["_ansible_verbose_always"] = True

    return result


# Traceback (TypeError)
TASK [allinone : Setting fact] *************************************************
task path: testing.yml:65
ok: [127.0.0.1] => {"ansible_facts": {"testing_dictionary": [{"name": "number_one", "value": "one"}, {"name": "number_two", "value": "two"}]}, "changed": false, "invocation": {"module_args": {"testing_dictionary": [{"name": "number_one", "value": "one"}, {"name": "number_two", "value": "two"}]}, "module_name": "set_fact"}}

TASK [allinone : Debugging] ****************************************************
task path: testing.yml:73
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/Users/Etherdaemon/ansible/lib/ansible/executor/process/worker.py", line 134, in run
shared_loader_obj,
File "/Users/Etherdaemon/ansible/lib/ansible/executor/task_executor.py", line 90, in run
item_results = self._run_loop(items)
File "/Users/Etherdaemon/ansible/lib/ansible/executor/task_executor.py", line 228, in _run_loop
res = self._execute(variables=task_vars)
File "/Users/Etherdaemon/ansible/lib/ansible/executor/task_executor.py", line 387, in _execute
result = self._handler.run(task_vars=variables)
File "/Users/Etherdaemon/ansible/lib/ansible/plugins/action/debug.py", line 46, in run
result[self._task.args['var']] = results
TypeError: unhashable type: 'dict'

fatal: [127.0.0.1]: FAILED! => {"failed": true, "stdout": ""}

# Fixed code
def run(self, tmp=None, task_vars=None):
    if task_vars is None:
        task_vars = dict()

    result = super(ActionModule, self).run(tmp, task_vars)

    if "msg" in self._task.args:
        if "fail" in self._task.args and boolean(self._task.args["fail"]):
            result["failed"] = True
            result["msg"] = self._task.args["msg"]
        else:
            result["msg"] = self._task.args["msg"]
    # FIXME: move the LOOKUP_REGEX somewhere else
    elif (
        "var" in self._task.args
    ):  # and not utils.LOOKUP_REGEX.search(self._task.args['var']):
        results = self._templar.template(self._task.args["var"], convert_bare=True)
        if type(self._task.args["var"]) in (list, dict):
            # If var is a list or dict, use the type as key to display
            result[str(type(self._task.args["var"]))] = results
        else:
            if results == self._task.args["var"]:
                results = "VARIABLE IS NOT DEFINED!"
            result[self._task.args["var"]] = results
    else:
        result["msg"] = "here we are"

    # force flag to make debug output module always verbose
    result["_ansible_verbose_always"] = True

    return result