diff options
author | Brian Coca <bcoca@ansible.com> | 2015-03-30 08:56:56 -0400 |
---|---|---|
committer | Brian Coca <bcoca@ansible.com> | 2015-03-30 08:56:56 -0400 |
commit | d27df0cdb4868ddea8956ab03ce398edc534017a (patch) | |
tree | 3ca88eb2a794fda7c71ddfb6b8d2ad12cb63f814 | |
parent | 1865ddbbdf1e8fa312c26b613fd28a98151023d1 (diff) | |
parent | 8a4e7e5d9fa36bcb21b9ac3f486a677f280b7a36 (diff) | |
download | ansible-modules-core-d27df0cdb4868ddea8956ab03ce398edc534017a.tar.gz |
Merge pull request #334 from adamchainz/cloudformation_dont_always_need_template
Make cloudformation module's template argument not required in case of stack deletion
-rw-r--r-- | cloud/amazon/cloudformation.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/cloud/amazon/cloudformation.py b/cloud/amazon/cloudformation.py index 398cea36..4253b63c 100644 --- a/cloud/amazon/cloudformation.py +++ b/cloud/amazon/cloudformation.py @@ -17,7 +17,7 @@ DOCUMENTATION = ''' --- module: cloudformation -short_description: create a AWS CloudFormation stack +short_description: Create or delete an AWS CloudFormation stack description: - Launches an AWS CloudFormation stack and waits for it complete. version_added: "1.1" @@ -50,8 +50,8 @@ options: aliases: [] template: description: - - the path of the cloudformation template - required: true + - The path of the cloudformation template, required if state is "present". + required: false default: null aliases: [] stack_policy: @@ -98,6 +98,13 @@ tasks: ClusterSize: 3 tags: Stack: "ansible-cloudformation" + +# Removal example +tasks: +- name: tear down old deployment + cloudformation: + stack_name: "ansible-cloudformation-old" + state: "absent" ''' import json @@ -190,7 +197,7 @@ def main(): stack_name=dict(required=True), template_parameters=dict(required=False, type='dict', default={}), state=dict(default='present', choices=['present', 'absent']), - template=dict(default=None, required=True), + template=dict(default=None, required=False), stack_policy=dict(default=None, required=False), disable_rollback=dict(default=False, type='bool'), tags=dict(default=None) @@ -205,7 +212,14 @@ def main(): state = module.params['state'] stack_name = module.params['stack_name'] - template_body = open(module.params['template'], 'r').read() + + if module.params['template'] is not None: + template_body = open(module.params['template'], 'r').read() + else: + template_body = None + if state == 'present': + module.fail_json('Module parameter "template" is required if "state" is "present"') + if module.params['stack_policy'] is not None: stack_policy_body = open(module.params['stack_policy'], 'r').read() else: |