From 41315b2cd94f3136ae7ba7f31ac7b69daf2514b0 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Wed, 12 Aug 2015 21:53:49 +0200 Subject: [PATCH] cloudstack: cs_template: fix state=absent must not need vm, url only for state=present, fixes example. --- .../modules/extras/cloud/cloudstack/cs_template.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py index 11e2cc747cc..9539442d06e 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py @@ -596,9 +596,6 @@ def main(): ['api_key', 'api_secret', 'api_url'], ['format', 'url', 'hypervisor'], ), - required_one_of = ( - ['url', 'vm'], - ), supports_check_mode=True ) @@ -612,11 +609,12 @@ def main(): if state in ['absent']: tpl = acs_tpl.remove_template() else: - url = module.params.get('url') - if url: + if module.params.get('url'): tpl = acs_tpl.register_template() - else: + elif module.params.get('vm'): tpl = acs_tpl.create_template() + else: + module.fail_json(msg="one of the following is required on state=present: url,vm") result = acs_tpl.get_result(tpl)