|
|
|
@ -21,7 +21,7 @@ description: Creates or destroys Amazon ELB.
|
|
|
|
|
short_description: Creates or destroys Amazon ELB.
|
|
|
|
|
- Returns information about the load balancer.
|
|
|
|
|
- Will be marked changed when called only if state is changed.
|
|
|
|
|
version_added: "1.4"
|
|
|
|
|
version_added: "1.5"
|
|
|
|
|
requirements: [ "boto" ]
|
|
|
|
|
author: Jim Dalton
|
|
|
|
|
options:
|
|
|
|
@ -161,15 +161,6 @@ EXAMPLES = """
|
|
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
AWS_REGIONS = ['ap-northeast-1',
|
|
|
|
|
'ap-southeast-1',
|
|
|
|
|
'ap-southeast-2',
|
|
|
|
|
'eu-west-1',
|
|
|
|
|
'sa-east-1',
|
|
|
|
|
'us-east-1',
|
|
|
|
|
'us-west-1',
|
|
|
|
|
'us-west-2']
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
import boto
|
|
|
|
|
import boto.ec2.elb
|
|
|
|
@ -459,20 +450,21 @@ def main():
|
|
|
|
|
purge_zones={'default': False, 'required': False,
|
|
|
|
|
'choices': BOOLEANS, 'type': 'bool'},
|
|
|
|
|
health_check={'default': None, 'required': False, 'type': 'dict'},
|
|
|
|
|
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},
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
aws_secret_key = module.params['aws_secret_key']
|
|
|
|
|
aws_access_key = module.params['aws_access_key']
|
|
|
|
|
region = module.params['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)
|
|
|
|
|
|
|
|
|
|
name = module.params['name']
|
|
|
|
|
state = module.params['state']
|
|
|
|
|
listeners = module.params['listeners']
|
|
|
|
@ -487,27 +479,6 @@ def main():
|
|
|
|
|
if state == 'present' and not zones:
|
|
|
|
|
module.fail_json(msg="At least one availability zone is required for ELB creation")
|
|
|
|
|
|
|
|
|
|
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."))
|
|
|
|
|
|
|
|
|
|
elb_man = ElbManager(module, name, listeners, purge_listeners, zones,
|
|
|
|
|
purge_zones, health_check, aws_access_key,
|
|
|
|
|
aws_secret_key, region=region)
|
|
|
|
@ -524,7 +495,8 @@ def main():
|
|
|
|
|
|
|
|
|
|
module.exit_json(**ec2_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()
|
|
|
|
|