From 845b6d78be49de4ceb138ffa49d1f5dc65833786 Mon Sep 17 00:00:00 2001 From: "Oleg A. Mamontov" Date: Fri, 27 Feb 2015 14:39:18 +0300 Subject: [PATCH] On FreeBSD apply 'login_class' only if there is real change. --- lib/ansible/modules/system/user.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/system/user.py b/lib/ansible/modules/system/user.py index e4a5280671..4f96ab1e80 100755 --- a/lib/ansible/modules/system/user.py +++ b/lib/ansible/modules/system/user.py @@ -797,8 +797,17 @@ class FreeBsdUser(User): cmd.append(self.shell) if self.login_class is not None: - cmd.append('-L') - cmd.append(self.login_class) + # find current login class + user_login_class = None + if os.path.exists(self.SHADOWFILE) and os.access(self.SHADOWFILE, os.R_OK): + for line in open(self.SHADOWFILE).readlines(): + if line.startswith('%s:' % self.name): + user_login_class = line.split(':')[4] + + # act only if login_class change + if self.login_class != user_login_class: + cmd.append('-L') + cmd.append(self.login_class) if self.groups is not None: current_groups = self.user_group_membership()