From aca24caa197d14f893b064dd945da5791ef6e6ee Mon Sep 17 00:00:00 2001 From: "Stefan J. Betz" Date: Thu, 18 Dec 2014 22:47:09 +0100 Subject: [PATCH] Create SSH Keys always after creating $HOME --- lib/ansible/modules/system/user.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ansible/modules/system/user.py b/lib/ansible/modules/system/user.py index 0939faf313..e4a5280671 100755 --- a/lib/ansible/modules/system/user.py +++ b/lib/ansible/modules/system/user.py @@ -1917,6 +1917,16 @@ def main(): if user.groups is not None: 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 if user.sshkeygen: (rc, out, err) = user.ssh_key_gen() @@ -1932,16 +1942,6 @@ def main(): result['ssh_key_file'] = user.get_ssh_key_path() 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) # import module snippets