From 37d99031693cb9672d4337bd8c2f1935531ced94 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Mon, 29 Sep 2014 18:07:41 -0400 Subject: [PATCH] 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. --- system/user.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/system/user.py b/system/user.py index 551384a7a67..95e48b4a21a 100644 --- a/system/user.py +++ b/system/user.py @@ -159,7 +159,7 @@ options: - Optionally specify the SSH key filename. ssh_key_comment: required: false - default: ansible-generated + default: ansible-generated on $HOSTNAME version_added: "0.9" description: - Optionally define the comment for the SSH key. @@ -198,6 +198,7 @@ import pwd import grp import syslog import platform +import socket try: import spwd @@ -1453,7 +1454,7 @@ def main(): 'bits': '2048', 'type': 'rsa', 'passphrase': None, - 'comment': 'ansible-generated' + 'comment': 'ansible-generated on %s' % socket.gethostname() } module = AnsibleModule( argument_spec = dict(