mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Create SSH Keys always after creating $HOME
This commit is contained in:
parent
ad9379ad7d
commit
aca24caa19
1 changed files with 10 additions and 10 deletions
|
@ -1917,6 +1917,16 @@ def main():
|
||||||
if user.groups is not None:
|
if user.groups is not None:
|
||||||
result['groups'] = user.groups
|
result['groups'] = user.groups
|
||||||
|
|
||||||
|
# handle missing homedirs
|
||||||
|
info = user.user_info()
|
||||||
|
if user.home is None:
|
||||||
|
user.home = info[5]
|
||||||
|
if not os.path.exists(user.home) and user.createhome:
|
||||||
|
if not module.check_mode:
|
||||||
|
user.create_homedir(user.home)
|
||||||
|
user.chown_homedir(info[2], info[3], user.home)
|
||||||
|
result['changed'] = True
|
||||||
|
|
||||||
# deal with ssh key
|
# deal with ssh key
|
||||||
if user.sshkeygen:
|
if user.sshkeygen:
|
||||||
(rc, out, err) = user.ssh_key_gen()
|
(rc, out, err) = user.ssh_key_gen()
|
||||||
|
@ -1932,16 +1942,6 @@ def main():
|
||||||
result['ssh_key_file'] = user.get_ssh_key_path()
|
result['ssh_key_file'] = user.get_ssh_key_path()
|
||||||
result['ssh_public_key'] = user.get_ssh_public_key()
|
result['ssh_public_key'] = user.get_ssh_public_key()
|
||||||
|
|
||||||
# handle missing homedirs
|
|
||||||
info = user.user_info()
|
|
||||||
if user.home is None:
|
|
||||||
user.home = info[5]
|
|
||||||
if not os.path.exists(user.home) and user.createhome:
|
|
||||||
if not module.check_mode:
|
|
||||||
user.create_homedir(user.home)
|
|
||||||
user.chown_homedir(info[2], info[3], user.home)
|
|
||||||
result['changed'] = True
|
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
Loading…
Reference in a new issue