[Bugfix] 修复只设置公钥不推送的问题

pull/3053/head
ibuler 2019-07-30 16:49:54 +08:00
parent b5aa69db61
commit d0c74a7704
1 changed files with 28 additions and 20 deletions

View File

@ -374,19 +374,16 @@ def test_system_user_connectivity_period():
#### Push system user tasks ####
def get_push_linux_system_user_tasks(system_user):
tasks = []
if system_user.password:
tasks.append({
tasks = [
{
'name': 'Add user {}'.format(system_user.username),
'action': {
'module': 'user',
'args': 'name={} shell={} state=present password={}'.format(
'args': 'name={} shell={} state=present'.format(
system_user.username, system_user.shell,
encrypt_password(system_user.password, salt="K3mIlKK"),
),
}
})
tasks.extend([
},
{
'name': 'Check home dir exists',
'action': {
@ -403,7 +400,18 @@ def get_push_linux_system_user_tasks(system_user):
},
'when': 'home_existed.stat.exists == true'
}
])
]
if system_user.password:
tasks.append({
'name': 'Set {} password'.format(system_user.username),
'action': {
'module': 'user',
'args': 'name={} shell={} state=present password={}'.format(
system_user.username, system_user.shell,
encrypt_password(system_user.password, salt="K3mIlKK"),
),
}
})
if system_user.public_key:
tasks.append({
'name': 'Set {} authorized key'.format(system_user.username),