if key name already exists on tenant, check if public_key is offered that it matches the existing key
This commit is contained in:
parent
84173035ea
commit
068cb9af59
1 changed files with 4 additions and 1 deletions
|
@ -115,6 +115,9 @@ def main():
|
|||
if module.params['state'] == 'present':
|
||||
for key in nova.keypairs.list():
|
||||
if key.name == module.params['name']:
|
||||
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'])
|
||||
|
|
Loading…
Reference in a new issue