From 869da89b353ad3d282bc70d6aeb55e7a963dbfb5 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 18 Jun 2015 07:59:32 -0400 Subject: [PATCH] Move the order of argument processing --- lib/ansible/modules/cloud/openstack/os_keypair.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_keypair.py b/lib/ansible/modules/cloud/openstack/os_keypair.py index c6794b4782..b404e6cc02 100644 --- a/lib/ansible/modules/cloud/openstack/os_keypair.py +++ b/lib/ansible/modules/cloud/openstack/os_keypair.py @@ -84,18 +84,16 @@ def main(): mutually_exclusive=[['public_key', 'public_key_file']]) module = AnsibleModule(argument_spec, **module_kwargs) - if module.params['public_key_file']: - public_key = open(module.params['public_key_file']).read() - else: - public_key = module.params['public_key'] - - if not HAS_SHADE: - module.fail_json(msg='shade is required for this module') - state = module.params['state'] name = module.params['name'] public_key = module.params['public_key'] + if module.params['public_key_file']: + public_key = open(module.params['public_key_file']).read() + + if not HAS_SHADE: + module.fail_json(msg='shade is required for this module') + try: cloud = shade.openstack_cloud(**module.params)