Use shared ec2 module snippet in elasticache module
This commit is contained in:
parent
fd6b16aca8
commit
d0986a20a3
1 changed files with 8 additions and 27 deletions
|
@ -479,11 +479,11 @@ def main():
|
||||||
cache_security_groups={'required': False, 'default': ['default'],
|
cache_security_groups={'required': False, 'default': ['default'],
|
||||||
'type': 'list'},
|
'type': 'list'},
|
||||||
zone={'required': False, 'default': None},
|
zone={'required': False, 'default': None},
|
||||||
aws_secret_key={'default': None,
|
ec2_secret_key={'default': None,
|
||||||
'aliases': ['ec2_secret_key', 'secret_key'],
|
'aliases': ['aws_secret_key', 'secret_key'],
|
||||||
'no_log': True},
|
'no_log': True},
|
||||||
aws_access_key={'default': None,
|
ec2_access_key={'default': None,
|
||||||
'aliases': ['ec2_access_key', 'access_key']},
|
'aliases': ['aws_access_key', 'access_key']},
|
||||||
region={'default': None, 'required': False,
|
region={'default': None, 'required': False,
|
||||||
'aliases': ['aws_region', 'ec2_region'],
|
'aliases': ['aws_region', 'ec2_region'],
|
||||||
'choices': AWS_REGIONS},
|
'choices': AWS_REGIONS},
|
||||||
|
@ -492,9 +492,7 @@ def main():
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
aws_secret_key = module.params['aws_secret_key']
|
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
||||||
aws_access_key = module.params['aws_access_key']
|
|
||||||
region = module.params['region']
|
|
||||||
|
|
||||||
name = module.params['name']
|
name = module.params['name']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
@ -511,24 +509,6 @@ def main():
|
||||||
if state == 'present' and not num_nodes:
|
if state == 'present' and not num_nodes:
|
||||||
module.fail_json(msg="'num_nodes' is a required parameter. Please specify num_nodes > 0")
|
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:
|
if not region:
|
||||||
module.fail_json(msg=str("Either region or EC2_REGION environment variable must be set."))
|
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)
|
module.exit_json(**facts_result)
|
||||||
|
|
||||||
# this is magic, see lib/ansible/module_common.py
|
# import module snippets
|
||||||
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
from ansible.module_utils.basic import *
|
||||||
|
from ansible.module_utils.ec2 import *
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue