1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

if key name already exists on tenant, check if public_key is offered that it matches the existing key

This commit is contained in:
Kesten Broughton 2014-05-02 11:09:54 -05:00
parent c6f3a0a4cc
commit aee1a97102

View file

@ -115,7 +115,10 @@ def main():
if module.params['state'] == 'present':
for key in nova.keypairs.list():
if key.name == module.params['name']:
module.exit_json(changed = False, result = "Key present")
if module.params['public_key'] and (module.params['public_key'] != key.public_key ):
module.fail_json(msg = "name {} present but key hash not the same as offered. Delete key first.".format(key['name']))
else:
module.exit_json(changed = False, result = "Key present")
try:
key = nova.keypairs.create(module.params['name'], module.params['public_key'])
except Exception, e: