mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-17 15:59:04 +00:00
Dev ansible windows 2 (#2783)
* [Update] 改密支持windows * [Update] 修改asset表结构 * [Feature] Windows支持批量改密、测试可连接性等功能 * [Update] 处理创建资产时labels的问题 * [Update] 优化测试管理系统、系统用户可连接性任务执行逻辑 * [Update] 优化ansible任务逻辑;添加自动推送rdp系统用户功能 * [Update] 添加翻译 * [Update] 优化ansible任务逻辑(测试系统用户可连接性, 通过协议过滤资产) * [Update] 更新翻译 * [Update] 更新翻译 * [Update] 推送windows系统用户,默认添加到Users、Remote Desktop Users组中 * [Update] 优化小细节 * [Update] 更新翻译,删除多余代码 * [Update] 更新翻译信息
This commit is contained in:
@@ -21,7 +21,7 @@ class JMSBaseInventory(BaseInventory):
|
||||
'id': asset.id,
|
||||
'hostname': asset.hostname,
|
||||
'ip': asset.ip,
|
||||
'port': asset.port,
|
||||
'port': asset.ssh_port,
|
||||
'vars': dict(),
|
||||
'groups': [],
|
||||
}
|
||||
@@ -29,8 +29,15 @@ class JMSBaseInventory(BaseInventory):
|
||||
info["vars"].update(self.make_proxy_command(asset))
|
||||
if run_as_admin:
|
||||
info.update(asset.get_auth_info())
|
||||
if asset.is_unixlike():
|
||||
info["become"] = asset.admin_user.become_info
|
||||
for node in asset.nodes.all():
|
||||
info["groups"].append(node.value)
|
||||
if asset.is_windows():
|
||||
info["vars"].update({
|
||||
"ansible_connection": "ssh",
|
||||
"ansible_shell_type": "cmd",
|
||||
})
|
||||
for label in asset.labels.all():
|
||||
info["vars"].update({
|
||||
label.name: label.value
|
||||
@@ -73,7 +80,7 @@ class JMSInventory(JMSBaseInventory):
|
||||
"""
|
||||
def __init__(self, assets, run_as_admin=False, run_as=None, become_info=None):
|
||||
"""
|
||||
:param host_id_list: ["test1", ]
|
||||
:param assets: assets
|
||||
:param run_as_admin: True 是否使用管理用户去执行, 每台服务器的管理用户可能不同
|
||||
:param run_as: 用户名(添加了统一的资产用户管理器之后AssetUserManager加上之后修改为username)
|
||||
:param become_info: 是否become成某个用户去执行
|
||||
@@ -86,17 +93,14 @@ class JMSInventory(JMSBaseInventory):
|
||||
host_list = []
|
||||
|
||||
for asset in assets:
|
||||
info = self.convert_to_ansible(asset, run_as_admin=run_as_admin)
|
||||
host_list.append(info)
|
||||
|
||||
if run_as:
|
||||
for host in host_list:
|
||||
host = self.convert_to_ansible(asset, run_as_admin=run_as_admin)
|
||||
if run_as:
|
||||
run_user_info = self.get_run_user_info(host)
|
||||
host.update(run_user_info)
|
||||
|
||||
if become_info:
|
||||
for host in host_list:
|
||||
if become_info and asset.is_unixlike():
|
||||
host.update(become_info)
|
||||
host_list.append(host)
|
||||
|
||||
super().__init__(host_list=host_list)
|
||||
|
||||
def get_run_user_info(self, host):
|
||||
@@ -133,12 +137,10 @@ class JMSCustomInventory(JMSBaseInventory):
|
||||
host_list = []
|
||||
|
||||
for asset in assets:
|
||||
info = self.convert_to_ansible(asset)
|
||||
host_list.append(info)
|
||||
|
||||
for host in host_list:
|
||||
host = self.convert_to_ansible(asset)
|
||||
run_user_info = self.get_run_user_info()
|
||||
host.update(run_user_info)
|
||||
host_list.append(host)
|
||||
|
||||
super().__init__(host_list=host_list)
|
||||
|
||||
|
@@ -220,6 +220,7 @@ class AdHoc(models.Model):
|
||||
time_start = time.time()
|
||||
try:
|
||||
date_start = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
history.date_start = date_start
|
||||
print(_("{} Start task: {}").format(date_start, self.task.name))
|
||||
raw, summary = self._run_only()
|
||||
date_end = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
@@ -134,8 +134,11 @@ function getSelectedAssetsNode() {
|
||||
var assetsNodeId = [];
|
||||
var assetsNode = [];
|
||||
nodes.forEach(function (node) {
|
||||
if (node.meta.type === 'asset' && !node.isHidden && node.meta.asset.protocol === 'ssh') {
|
||||
if (assetsNodeId.indexOf(node.id) === -1) {
|
||||
if (node.meta.type === 'asset' && !node.isHidden) {
|
||||
var protocols = $.map(node.meta.asset.protocols, function (v) {
|
||||
return v.name
|
||||
});
|
||||
if (assetsNodeId.indexOf(node.id) === -1 && protocols.indexOf("ssh") > -1) {
|
||||
assetsNodeId.push(node.id);
|
||||
assetsNode.push(node)
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ def update_or_create_ansible_task(
|
||||
run_as_admin=False, run_as=None, become_info=None,
|
||||
):
|
||||
if not hosts or not tasks or not task_name:
|
||||
return
|
||||
return None, None
|
||||
set_to_root_org()
|
||||
defaults = {
|
||||
'name': task_name,
|
||||
|
Reference in New Issue
Block a user