# Buggy code
def set_bios_default_settings(self):
    result = {}
    key = "Bios"

    # Search for 'key' entry and extract URI from it
    response = self.get_request(self.root_uri + self.systems_uri)
    if response["ret"] is False:
        return response
    result["ret"] = True
    data = response["data"]

    if key not in data:
        return {"ret": False, "msg": "Key %s not found" % key}

    bios_uri = data[key]["@odata.id"]

    # Extract proper URI
    response = self.get_request(self.root_uri + bios_uri)
    if response["ret"] is False:
        return response
    result["ret"] = True
    data = response["data"]
    reset_bios_settings_uri = data["Actions"]["#Bios.ResetBios"]["target"]

    response = self.post_request(self.root_uri + reset_bios_settings_uri, {}, HEADERS)
    if response["ret"] is False:
        return response
    return {"ret": True}


# Traceback (KeyError)
TASK [Enable NTP in the OOB Controller] *******************************************************************************************************************************************************************
task path: /home/xxxx/yyyy/test01_bmc_setup.yml:26
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'changed'
The full traceback is:
Traceback (most recent call last):
File "/home/xxxx/.ansible/tmp/ansible-tmp-1543355194.27-98542354862727/AnsiballZ_redfish_config.py", line 113, in <module>
_ansiballz_main()
File "/home/xxxx/.ansible/tmp/ansible-tmp-1543355194.27-98542354862727/AnsiballZ_redfish_config.py", line 105, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/xxxx/.ansible/tmp/ansible-tmp-1543355194.27-98542354862727/AnsiballZ_redfish_config.py", line 48, in invoke_module
imp.load_module('__main__', mod, module, MOD_DESC)
File "/data/tmp/ansible_redfish_config_payload_QCPf9S/__main__.py", line 236, in <module>
File "/data/tmp/ansible_redfish_config_payload_QCPf9S/__main__.py", line 230, in main
KeyError: 'changed'

fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n  File \"/home/xxxx/.ansible/tmp/ansible-tmp-1543355194.27-98542354862727/AnsiballZ_redfish_config.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/home/xxxx/.ansible/tmp/ansible-tmp-1543355194.27-98542354862727/AnsiballZ_redfish_config.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/xxxx/.ansible/tmp/ansible-tmp-1543355194.27-98542354862727/AnsiballZ_redfish_config.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/data/tmp/ansible_redfish_config_payload_QCPf9S/__main__.py\", line 236, in <module>\n  File \"/data/tmp/ansible_redfish_config_payload_QCPf9S/__main__.py\", line 230, in main\nKeyError: 'changed'\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}

# Fixed code
def set_bios_default_settings(self):
    result = {}
    key = "Bios"

    # Search for 'key' entry and extract URI from it
    response = self.get_request(self.root_uri + self.systems_uri)
    if response["ret"] is False:
        return response
    result["ret"] = True
    data = response["data"]

    if key not in data:
        return {"ret": False, "msg": "Key %s not found" % key}

    bios_uri = data[key]["@odata.id"]

    # Extract proper URI
    response = self.get_request(self.root_uri + bios_uri)
    if response["ret"] is False:
        return response
    result["ret"] = True
    data = response["data"]
    reset_bios_settings_uri = data["Actions"]["#Bios.ResetBios"]["target"]

    response = self.post_request(self.root_uri + reset_bios_settings_uri, {}, HEADERS)
    if response["ret"] is False:
        return response
    return {"ret": True, "changed": True, "msg": "Set BIOS to default settings"}