Use shared ec2 module snippet in elasticache module

reviewable/pr18780/r1
James Tanner 11 years ago
parent a63ecf23cd
commit e6bd870959

@ -479,11 +479,11 @@ def main():
cache_security_groups={'required': False, 'default': ['default'],
'type': 'list'},
zone={'required': False, 'default': None},
aws_secret_key={'default': None,
'aliases': ['ec2_secret_key', 'secret_key'],
ec2_secret_key={'default': None,
'aliases': ['aws_secret_key', 'secret_key'],
'no_log': True},
aws_access_key={'default': None,
'aliases': ['ec2_access_key', 'access_key']},
ec2_access_key={'default': None,
'aliases': ['aws_access_key', 'access_key']},
region={'default': None, 'required': False,
'aliases': ['aws_region', 'ec2_region'],
'choices': AWS_REGIONS},
@ -492,9 +492,7 @@ def main():
)
)
aws_secret_key = module.params['aws_secret_key']
aws_access_key = module.params['aws_access_key']
region = module.params['region']
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
name = module.params['name']
state = module.params['state']
@ -511,24 +509,6 @@ def main():
if state == 'present' and not num_nodes:
module.fail_json(msg="'num_nodes' is a required parameter. Please specify num_nodes > 0")
if not aws_secret_key:
if 'AWS_SECRET_KEY' in os.environ:
aws_secret_key = os.environ['AWS_SECRET_KEY']
elif 'EC2_SECRET_KEY' in os.environ:
aws_secret_key = os.environ['EC2_SECRET_KEY']
if not aws_access_key:
if 'AWS_ACCESS_KEY' in os.environ:
aws_access_key = os.environ['AWS_ACCESS_KEY']
elif 'EC2_ACCESS_KEY' in os.environ:
aws_access_key = os.environ['EC2_ACCESS_KEY']
if not region:
if 'AWS_REGION' in os.environ:
region = os.environ['AWS_REGION']
elif 'EC2_REGION' in os.environ:
region = os.environ['EC2_REGION']
if not region:
module.fail_json(msg=str("Either region or EC2_REGION environment variable must be set."))
@ -551,7 +531,8 @@ def main():
module.exit_json(**facts_result)
# this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.ec2 import *
main()

Loading…
Cancel
Save