From 1a8b9b8935a97f49f042e5653dd7bfbd759ee3be Mon Sep 17 00:00:00 2001 From: Harald Skoglund Date: Thu, 11 Dec 2014 16:41:25 +0100 Subject: [PATCH] add support for stack policies in cloudformation --- lib/ansible/modules/cloud/amazon/cloudformation.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/ansible/modules/cloud/amazon/cloudformation.py b/lib/ansible/modules/cloud/amazon/cloudformation.py index 72b970cd26..631189bc43 100644 --- a/lib/ansible/modules/cloud/amazon/cloudformation.py +++ b/lib/ansible/modules/cloud/amazon/cloudformation.py @@ -60,6 +60,13 @@ options: required: true default: null aliases: [] + stack_policy: + description: + - the path of the cloudformation stack policy + required: false + default: null + aliases: [] + version_added: "x.x" tags: description: - Dictionary of tags to associate with stack and it's resources during stack creation. Cannot be updated later. @@ -196,6 +203,7 @@ def main(): template_parameters=dict(required=False, type='dict', default={}), state=dict(default='present', choices=['present', 'absent']), template=dict(default=None, required=True), + stack_policy=dict(default=None, required=False), disable_rollback=dict(default=False, type='bool'), tags=dict(default=None) ) @@ -208,6 +216,10 @@ def main(): state = module.params['state'] stack_name = module.params['stack_name'] template_body = open(module.params['template'], 'r').read() + if module.params['stack_policy'] is not None: + stack_policy_body = open(module.params['stack_policy'], 'r').read() + else: + stack_policy_body = None disable_rollback = module.params['disable_rollback'] template_parameters = module.params['template_parameters'] tags = module.params['tags'] @@ -244,6 +256,7 @@ def main(): try: cfn.create_stack(stack_name, parameters=template_parameters_tup, template_body=template_body, + stack_policy_body=stack_policy_body, disable_rollback=disable_rollback, capabilities=['CAPABILITY_IAM'], **kwargs) @@ -264,6 +277,7 @@ def main(): try: cfn.update_stack(stack_name, parameters=template_parameters_tup, template_body=template_body, + stack_policy_body=stack_policy_body, disable_rollback=disable_rollback, capabilities=['CAPABILITY_IAM']) operation = 'UPDATE'