# Buggy code
def remove(self):
    if not (self.__isSwarmManager()):
        self.client.fail("This node is not a manager.")

    try:
        status_down = self.__check_node_is_down()
    except APIError:
        return

    if not (status_down):
        self.client.fail(
            "Can not remove the node. The status node is ready and not down."
        )

    if not self.check_mode:
        try:
            self.client.remove_node(
                node_id=self.parameters.node_id, force=self.parameters.force
            )
        except APIError as exc:
            self.client.fail(
                "Can not remove the node from the Swarm Cluster: %s" % to_native(exc)
            )
    self.results["actions"].append("Node is removed from swarm cluster.")
    self.results["changed"] = True


# Traceback (nKeyError)
fatal: [node-01]: FAILED! => {"changed": false, "module_stderr": "Shared connection to node-01 closed.\r\n", "module_stdout": "/usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.24.1) or chardet (2.2.1) doesn't match a supported version!\r\n  RequestsDependencyWarning)\r\nTraceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1548156057.5468266-261250085584743/AnsiballZ_docker_swarm.py\", line 113, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1548156057.5468266-261250085584743/AnsiballZ_docker_swarm.py\", line 105, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1548156057.5468266-261250085584743/AnsiballZ_docker_swarm.py\", line 48, in invoke_module\r\n    imp.load_module('__main__', mod, module, MOD_DESC)\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 535, in <module>\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 530, in main\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 310, in __call__\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 333, in init_swarm\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 390, in __update_swarm\r\n  File \"/tmp/ansible_docker_swarm_payload_2QlvP8/__main__.py\", line 376, in __update_spec\r\nKeyError: 'Labels'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

# Fixed code
def remove(self):
    if not (self.__isSwarmManager()):
        self.client.fail("This node is not a manager.")

    try:
        status_down = self.__check_node_is_down()
    except APIError:
        return

    if not (status_down):
        self.client.fail(
            "Can not remove the node. The status node is ready and not down."
        )

    if not self.check_mode:
        try:
            self.client.remove_node(node_id=self.parameters.node_id, force=self.force)
        except APIError as exc:
            self.client.fail(
                "Can not remove the node from the Swarm Cluster: %s" % to_native(exc)
            )
    self.results["actions"].append("Node is removed from swarm cluster.")
    self.differences.add("joined", parameter=False, active=True)
    self.results["changed"] = True