diff --git a/lib/ansible/modules/cloud/openstack/os_keypair.py b/lib/ansible/modules/cloud/openstack/os_keypair.py index c6794b47826..b404e6cc02a 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) + 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() - 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'] - try: cloud = shade.openstack_cloud(**module.params)