# Buggy code
def __init__(self, client):
    super(TaskParameters, self).__init__()

    self.state = None
    self.advertise_addr = None
    self.listen_addr = None
    self.force_new_cluster = None
    self.remote_addrs = None
    self.join_token = None

    # Spec
    self.snapshot_interval = None
    self.task_history_retention_limit = None
    self.keep_old_snapshots = None
    self.log_entries_for_slow_followers = None
    self.heartbeat_tick = None
    self.election_tick = None
    self.dispatcher_heartbeat_period = None
    self.node_cert_expiry = None
    self.external_cas = None
    self.name = None
    self.labels = None
    self.log_driver = None
    self.signing_ca_cert = None
    self.signing_ca_key = None
    self.ca_force_rotate = None
    self.autolock_managers = None
    self.rotate_worker_token = None
    self.rotate_manager_token = None

    for key, value in client.module.params.items():
        setattr(self, key, value)

    self.update_parameters(client)


# 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 __init__(self):
    super(TaskParameters, self).__init__()

    self.advertise_addr = None
    self.listen_addr = None
    self.force_new_cluster = None
    self.remote_addrs = None
    self.join_token = None

    # Spec
    self.snapshot_interval = None
    self.task_history_retention_limit = None
    self.keep_old_snapshots = None
    self.log_entries_for_slow_followers = None
    self.heartbeat_tick = None
    self.election_tick = None
    self.dispatcher_heartbeat_period = None
    self.node_cert_expiry = None
    self.external_cas = None
    self.name = None
    self.labels = None
    self.log_driver = None
    self.signing_ca_cert = None
    self.signing_ca_key = None
    self.ca_force_rotate = None
    self.autolock_managers = None
    self.rotate_worker_token = None
    self.rotate_manager_token = None