diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py index ebd0e17c490..a72f4aaa5ca 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_template.py @@ -470,6 +470,12 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack): def register_template(self): + required_params = [ + 'format', + 'url', + 'hypervisor', + ] + self.module.fail_on_missing_params(required_params=required_params) template = self.get_template() if not template: self.result['changed'] = True @@ -537,9 +543,6 @@ class AnsibleCloudStackTemplate(AnsibleCloudStack): args['mode'] = self.module.params.get('mode') args['zoneid'] = self.get_zone(key='id') - if not args['url']: - self.module.fail_json(msg="Missing required arguments: url") - self.result['changed'] = True if not self.module.check_mode: @@ -613,14 +616,9 @@ def main(): poll_async = dict(type='bool', choices=BOOLEANS, default=True), )) - required_together = cs_required_together() - required_together.extend([ - ['format', 'url', 'hypervisor'], - ]) - module = AnsibleModule( argument_spec=argument_spec, - required_together=required_together, + required_together=cs_required_together(), mutually_exclusive = ( ['url', 'vm'], ['zone', 'cross_zones'],