Rebase attempt

No idea if I'm rebasing properly or not.  This is my first attempt.
This commit is contained in:
Bruce Pennypacker 2013-08-13 09:30:56 -04:00
commit 0f458210bc
8 changed files with 335 additions and 218 deletions

View file

@ -43,10 +43,10 @@ options:
aliases: []
region:
description:
- The AWS region the stack will be launched in
- The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used.
required: true
default: null
aliases: []
aliases: ['aws_region', 'ec2_region']
state:
description:
- If state is "present", stack will be created. If state is "present" and if stack exists and template has changed, it will be updated.
@ -81,10 +81,24 @@ tasks:
ClusterSize: 3
'''
import boto.cloudformation.connection
import json
import time
try:
import boto.cloudformation.connection
except ImportError:
print "failed=True msg='boto required for this module'"
sys.exit(1)
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']
class Region:
def __init__(self, region):
'''connects boto to the region specified in the cloudformation template'''
@ -146,11 +160,7 @@ def main():
argument_spec=dict(
stack_name=dict(required=True),
template_parameters=dict(required=False),
region=dict(required=True,
choices=['ap-northeast-1', 'ap-southeast-1',
'ap-southeast-2', 'eu-west-1',
'sa-east-1', 'us-east-1', 'us-west-1',
'us-west-2']),
region=dict(aliases=['aws_region', 'ec2_region'], required=True, choices=AWS_REGIONS),
state=dict(default='present', choices=['present', 'absent']),
template=dict(default=None, required=True),
disable_rollback=dict(default=False)
@ -159,16 +169,25 @@ def main():
state = module.params['state']
stack_name = module.params['stack_name']
region = Region(module.params['region'])
r = module.params['region']
template_body = open(module.params['template'], 'r').read()
disable_rollback = module.params['disable_rollback']
template_parameters = module.params['template_parameters']
if not r:
if 'AWS_REGION' in os.environ:
r = os.environ['AWS_REGION']
elif 'EC2_REGION' in os.environ:
r = os.environ['EC2_REGION']
# convert the template parameters ansible passes into a tuple for boto
template_parameters_tup = [(k, v) for k, v in template_parameters.items()]
stack_outputs = {}
try:
region = Region(r)
cfn = boto.cloudformation.connection.CloudFormationConnection(
region=region)
except boto.exception.NoAuthHandlerFound, e: