Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
deb33e9d
Commit
deb33e9d
authored
Nov 12, 2013
by
jctanner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4272 from psvo/tags_parameter_for_cloudformation
Add support for tags parameter to cloudformation module
parents
dc41bb80
5e4fff98
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
library/cloud/cloudformation
+34
-4
No files found.
library/cloud/cloudformation
View file @
deb33e9d
...
@@ -60,6 +60,14 @@ options:
...
@@ -60,6 +60,14 @@ options:
required: true
required: true
default: null
default: null
aliases: []
aliases: []
tags:
description:
- Dictionary of tags to associate with stack and it's resources during stack creation. Cannot be updated later.
Requires at least Boto version 2.6.0.
required: false
default: null
aliases: []
version_added: "1.4"
requirements: [ "boto" ]
requirements: [ "boto" ]
author: James S. Martin
author: James S. Martin
...
@@ -79,12 +87,15 @@ tasks:
...
@@ -79,12 +87,15 @@ tasks:
DiskType: ephemeral
DiskType: ephemeral
InstanceType: m1.small
InstanceType: m1.small
ClusterSize: 3
ClusterSize: 3
tags:
Stack: ansible-cloudformation
'''
'''
import
json
import
json
import
time
import
time
try
:
try
:
import
boto
import
boto.cloudformation.connection
import
boto.cloudformation.connection
except
ImportError
:
except
ImportError
:
print
"failed=True msg='boto required for this module'"
print
"failed=True msg='boto required for this module'"
...
@@ -118,6 +129,17 @@ def boto_exception(err):
...
@@ -118,6 +129,17 @@ def boto_exception(err):
return
error
return
error
def
boto_version_required
(
version_tuple
):
parts
=
boto
.
Version
.
split
(
'.'
)
boto_version
=
[]
try
:
for
part
in
parts
:
boto_version
.
append
(
int
(
part
))
except
:
boto_version
.
append
(
-
1
)
return
tuple
(
boto_version
)
>=
tuple
(
version_tuple
)
def
stack_operation
(
cfn
,
stack_name
,
operation
):
def
stack_operation
(
cfn
,
stack_name
,
operation
):
'''gets the status of a stack while it is created/updated/deleted'''
'''gets the status of a stack while it is created/updated/deleted'''
existed
=
[]
existed
=
[]
...
@@ -163,7 +185,8 @@ def main():
...
@@ -163,7 +185,8 @@ def main():
region
=
dict
(
aliases
=
[
'aws_region'
,
'ec2_region'
],
required
=
True
,
choices
=
AWS_REGIONS
),
region
=
dict
(
aliases
=
[
'aws_region'
,
'ec2_region'
],
required
=
True
,
choices
=
AWS_REGIONS
),
state
=
dict
(
default
=
'present'
,
choices
=
[
'present'
,
'absent'
]),
state
=
dict
(
default
=
'present'
,
choices
=
[
'present'
,
'absent'
]),
template
=
dict
(
default
=
None
,
required
=
True
),
template
=
dict
(
default
=
None
,
required
=
True
),
disable_rollback
=
dict
(
default
=
False
)
disable_rollback
=
dict
(
default
=
False
),
tags
=
dict
(
default
=
None
)
)
)
)
)
...
@@ -173,14 +196,20 @@ def main():
...
@@ -173,14 +196,20 @@ def main():
template_body
=
open
(
module
.
params
[
'template'
],
'r'
)
.
read
()
template_body
=
open
(
module
.
params
[
'template'
],
'r'
)
.
read
()
disable_rollback
=
module
.
params
[
'disable_rollback'
]
disable_rollback
=
module
.
params
[
'disable_rollback'
]
template_parameters
=
module
.
params
[
'template_parameters'
]
template_parameters
=
module
.
params
[
'template_parameters'
]
tags
=
module
.
params
[
'tags'
]
if
not
r
:
if
not
r
:
if
'AWS_REGION'
in
os
.
environ
:
if
'AWS_REGION'
in
os
.
environ
:
r
=
os
.
environ
[
'AWS_REGION'
]
r
=
os
.
environ
[
'AWS_REGION'
]
elif
'EC2_REGION'
in
os
.
environ
:
elif
'EC2_REGION'
in
os
.
environ
:
r
=
os
.
environ
[
'EC2_REGION'
]
r
=
os
.
environ
[
'EC2_REGION'
]
kwargs
=
dict
()
if
tags
is
not
None
:
if
not
boto_version_required
((
2
,
6
,
0
)):
module
.
fail_json
(
msg
=
'Module parameter "tags" requires at least Boto version 2.6.0'
)
kwargs
[
'tags'
]
=
tags
# convert the template parameters ansible passes into a tuple for boto
# convert the template parameters ansible passes into a tuple for boto
template_parameters_tup
=
[(
k
,
v
)
for
k
,
v
in
template_parameters
.
items
()]
template_parameters_tup
=
[(
k
,
v
)
for
k
,
v
in
template_parameters
.
items
()]
...
@@ -203,7 +232,8 @@ def main():
...
@@ -203,7 +232,8 @@ def main():
cfn
.
create_stack
(
stack_name
,
parameters
=
template_parameters_tup
,
cfn
.
create_stack
(
stack_name
,
parameters
=
template_parameters_tup
,
template_body
=
template_body
,
template_body
=
template_body
,
disable_rollback
=
disable_rollback
,
disable_rollback
=
disable_rollback
,
capabilities
=
[
'CAPABILITY_IAM'
])
capabilities
=
[
'CAPABILITY_IAM'
],
**
kwargs
)
operation
=
'CREATE'
operation
=
'CREATE'
except
Exception
,
err
:
except
Exception
,
err
:
error_msg
=
boto_exception
(
err
)
error_msg
=
boto_exception
(
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment