From d0c74a770439fb09e016f097df3375c2245731f1 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 30 Jul 2019 16:49:54 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E5=8F=AA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=85=AC=E9=92=A5=E4=B8=8D=E6=8E=A8=E9=80=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/tasks.py | 48 ++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/apps/assets/tasks.py b/apps/assets/tasks.py index 8d057f897..f96e1faa5 100644 --- a/apps/assets/tasks.py +++ b/apps/assets/tasks.py @@ -374,10 +374,36 @@ def test_system_user_connectivity_period(): #### Push system user tasks #### def get_push_linux_system_user_tasks(system_user): - tasks = [] + tasks = [ + { + 'name': 'Add user {}'.format(system_user.username), + 'action': { + 'module': 'user', + 'args': 'name={} shell={} state=present'.format( + system_user.username, system_user.shell, + ), + } + }, + { + 'name': 'Check home dir exists', + 'action': { + 'module': 'stat', + 'args': 'path=/home/{}'.format(system_user.username) + }, + 'register': 'home_existed' + }, + { + 'name': "Set home dir permission", + 'action': { + 'module': 'file', + 'args': "path=/home/{0} owner={0} group={0} mode=700".format(system_user.username) + }, + 'when': 'home_existed.stat.exists == true' + } + ] if system_user.password: tasks.append({ - 'name': 'Add user {}'.format(system_user.username), + 'name': 'Set {} password'.format(system_user.username), 'action': { 'module': 'user', 'args': 'name={} shell={} state=present password={}'.format( @@ -386,24 +412,6 @@ def get_push_linux_system_user_tasks(system_user): ), } }) - tasks.extend([ - { - 'name': 'Check home dir exists', - 'action': { - 'module': 'stat', - 'args': 'path=/home/{}'.format(system_user.username) - }, - 'register': 'home_existed' - }, - { - 'name': "Set home dir permission", - 'action': { - 'module': 'file', - 'args': "path=/home/{0} owner={0} group={0} mode=700".format(system_user.username) - }, - 'when': 'home_existed.stat.exists == true' - } - ]) if system_user.public_key: tasks.append({ 'name': 'Set {} authorized key'.format(system_user.username),