openssh_keypair - Add key `comment` to return output (#59268)

If the comment will be provided during the key creation, it will be
diplayed in the return values.
Same will be on the comment change.
This commit is contained in:
Maxim Babushkin 2019-08-11 14:47:34 +03:00 committed by Felix Fontein
parent 8da48b1a40
commit dda80c46e9
3 changed files with 18 additions and 0 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- openssh_keypair - add key ``comment`` to return value

View file

@ -113,6 +113,11 @@ public_key:
returned: changed or success
type: str
sample: ssh-rsa AAAAB3Nza(...omitted...)veL4E3Xcw== test_key
comment:
description: The comment of the generated key
returned: changed or success
type: str
sample: test@comment
'''
import os
@ -313,6 +318,7 @@ class Keypair(object):
# On removal this has no value
'fingerprint': self.fingerprint[1] if self.fingerprint else '',
'public_key': self.public_key,
'comment': self.comment if self.comment else '',
}
return result

View file

@ -97,3 +97,13 @@
assert:
that:
- privatekey7_result.public_key == privatekey7_modified_result.public_key
- name: Validate privatekey7 comment on creation
assert:
that:
- privatekey7_result.comment == 'test@privatekey7'
- name: Validate privatekey7 comment update
assert:
that:
- privatekey7_modified_result.comment == 'test_modified@privatekey7'