mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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.
This commit is contained in:
parent
0d3b144eb2
commit
36c653f54a
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||||
|
@ -1463,7 +1464,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…
Reference in a new issue