Add hostname to generated user SSH key comment

The default is not very useful to sort between different
keys and user. Adding the hostname in the comment permit to later
sort them if you start to reuse the key and set them in different
servers. See https://github.com/ansible/ansible/pull/7420
for the rational.
reviewable/pr18780/r1
Michael Scherer 10 years ago
parent db5668b84c
commit 37d9903169

@ -159,7 +159,7 @@ options:
- Optionally specify the SSH key filename. - Optionally specify the SSH key filename.
ssh_key_comment: ssh_key_comment:
required: false required: false
default: ansible-generated default: ansible-generated on $HOSTNAME
version_added: "0.9" version_added: "0.9"
description: description:
- Optionally define the comment for the SSH key. - Optionally define the comment for the SSH key.
@ -198,6 +198,7 @@ import pwd
import grp import grp
import syslog import syslog
import platform import platform
import socket
try: try:
import spwd import spwd
@ -1453,7 +1454,7 @@ def main():
'bits': '2048', 'bits': '2048',
'type': 'rsa', 'type': 'rsa',
'passphrase': None, 'passphrase': None,
'comment': 'ansible-generated' 'comment': 'ansible-generated on %s' % socket.gethostname()
} }
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec = dict(

Loading…
Cancel
Save