From 29fdeef45f109575d8c2a0c78adcb2bd75b86f45 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 23 Aug 2023 18:53:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Host=20name=20?= =?UTF-8?q?=E4=B8=AD=E5=8C=85=E5=90=AB=20[=20=E5=AF=BC=E8=87=B4=20ansible?= =?UTF-8?q?=20=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/ansible/inventory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index a650b158e..6bbbb0be9 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -163,8 +163,9 @@ class JMSInventory: protocol = self.get_primary_protocol(ansible_config, protocols) + name = asset.name.replace(' ', '_').replace('[', '_').replace(']', '_') host = { - 'name': '{}'.format(asset.name.replace(' ', '_')), + 'name': name, 'jms_asset': { 'id': str(asset.id), 'name': asset.name, 'address': asset.address, 'type': asset.type, 'category': asset.category, @@ -281,7 +282,6 @@ class JMSInventory: data = {'all': {'hosts': {}}} for host in hosts: name = host.pop('name') - name = name.replace('[', '_').replace(']', '_') data['all']['hosts'][name] = host if not self.exclude_localhost: data['all']['hosts'].update({