|
|
@ -146,43 +146,21 @@ def main():
|
|
|
|
region = dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),
|
|
|
|
region = dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),
|
|
|
|
zone = dict(aliases=['availability_zone', 'aws_zone', 'ec2_zone']),
|
|
|
|
zone = dict(aliases=['availability_zone', 'aws_zone', 'ec2_zone']),
|
|
|
|
ec2_url = dict(),
|
|
|
|
ec2_url = dict(),
|
|
|
|
aws_secret_key = dict(aliases=['ec2_secret_key', 'secret_key'], no_log=True),
|
|
|
|
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
|
|
|
|
aws_access_key = dict(aliases=['ec2_access_key', 'access_key']),
|
|
|
|
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
|
|
|
|
|
|
|
instance = module.params.get('instance')
|
|
|
|
instance = module.params.get('instance')
|
|
|
|
volume_size = module.params.get('volume_size')
|
|
|
|
volume_size = module.params.get('volume_size')
|
|
|
|
iops = module.params.get('iops')
|
|
|
|
iops = module.params.get('iops')
|
|
|
|
device_name = module.params.get('device_name')
|
|
|
|
device_name = module.params.get('device_name')
|
|
|
|
region = module.params.get('region')
|
|
|
|
|
|
|
|
zone = module.params.get('zone')
|
|
|
|
zone = module.params.get('zone')
|
|
|
|
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')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If we have a region specified, connect to its endpoint.
|
|
|
|
# If we have a region specified, connect to its endpoint.
|
|
|
|
if region:
|
|
|
|
if region:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -274,7 +252,8 @@ def main():
|
|
|
|
})
|
|
|
|
})
|
|
|
|
sys.exit(0)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
|
|
# 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()
|
|
|
|