From 9f7287acc241a28814e75e2e0c1aa6e14f969f7b Mon Sep 17 00:00:00 2001 From: Steve Brasier Date: Sat, 17 Feb 2024 09:28:14 +0000 Subject: [PATCH] don't crash when removing basic_users --- .../basic_users/library/terminate_user_sessions.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ansible/roles/basic_users/library/terminate_user_sessions.py b/ansible/roles/basic_users/library/terminate_user_sessions.py index 2ce71137b..711b3732f 100644 --- a/ansible/roles/basic_users/library/terminate_user_sessions.py +++ b/ansible/roles/basic_users/library/terminate_user_sessions.py @@ -56,13 +56,11 @@ def run_module(): _, sessions_stdout, _ = module.run_command("loginctl --no-legend list-sessions", check_rc=True) for line in sessions_stdout.splitlines(): - try: - session, uid, user = line.split() - except ValueError: - raise ValueError('failed to split "%s"' % line) - + session_info = line.split() + user = session_info[1] + session_id = session_info[0] if user == module.params['user']: - _, sessions_stdout, _ = module.run_command("loginctl terminate-session %s" % session, check_rc=True) + _, sessions_stdout, _ = module.run_command("loginctl terminate-session %s" % session_id, check_rc=True) result['changed'] = True # successful module exit: