Skip to content

Commit

Permalink
1.优化ansible支持普通用户sudo
Browse files Browse the repository at this point in the history
2.修复在线添加剧本,异步记录日志bug
  • Loading branch information
welliamcao committed Dec 23, 2017
1 parent 20dbaed commit 7cbb919
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 110 deletions.
102 changes: 0 additions & 102 deletions OpsManage/sudoterminal.py

This file was deleted.

8 changes: 4 additions & 4 deletions OpsManage/utils/ansible_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ def __initializeData(self,kwargs):
self.variable_manager = VariableManager()
self.loader = DataLoader()
self.options = Options(connection='smart', module_path=None, forks=100, timeout=10,
remote_user='root', ask_pass=False, private_key_file=None, ssh_common_args=None,
remote_user=kwargs.get('remote_user','root'), ask_pass=False, private_key_file=None, ssh_common_args=None,
ssh_extra_args=None,sftp_extra_args=None, scp_extra_args=None, become=None,
become_method=None,become_user='root', ask_value_pass=False,
verbosity=kwargs.get('verbosity',None),check=False, listhosts=False,
listtasks=False, listtags=False, syntax=False)
become_method=kwargs.get('become_method',None),become_user=kwargs.get('become_user','root'),
verbosity=kwargs.get('verbosity',None),check=False, listhosts=False,
listtasks=False, listtags=False, syntax=False,ask_value_pass=False, )

self.passwords = dict(sshpass=None, becomepass=None)
self.inventory = MyInventory(self.resource, self.loader, self.variable_manager).inventory
Expand Down
7 changes: 3 additions & 4 deletions OpsManage/views/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ def apps_playbook_modf(request,pid):
Ansible_Playbook_Number.objects.filter(playbook=playbook,playbook_server=ip).delete()
else:
for server in numberList:
Ansible_Playbook_Number.objects.filter(playbook=playbook,playbook_server=server.playbook_server).delete()
AnsibleRecord.PlayBook.insert(user=str(request.user),ans_id=playbook.id,ans_name=playbook.playbook_name,ans_content="修改Ansible剧本",ans_server=None)
Ansible_Playbook_Number.objects.filter(playbook=playbook,playbook_server=server.playbook_server).delete()
AnsibleRecord.PlayBook.insert(user=str(request.user),ans_id=playbook.id,ans_name=playbook.playbook_name,ans_content="修改Ansible剧本",ans_server=','.join(sList))
return HttpResponseRedirect('/apps/playbook/modf/{id}/'.format(id=pid))


Expand Down Expand Up @@ -448,7 +448,6 @@ def apps_playbook_online_modf(request,pid):
if sip not in tagret_server_list:
Ansible_Playbook_Number.objects.create(playbook=playbook,playbook_server=sip)
except Exception,e:
print e
return render(request,'apps/apps_playbook_modf.html',{"user":request.user,
"errorInfo":"目标服务器信息修改错误:%s" % str(e)},
)
Expand All @@ -459,7 +458,7 @@ def apps_playbook_online_modf(request,pid):
else:
for server in numberList:
Ansible_Playbook_Number.objects.filter(playbook=playbook,playbook_server=server.playbook_server).delete()
AnsibleRecord.PlayBook.insert(user=str(request.user),ans_id=playbook.id,ans_name=playbook.playbook_name,ans_content="修改Ansible剧本",ans_server=None)
AnsibleRecord.PlayBook.insert(user=str(request.user),ans_id=playbook.id,ans_name=playbook.playbook_name,ans_content="修改Ansible剧本",ans_server=','.join(sList))
return JsonResponse({'msg':"更新成功","code":200,'data':[]})

@login_required(login_url='/login')
Expand Down

0 comments on commit 7cbb919

Please sign in to comment.