mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #7478 from sivel/rax-keypair-filepath
rax_keypair module: Allow public_key to be a path to a file
This commit is contained in:
commit
d52b50cb03
1 changed files with 10 additions and 1 deletions
|
@ -30,7 +30,7 @@ options:
|
||||||
required: true
|
required: true
|
||||||
public_key:
|
public_key:
|
||||||
description:
|
description:
|
||||||
- Public Key string to upload
|
- Public Key string to upload. Can be a file path or string
|
||||||
default: null
|
default: null
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
|
@ -43,6 +43,7 @@ author: Matt Martz
|
||||||
notes:
|
notes:
|
||||||
- Keypairs cannot be manipulated, only created and deleted. To "update" a
|
- Keypairs cannot be manipulated, only created and deleted. To "update" a
|
||||||
keypair you must first delete and then recreate.
|
keypair you must first delete and then recreate.
|
||||||
|
- The ability to specify a file path for the public key was added in 1.7
|
||||||
extends_documentation_fragment: rackspace.openstack
|
extends_documentation_fragment: rackspace.openstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -116,6 +117,14 @@ def rax_keypair(module, name, public_key, state):
|
||||||
keypair = {}
|
keypair = {}
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
|
if os.path.isfile(public_key):
|
||||||
|
try:
|
||||||
|
f = open(public_key)
|
||||||
|
public_key = f.read()
|
||||||
|
f.close()
|
||||||
|
except Exception, e:
|
||||||
|
module.fail_json(msg='Failed to load %s' % public_key)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
keypair = cs.keypairs.find(name=name)
|
keypair = cs.keypairs.find(name=name)
|
||||||
except cs.exceptions.NotFound:
|
except cs.exceptions.NotFound:
|
||||||
|
|
Loading…
Reference in a new issue