|
|
|
@ -573,8 +573,8 @@ def main():
|
|
|
|
|
wait = dict(type='bool', default=False),
|
|
|
|
|
wait_timeout = dict(default=300),
|
|
|
|
|
ec2_url = dict(),
|
|
|
|
|
aws_secret_key = dict(aliases=['ec2_secret_key', 'secret_key'], no_log=True),
|
|
|
|
|
aws_access_key = dict(aliases=['ec2_access_key', 'access_key']),
|
|
|
|
|
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
|
|
|
|
|
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
|
|
|
|
|
placement_group = dict(),
|
|
|
|
|
user_data = dict(),
|
|
|
|
|
instance_tags = dict(type='dict'),
|
|
|
|
@ -586,33 +586,9 @@ def main():
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
ec2_url = module.params.get('ec2_url')
|
|
|
|
|
aws_secret_key = module.params.get('aws_secret_key')
|
|
|
|
|
aws_access_key = module.params.get('aws_access_key')
|
|
|
|
|
region = module.params.get('region')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# allow eucarc environment variables to be used if ansible vars aren't set
|
|
|
|
|
if not ec2_url and 'EC2_URL' in os.environ:
|
|
|
|
|
ec2_url = os.environ['EC2_URL']
|
|
|
|
|
|
|
|
|
|
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']
|
|
|
|
|
# def get_ec2_creds(module):
|
|
|
|
|
# return ec2_url, ec2_access_key, ec2_secret_key, region
|
|
|
|
|
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
|
|
|
|
|
|
|
|
|
|
# If we have a region specified, connect to its endpoint.
|
|
|
|
|
if region:
|
|
|
|
@ -646,8 +622,8 @@ def main():
|
|
|
|
|
|
|
|
|
|
module.exit_json(changed=changed, instance_ids=new_instance_ids, instances=instance_dict_array)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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()
|
|
|
|
|