Commit aee1a971 by Kesten Broughton

if key name already exists on tenant, check if public_key is offered that it…

if key name already exists on tenant, check if public_key is offered that it matches the existing key
parent c6f3a0a4
...@@ -115,7 +115,10 @@ def main(): ...@@ -115,7 +115,10 @@ def main():
if module.params['state'] == 'present': if module.params['state'] == 'present':
for key in nova.keypairs.list(): for key in nova.keypairs.list():
if key.name == module.params['name']: 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: try:
key = nova.keypairs.create(module.params['name'], module.params['public_key']) key = nova.keypairs.create(module.params['name'], module.params['public_key'])
except Exception, e: except Exception, e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment