# Buggy code
def main():
    argument_spec = ec2_argument_spec()
    argument_spec.update(
        dict(
            command=dict(
                choices=["create", "facts", "delete", "modify"], required=True
            ),
            identifier=dict(required=True),
            node_type=dict(
                choices=[
                    "ds1.xlarge",
                    "ds1.8xlarge",
                    "ds2.xlarge",
                    "ds2.8xlarge",
                    "dc1.large",
                    "dc1.8xlarge",
                    "dw1.xlarge",
                    "dw1.8xlarge",
                    "dw2.large",
                    "dw2.8xlarge",
                ],
                required=False,
            ),
            username=dict(required=False),
            password=dict(no_log=True, required=False),
            db_name=dict(require=False),
            cluster_type=dict(
                choices=[
                    "multi-node",
                    "single-node",
                ],
                default="single-node",
            ),
            cluster_security_groups=dict(aliases=["security_groups"], type="list"),
            vpc_security_group_ids=dict(aliases=["vpc_security_groups"], type="list"),
            cluster_subnet_group_name=dict(aliases=["subnet"]),
            availability_zone=dict(aliases=["aws_zone", "zone"]),
            preferred_maintenance_window=dict(
                aliases=["maintance_window", "maint_window"]
            ),
            cluster_parameter_group_name=dict(aliases=["param_group_name"]),
            automated_snapshot_retention_period=dict(aliases=["retention_period"]),
            port=dict(type="int"),
            cluster_version=dict(aliases=["version"], choices=["1.0"]),
            allow_version_upgrade=dict(
                aliases=["version_upgrade"], type="bool", default=True
            ),
            number_of_nodes=dict(type="int"),
            publicly_accessible=dict(type="bool", default=False),
            encrypted=dict(type="bool", default=False),
            elastic_ip=dict(required=False),
            new_cluster_identifier=dict(aliases=["new_identifier"]),
            wait=dict(type="bool", default=False),
            wait_timeout=dict(default=300),
        )
    )

    module = AnsibleModule(
        argument_spec=argument_spec,
    )

    if not HAS_BOTO:
        module.fail_json(msg="boto v2.9.0+ required for this module")

    command = module.params.get("command")

    region, ec2_url, aws_connect_params = get_aws_connection_info(module)
    if not region:
        module.fail_json(
            msg=str(
                "region not specified and unable to determine region from EC2_REGION."
            )
        )

    # connect to the rds endpoint
    try:
        conn = connect_to_aws(boto.redshift, region, **aws_connect_params)
    except boto.exception.JSONResponseError as e:
        module.fail_json(msg=str(e))

    changed = True
    if command == "create":
        (changed, cluster) = create_cluster(module, conn)

    elif command == "facts":
        (changed, cluster) = describe_cluster(module, conn)

    elif command == "delete":
        (changed, cluster) = delete_cluster(module, conn)

    elif command == "modify":
        (changed, cluster) = modify_cluster(module, conn)

    module.exit_json(changed=changed, cluster=cluster)


# Traceback (TypeError)
TASK [create-network : Create AWS Redshift Cluster] ***********************************************************************
task path: /home/ubuntu/code/ansible/ansible-dev/roles/create-redshift/tasks/main.yml:106
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/cloud/amazon/redshift.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<localhost> EXEC /bin/sh -c 'echo ~ &amp;&amp; sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1495788650.68-58620293769733 `" &amp;&amp; echo ansible-tmp-1495788650.68-58620293769733="` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1495788650.68-58620293769733 `" ) &amp;&amp; sleep 0'
<localhost> PUT /tmp/tmpQSw3Hl TO /home/ubuntu/.ansible/tmp/ansible-tmp-1495788650.68-58620293769733/redshift.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1495788650.68-58620293769733/ /home/ubuntu/.ansible/tmp/ansible-tmp-1495788650.68-58620293769733/redshift.py &amp;&amp; sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1495788650.68-58620293769733/redshift.py; rm -rf "/home/ubuntu/.ansible/tmp/ansible-tmp-1495788650.68-58620293769733/" > /dev/null 2>&amp;1 &amp;&amp; sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_ByRYQt/ansible_module_redshift.py", line 485, in <module>
main()
File "/tmp/ansible_ByRYQt/ansible_module_redshift.py", line 467, in main
(changed, cluster) = create_cluster(module, conn)
File "/tmp/ansible_ByRYQt/ansible_module_redshift.py", line 293, in create_cluster
wait_timeout = time.time() + wait_timeout
TypeError: unsupported operand type(s) for +: 'float' and 'str'

fatal: [localhost]: FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_ByRYQt/ansible_module_redshift.py\", line 485, in <module>\n    main()\n  File \"/tmp/ansible_ByRYQt/ansible_module_redshift.py\", line 467, in main\n    (changed, cluster) = create_cluster(module, conn)\n  File \"/tmp/ansible_ByRYQt/ansible_module_redshift.py\", line 293, in create_cluster\n    wait_timeout = time.time() + wait_timeout\nTypeError: unsupported operand type(s) for +: 'float' and 'str'\n",
"msg": "MODULE FAILURE",
"rc": 0
}

# Fixed code
def main():
    argument_spec = ec2_argument_spec()
    argument_spec.update(
        dict(
            command=dict(
                choices=["create", "facts", "delete", "modify"], required=True
            ),
            identifier=dict(required=True),
            node_type=dict(
                choices=[
                    "ds1.xlarge",
                    "ds1.8xlarge",
                    "ds2.xlarge",
                    "ds2.8xlarge",
                    "dc1.large",
                    "dc1.8xlarge",
                    "dw1.xlarge",
                    "dw1.8xlarge",
                    "dw2.large",
                    "dw2.8xlarge",
                ],
                required=False,
            ),
            username=dict(required=False),
            password=dict(no_log=True, required=False),
            db_name=dict(require=False),
            cluster_type=dict(
                choices=[
                    "multi-node",
                    "single-node",
                ],
                default="single-node",
            ),
            cluster_security_groups=dict(aliases=["security_groups"], type="list"),
            vpc_security_group_ids=dict(aliases=["vpc_security_groups"], type="list"),
            cluster_subnet_group_name=dict(aliases=["subnet"]),
            availability_zone=dict(aliases=["aws_zone", "zone"]),
            preferred_maintenance_window=dict(
                aliases=["maintance_window", "maint_window"]
            ),
            cluster_parameter_group_name=dict(aliases=["param_group_name"]),
            automated_snapshot_retention_period=dict(aliases=["retention_period"]),
            port=dict(type="int"),
            cluster_version=dict(aliases=["version"], choices=["1.0"]),
            allow_version_upgrade=dict(
                aliases=["version_upgrade"], type="bool", default=True
            ),
            number_of_nodes=dict(type="int"),
            publicly_accessible=dict(type="bool", default=False),
            encrypted=dict(type="bool", default=False),
            elastic_ip=dict(required=False),
            new_cluster_identifier=dict(aliases=["new_identifier"]),
            wait=dict(type="bool", default=False),
            wait_timeout=dict(type="int", default=300),
        )
    )

    module = AnsibleModule(
        argument_spec=argument_spec,
    )

    if not HAS_BOTO:
        module.fail_json(msg="boto v2.9.0+ required for this module")

    command = module.params.get("command")

    region, ec2_url, aws_connect_params = get_aws_connection_info(module)
    if not region:
        module.fail_json(
            msg=str(
                "region not specified and unable to determine region from EC2_REGION."
            )
        )

    # connect to the rds endpoint
    try:
        conn = connect_to_aws(boto.redshift, region, **aws_connect_params)
    except boto.exception.JSONResponseError as e:
        module.fail_json(msg=str(e))

    changed = True
    if command == "create":
        (changed, cluster) = create_cluster(module, conn)

    elif command == "facts":
        (changed, cluster) = describe_cluster(module, conn)

    elif command == "delete":
        (changed, cluster) = delete_cluster(module, conn)

    elif command == "modify":
        (changed, cluster) = modify_cluster(module, conn)

    module.exit_json(changed=changed, cluster=cluster)