Repository: ansible/ansible

Issue:
Redshift module doesn't allow dc2.large node type
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->

redshift

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
ansible 2.4.1.0
  config file = None
  configured module search path = [u'/Users/brad.chamberlain/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.4.1.0/libexec/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.14 (default, Sep 25 2017, 09:53:22) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]
```

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"

Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).

-->

<no output / empty>

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->

Running from macOS High Sierra 10.13.1

Running against AWS Redshift

##### SUMMARY
<!--- Explain the problem briefly -->

The Redshift module doesn't allow dc2.large as a node type option, but this is the default node type in Redshift. The AWS console says, "The ds2 and dc2 node types replace the ds1 and dc1 node types, respectively. The newer ds2 and dc2 node types provide higher performance than ds1 and dc1 at no extra cost." so it sounds like dc2.large is replacing the older dc1.large node type.

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

Run the following in a role.

<!--- Paste example playbooks or commands between quotes below -->
```yaml
- name: redshift
  redshift:
    command: create
    region: "{{ redshift_region }}"
    node_type: dc2.large
    identifier: "{{ redshift_name }}"
    availability_zone: "{{ redshift_az }}"
    cluster_type: single-node
    db_name: "{{ redshift_db_name }}"
    username: "{{ redshift_username }}"
    password: "{{ redshift_password }}"
    publicly_accessible: yes
    vpc_security_group_ids: "{{ redshift_sg_id }}"
    skip_final_cluster_snapshot: yes
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

Redshift single-node cluster with dc2.large node type.

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

Got the following error message:

TASK [listener : redshift] *******************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "value of node_type must be one of: ds1.xlarge,ds1.8xlarge,ds2.xlarge,ds2.8xlarge,dc1.large,dc1.8xlarge,dw1.xlarge,dw1.8xlarge,dw2.large,dw2.8xlarge, got: dc2.large"}

<!--- Paste verbatim command output between quotes below -->
```
TASK [listener : redshift] *******************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "value of node_type must be one of: ds1.xlarge,ds1.8xlarge,ds2.xlarge,ds2.8xlarge,dc1.large,dc1.8xlarge,dw1.xlarge,dw1.8xlarge,dw2.large,dw2.8xlarge, got: dc2.large"}
```



Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/redshift.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/redshift.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @j-carl @willthames
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/redshift.py b/lib/ansible/modules/cloud/amazon/redshift.py
--- a/lib/ansible/modules/cloud/amazon/redshift.py
+++ b/lib/ansible/modules/cloud/amazon/redshift.py
@@ -34,7 +34,8 @@
   node_type:
     description:
       - The node type of the cluster. Must be specified when command=create.
-    choices: ['ds1.xlarge', 'ds1.8xlarge', 'ds2.xlarge', 'ds2.8xlarge', 'dc1.large', 'dc1.8xlarge', 'dw1.xlarge', 'dw1.8xlarge', 'dw2.large', 'dw2.8xlarge']
+    choices: ['ds1.xlarge', 'ds1.8xlarge', 'ds2.xlarge', 'ds2.8xlarge', 'dc1.large', 'dc2.large', 'dc1.8xlarge', 'dw1.xlarge',
+              'dw1.8xlarge', 'dw2.large', 'dw2.8xlarge']
   username:
     description:
       - Master database username. Used only when command=create.
@@ -434,8 +435,9 @@ def main():
     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),
+        node_type                           = dict(choices=['ds1.xlarge', 'ds1.8xlarge', 'ds2.xlarge', 'ds2.8xlarge', 'dc1.large',
+                                                            'dc2.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),


Test patch: