redshift: Fix error with boolean parameters (#3467)

This commit is contained in:
Jens Carl 2016-11-17 10:18:23 -08:00 committed by Matt Clay
parent cb765ce590
commit 90e0dc2a89

View file

@ -37,115 +37,94 @@ options:
node_type: node_type:
description: description:
- The node type of the cluster. Must be specified when command=create. - The node type of the cluster. Must be specified when command=create.
required: false
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', 'dc1.8xlarge', 'dw1.xlarge', 'dw1.8xlarge', 'dw2.large', 'dw2.8xlarge']
username: username:
description: description:
- Master database username. Used only when command=create. - Master database username. Used only when command=create.
required: false
password: password:
description: description:
- Master database password. Used only when command=create. - Master database password. Used only when command=create.
required: false
cluster_type: cluster_type:
description: description:
- The type of cluster. - The type of cluster.
required: false
choices: ['multi-node', 'single-node' ] choices: ['multi-node', 'single-node' ]
default: 'single-node' default: 'single-node'
db_name: db_name:
description: description:
- Name of the database. - Name of the database.
required: false
default: null default: null
availability_zone: availability_zone:
description: description:
- availability zone in which to launch cluster - availability zone in which to launch cluster
required: false
aliases: ['zone', 'aws_zone'] aliases: ['zone', 'aws_zone']
number_of_nodes: number_of_nodes:
description: description:
- Number of nodes. Only used when cluster_type=multi-node. - Number of nodes. Only used when cluster_type=multi-node.
required: false
default: null default: null
cluster_subnet_group_name: cluster_subnet_group_name:
description: description:
- which subnet to place the cluster - which subnet to place the cluster
required: false
aliases: ['subnet'] aliases: ['subnet']
cluster_security_groups: cluster_security_groups:
description: description:
- in which security group the cluster belongs - in which security group the cluster belongs
required: false
default: null default: null
aliases: ['security_groups'] aliases: ['security_groups']
vpc_security_group_ids: vpc_security_group_ids:
description: description:
- VPC security group - VPC security group
required: false
aliases: ['vpc_security_groups'] aliases: ['vpc_security_groups']
default: null default: null
preferred_maintenance_window: preferred_maintenance_window:
description: description:
- maintenance window - maintenance window
required: false
aliases: ['maintance_window', 'maint_window'] aliases: ['maintance_window', 'maint_window']
default: null default: null
cluster_parameter_group_name: cluster_parameter_group_name:
description: description:
- name of the cluster parameter group - name of the cluster parameter group
required: false
aliases: ['param_group_name'] aliases: ['param_group_name']
default: null default: null
automated_snapshot_retention_period: automated_snapshot_retention_period:
description: description:
- period when the snapshot take place - period when the snapshot take place
required: false
aliases: ['retention_period'] aliases: ['retention_period']
default: null default: null
port: port:
description: description:
- which port the cluster is listining - which port the cluster is listining
required: false
default: null default: null
cluster_version: cluster_version:
description: description:
- which version the cluster should have - which version the cluster should have
required: false
aliases: ['version'] aliases: ['version']
choices: ['1.0'] choices: ['1.0']
default: null default: null
allow_version_upgrade: allow_version_upgrade:
description: description:
- flag to determinate if upgrade of version is possible - flag to determinate if upgrade of version is possible
required: false
aliases: ['version_upgrade'] aliases: ['version_upgrade']
default: null default: true
publicly_accessible: publicly_accessible:
description: description:
- if the cluster is accessible publicly or not - if the cluster is accessible publicly or not
required: false default: false
default: null
encrypted: encrypted:
description: description:
- if the cluster is encrypted or not - if the cluster is encrypted or not
required: false default: false
default: null
elastic_ip: elastic_ip:
description: description:
- if the cluster has an elastic IP or not - if the cluster has an elastic IP or not
required: false
default: null default: null
new_cluster_identifier: new_cluster_identifier:
description: description:
- Only used when command=modify. - Only used when command=modify.
required: false
aliases: ['new_identifier'] aliases: ['new_identifier']
default: null default: null
wait: wait:
description: description:
- When command=create, modify or restore then wait for the database to enter the 'available' state. When command=delete wait for the database to be terminated. - When command=create, modify or restore then wait for the database to enter the 'available' state. When command=delete wait for the database to be terminated.
required: false
default: "no" default: "no"
choices: [ "yes", "no" ] choices: [ "yes", "no" ]
wait_timeout: wait_timeout:
@ -282,7 +261,7 @@ def create_cluster(module, redshift):
'cluster_version', 'allow_version_upgrade', 'cluster_version', 'allow_version_upgrade',
'number_of_nodes', 'publicly_accessible', 'number_of_nodes', 'publicly_accessible',
'encrypted', 'elastic_ip'): 'encrypted', 'elastic_ip'):
if module.params.get( p ): if p in module.params:
params[ p ] = module.params.get( p ) params[ p ] = module.params.get( p )
try: try:
@ -389,12 +368,11 @@ def modify_cluster(module, redshift):
'cluster_parameter_group_name', 'cluster_parameter_group_name',
'automated_snapshot_retention_period', 'port', 'cluster_version', 'automated_snapshot_retention_period', 'port', 'cluster_version',
'allow_version_upgrade', 'number_of_nodes', 'new_cluster_identifier'): 'allow_version_upgrade', 'number_of_nodes', 'new_cluster_identifier'):
if module.params.get(p): if p in module.params:
params[p] = module.params.get(p) params[p] = module.params.get(p)
try: try:
redshift.describe_clusters(identifier)['DescribeClustersResponse']['DescribeClustersResult']['Clusters'][0] redshift.describe_clusters(identifier)['DescribeClustersResponse']['DescribeClustersResult']['Clusters'][0]
changed = False
except boto.exception.JSONResponseError as e: except boto.exception.JSONResponseError as e:
try: try:
redshift.modify_cluster(identifier, **params) redshift.modify_cluster(identifier, **params)
@ -444,10 +422,10 @@ def main():
automated_snapshot_retention_period = dict(aliases=['retention_period']), automated_snapshot_retention_period = dict(aliases=['retention_period']),
port = dict(type='int'), port = dict(type='int'),
cluster_version = dict(aliases=['version'], choices=['1.0']), cluster_version = dict(aliases=['version'], choices=['1.0']),
allow_version_upgrade = dict(aliases=['version_upgrade'], type='bool'), allow_version_upgrade = dict(aliases=['version_upgrade'], type='bool', default=True),
number_of_nodes = dict(type='int'), number_of_nodes = dict(type='int'),
publicly_accessible = dict(type='bool'), publicly_accessible = dict(type='bool', default=False),
encrypted = dict(type='bool'), encrypted = dict(type='bool', default=False),
elastic_ip = dict(required=False), elastic_ip = dict(required=False),
new_cluster_identifier = dict(aliases=['new_identifier']), new_cluster_identifier = dict(aliases=['new_identifier']),
wait = dict(type='bool', default=False), wait = dict(type='bool', default=False),