diff --git a/cloud/openstack/os_keypair.py b/cloud/openstack/os_keypair.py index f62cc51bf64..64ebd8c67be 100644 --- a/cloud/openstack/os_keypair.py +++ b/cloud/openstack/os_keypair.py @@ -146,10 +146,14 @@ def main(): " as offered. Delete key first." % name ) else: - module.exit_json(changed=False, key=keypair) - - new_key = cloud.create_keypair(name, public_key) - module.exit_json(changed=True, key=new_key) + changed = False + else: + keypair = cloud.create_keypair(name, public_key) + changed = True + + module.exit_json(changed=changed, + key=keypair, + id=keypair['id']) elif state == 'absent': if keypair: