Merge pull request #11003 from jumpserver/pr@dev@fix_ansiblejobrunerror

fix: 修复批量执行命令时资产名称包含 [ 特殊字符执行报错的问题(issue: 10986)
pull/11009/head
老广 2023-07-18 18:14:32 +08:00 committed by GitHub
commit 0c34a41381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -268,6 +268,7 @@ class JMSInventory:
data = {'all': {'hosts': {}}}
for host in hosts:
name = host.pop('name')
name = name.replace('[', '_').replace(']', '_')
data['all']['hosts'][name] = host
if self.exclude_localhost and data['all']['hosts'].__contains__('localhost'):
data['all']['hosts'].update({'localhost': {'ansible_host': '255.255.255.255'}})