From 531de188d651504092a3b4425c34ab50495d6f47 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 3 Nov 2020 13:38:51 +0800 Subject: [PATCH] =?UTF-8?q?perf(systemuser):=20=E4=BC=98=E5=8C=96=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=94=A8=E6=88=B7=E5=AE=B6=E7=9B=AE=E5=BD=95=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/tasks/push_system_user.py | 35 +++++++++++++++------------ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/apps/assets/tasks/push_system_user.py b/apps/assets/tasks/push_system_user.py index 719f6b278..0072a862a 100644 --- a/apps/assets/tasks/push_system_user.py +++ b/apps/assets/tasks/push_system_user.py @@ -66,24 +66,27 @@ def get_push_unixlike_system_user_tasks(system_user, username=None): 'module': 'group', 'args': 'name={} state=present'.format(username), } - }, - { - 'name': 'Check home dir exists', - 'action': { - 'module': 'stat', - 'args': 'path=/home/{}'.format(username) - }, - 'register': 'home_existed' - }, - { - 'name': "Set home dir permission", - 'action': { - 'module': 'file', - 'args': "path=/home/{0} owner={0} group={0} mode=700".format(username) - }, - 'when': 'home_existed.stat.exists == true' } ] + if not system_user.home: + tasks.extend([ + { + 'name': 'Check home dir exists', + 'action': { + 'module': 'stat', + 'args': 'path=/home/{}'.format(username) + }, + 'register': 'home_existed' + }, + { + 'name': "Set home dir permission", + 'action': { + 'module': 'file', + 'args': "path=/home/{0} owner={0} group={0} mode=700".format(username) + }, + 'when': 'home_existed.stat.exists == true' + } + ]) if password: tasks.append({ 'name': 'Set {} password'.format(username),